1

I am trying the following table that I found online, but there is an error in the specific lines:

 \begin{tabular}{%
    >{\begin{math}}c<{\end{math}}

I don't know what is causing the latex compiler to complain. The error message is

unclosed \begin{tabular} found at \end{math} unclosed open group { found at \end{math}

Any ideas?

\documentclass{article}
\usepackage[utf8]{inputenc}    
\usepackage[T1]{fontenc}
\usepackage{array,booktabs}
\usepackage{siunitx}
 \usepackage{etoolbox}

\begin{document}

\begin{tabular}{%
>{\begin{math}}c<{\end{math}} % first column centered in math mode
S[% second column uses siunitx
output-exponent-marker = {\mathrm{E}},% use `E' as exponent marker
print-implicit-plus,% add + to positive numbers
reset-text-family=false,% use active text font (\ttfamily)
mode=text,% print as text
table-format=1.15e2,% one integer digit, 14 decimal digits, 2 exponent digits
minimum-decimal-digits=15,% pad to 14 decimal places
group-digits=false% don't put digits in blocks of 3
]}
\midrule
\multicolumn{1}{c}{\textrm{\textbf{Variable}}} & \multicolumn{1}{c}{\textrm{\textbf{magnitude}}} \\
\toprule
x_{1}  & 8.337723370858222e-01  \\
y_{2}  & -3.690152225162680e-01  \\
z_{3}  & 7.763961719898990e-01  \\
\bottomrule
\end{tabular}



\end{document}
3
  • 1
    You have spurious \endgroup after table. Remove it!
    – Zarko
    Nov 25, 2022 at 8:15
  • Thanks, you are right. It is still complaining though.
    – Morcus
    Nov 25, 2022 at 8:21
  • No, it compile fine. But, see my answer, you may liked it :-)
    – Zarko
    Nov 25, 2022 at 8:34

2 Answers 2

1
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{tabularray}
\UseTblrLibrary{booktabs, siunitx}

\begin{document}

\begin{tblr}{colspec = {Q[c,mode=math] 
                        S[output-exponent-marker = {\mathrm{E}}, % use `E' as exponent marker
                          print-implicit-plus,                   % add + to positive numbers
                          %reset-text-family=false,              % use active text font (\ttfamily)
                          %mode=text,                            % print as text
                          table-format=-1.15e-1,                   % one integer AND 14 decimal digits, 2 exponent digits
                          minimum-decimal-digits=15,             % pad to 14 decimal places
                          group-digits=false                     % don't put digits in blocks of 3
                          ]
                         },
            row{1} = {guard, mode=text, font=\bfseries}
            }
    \toprule
Variable    & Magnitude             \\
    \midrule
    x_{1}  &  8.337723370858222e-01  \\
    y_{2}  & -3.690152225162680e-01  \\
    z_{3}  &  7.763961719890e-01     \\
    \bottomrule
\end{tblr}

\end{document}

enter image description here

2
  • Since you're showing the + and - sign symbols, and given that there's a single digit in the exponential term, I think it should be table-format=-1.15e-1, not table-format=1.15e2.
    – Mico
    Dec 25, 2022 at 23:48
  • 1
    @Mico, you are right. Corrected now.
    – Zarko
    Dec 26, 2022 at 1:19
0

Please do your readers a big favor and make the table more readable and visually appealing. For instance, what's the purpose of showing fifteen [15!] decimal digits of numbers? Three decimal digits should be more than enough to convey whatever message you intend to convey by showing the numbers. Fortunately, the S column type makes it easy to round numbers to a preset number of digits. See the code below for an implentation of this claim. Oh, and don't use bold-facing of the header row unless you want to risk creating a typographic vulgarity.

enter image description here

\documentclass{article}
%%\usepackage[utf8]{inputenc}  % that's the default nowadays   
\usepackage[T1]{fontenc}
\usepackage{array,booktabs,siunitx}

\begin{document}

\begin{tabular}{@{}
   >{$}c<{$} % not ">{\begin{math}}c<{\end{math}}"
   S[round-mode      = places,
     round-precision = 3,
     table-format    = -1.3e-1,
     exponent-product= \cdot] @{}}
   \toprule
   \text{Variable} & {\text{Magnitude}} \\
   \midrule
   x_{1} &  8.337723370858222e-01  \\
   y_{2} & -3.690152225162680e-01  \\
   z_{3} &  7.763961719898990e-01  \\
   \bottomrule
\end{tabular}

\end{document}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .