Skip to content

[Bug]: Flextable issue rendering from quarto to latex - a11y #123

@Schiano-NOAA

Description

@Schiano-NOAA

Feature related to a problem:

  • when rendering a flextable (unsure of other table formats) in quarto to latex and adding tagging, tagging cannot be applied
  • there is a lot of redundant and unnecessary calls in the latex code produced from quarto
  • \multicolumn argument is sometimes empty (re: Gemini)
  • \multirow argument is unnecessary (re: Gemini)
  • Redundant use of \ between words in header names such as Fleet\ North (can specifically cause odd spacing in latex)
  • Re: Gemini -- Repeated font commands in every cell
    Remove all \textcolor[HTML]{000000}, \fontsize{11}{11}\selectfont, and \global\setmainfont{Arial} from inside the \multicolumn and \parbox commands. Set \setmainfont{Arial} once in your preamble
  • \ascline is not standard and should be replaced with \hline

Reprex:

\begin{longtable*}[c]{|p{0.75in}|p{0.75in}|p{0.75in}|p{0.75in}|p{0.75in}}

\ascline{1.5pt}{666666}{1-5}

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Product\ Category}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Quarter\ 1\ Sales}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Quarter\ 2\ Sales}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Growth\ (\%)}}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Notes}}}}} \\

\ascline{1.5pt}{666666}{1-5}\endfirsthead

\ascline{1.5pt}{666666}{1-5}

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Product\ Category}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Quarter\ 1\ Sales}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Quarter\ 2\ Sales}}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Growth\ (\%)}}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{\textbf{Notes}}}}} \\

\ascline{1.5pt}{666666}{1-5}\endhead

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Fruits}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{12,000}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{15,000}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{25.0}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Seasonal\ peak}}}} \\

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Vegetables}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{8,500}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{9,200}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{8.2}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Steady\ growth}}}} \\

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Grains}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{6,200}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{7,000}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{12.9}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{New\ product\ line}}}} \\


\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Dairy}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{9,800}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{10,500}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{7.1}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Stable}}}} \\

\multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Protein}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{7,500}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{8,100}}}} & \multicolumn{1}{>{\raggedleft}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{8.0}}}} & \multicolumn{1}{>{\raggedright}m{\dimexpr 0.75in+0\tabcolsep}}{\textcolor[HTML]{000000}{\fontsize{12}{12}\selectfont{\global\setmainfont{Arial}{Good\ performance}}}} \\

\ascline{1.5pt}{666666}{1-5}

\end{longtable*}

Proposed solution:

  • Simplifying code to make tables
  • Following suggestions from Gemini as noted above
  • Making sure no tables headers are merged
  • Use the following code:
\begin{longtable}[c]{|p{0.75in}|p{0.75in}|p{0.75in}|p{0.75in}|p{0.75in}|}
\hline % Replaced \ascline
\multicolumn{1}{|>{\raggedright\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Product Category}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Quarter 1 Sales}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Quarter 2 Sales}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Growth (\%)}} &
\multicolumn{1}{>{\raggedright\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Notes}} \\
\hline % Replaced \ascline
\endfirsthead
%
\hline % Replaced \ascline
\multicolumn{1}{|>{\raggedright\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Product Category}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Quarter 1 Sales}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Quarter 2 Sales}} &
\multicolumn{1}{>{\raggedleft\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Growth (\%)}} &
\multicolumn{1}{>{\raggedright\arraybackslash}m{\dimexpr 0.75in}|}{\textbf{Notes}} \\
\hline % Replaced \ascline
\endhead
%
Fruits & 12,000 & 15,000 & 25.0 & Seasonal peak \\ \hline
Vegetables & 8,500 & 9,200 & 8.2 & Steady growth \\ \hline
Grains & 6,200 & 7,000 & 12.9 & New product line \\ \hline
Dairy & 9,800 & 10,500 & 7.1 & Stable \\ \hline
Protein & 7,500 & 8,100 & 8.0 & Good performance \\
\hline % Replaced \ascline
\end{longtable}

*Note

  • formatting is not perfect and table lines are excessive for our use case
  • example is missing necessary packages

Add'l details:

necessary packages:

\documentclass{article} % Or your document class
\usepackage{longtable}
\usepackage{array}     % For m{} columns, >{} and \extracolsep
\usepackage{calc}      % For \dimexpr
\usepackage{xcolor}    % For \textcolor
\usepackage{fontspec}  % For \setmainfont
\usepackage{multirow}  % For \multirow command
% \usepackage{hhline}    % For more flexible horizontal rules (optional, replaces \hline)
% \usepackage{booktabs}  % For publication-quality rules (discourages vertical lines)

\setmainfont{Arial}    % Set Arial globally for the document

% If you want colored lines (requires xcolor and colortbl)
% \usepackage{colortbl}
% \newcommand{\tablelinecolor}{gray} % Define your line color
% \arrayrulecolor{\tablelinecolor}

\begin{document}

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingdevelopmentDocumenting aspects that need to be added into the repohelp wantedExtra attention is neededwontfixThis will not be worked on

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions