# Continued fraction is hard to read

So this sort of ties into this question on Puzzling.SE about making π out of the numbers [1...n] for n=[1,2,3...20]. I am currently working on a document using LAT EX that I am going to publish as an online reference when all n=[1,2,3...20] are figured out.

I am currently working off of my community wiki answer for the info and decided to jump to n=17 and input those formulas so I wouldn't have to do them later.

I currently have the problem with the continued fraction for n=20 being hard to read since it appears really small.

However, in case this is a problem that I would otherwise need to take care of, I am okay with the formulas being squished between the \hlines.

Picture of problem:

Code:

\documentclass[12pt]{article}
\begin{document}

\begin{table*}
\begin{tabular}{|c|c|c|c|}
\hline
$n=$&Formula&Error&Credit\\\hline
1&1=1&2.14E0&Simd, 2012rcampion\\\hline
2&1+2=3&1.42E$-1$&Simd, 2012rcampion\\\hline
3&3=3&1.42E$-1$&Simd, 2012rcampion\\\hline
4&3+$\frac1{2\times4}=3.125$&1.66E$-2$&Simd, 2012rcampion\\\hline
5&3+$\frac1{2+5}=\frac{22}7$&1.26E$-3$&2012rcampion\\\hline
17&$\left(\frac1{10}\right)^{(4-6)/3}+8^{5-11}$&5.28E$-9$&CrSb0001\\&$-\frac7{12-2}-\frac{17-13}{14-9}$&&\\\hline
18&&&\\\hline
19&&&\\\hline
20&$3+\frac1{7+\frac{6-5}{15+\frac2{(10-8)+\frac{11-9}{(20\times14+12)+\frac{17-16}{13\times4}}}}}$&2.21E$-13$&Bubbler\\\hline
\end{tabular}
\end{table*}
\end{document}


Is there a way I could make the continued fraction bigger so it's easier to read? I have tried using \dfrac, but it completely breaks the fraction.

Edit: This is what I mean by "completely breaks the fraction":

• Welcome to TeX.SE. Have you tried using \cfrac? It's designed for continued fractions. But I assume it does so by making the fraction bigger just as dfrac does, so "completely breaks the fraction may still happen". Jan 4 at 18:31
• Could you explain what you mean by "breaking the entire fraction"? Jan 4 at 18:33
• but you did load amsmath? Jan 4 at 18:33
• @CrSb0001 Never ignore error messages, by the way. Jan 4 at 18:37
• if you tried \dfrac without amsmath you should have got an error. If you didn't see that change your compilation method or editor. Jan 4 at 18:40

Edit:
Consider @Mico comment and change specification for third column type (1.2e3 --> 1.2e-2) and siunitx specification (added print-zero-exponent option to sisetup).

Like this?

For above table are used tabularray package with libraries amsmath and siunitx where the second column is defined to be in math mode and left aligned, the third column is S type as defined in siunitx and tabularray package.

Since table is quite wide, in table is used \small font size.

\documentclass[12pt]{article}
\usepackage[margin=25mm]{geometry}
\usepackage{tabularray}
\UseTblrLibrary{amsmath, siunitx}
\sisetup{print-zero-exponent,
tight-spacing}
\usepackage{nccmath}   % for \mfrac (medium size fraction)

\begin{document}
\begin{table}
\begin{tblr}{hlines, vlines,
colspec = {Q[c]
X[l, mode=math]
Q[l, si={table-format=1.2e-2}]
l},
row{1}   = {guard, c, mode=text},
row{2-Z} = {rowsep = 5pt},
cells = {font=\small}
}
$n$ & Formula   & Error     & Credit                \\
1   & 1=1       & 2.14E 0   & Simd, 2012rcampion    \\
2   & 1+2=3     & 1.42E-1   & Simd, 2012rcampion    \\
3   & 3=3       & 1.42e-1   & Simd, 2012rcampion    \\
4   & 3+\mfrac1{2\times4}=3.125
& 1.66e-2   & Simd, 2012rcampion    \\
5   & 3+\mfrac1{2+5}=\mfrac{22}7
& 1.26E-3   &   2012rcampion        \\
17  & \Bigl(\frac1{10}\Bigr)^{(4-6)/3}+8^{5-11} - \frac7{12-2} - \frac{17-13}{14-9}
& 5.28E-9   & CrSb0001              \\
18  &           &           &                       \\
19  &           &           &                       \\
20  & 3+\cfrac1{7+\cfrac{6-5}{15+\cfrac2{(10-8)+\cfrac{11-9}{(20\times14+12)+\cfrac{17-16}{13\times4}}}}}
& 2.21E-13  & Bubbler               \\
\end{tblr}
\end{table}
\end{document}

• Okay, thank you! This actually helped :) Jan 4 at 19:56
• A minor detail: Should it be si={table-format=1.2e-2,print-zero-exponent} rather than si={table-format=1.2e3}? I'll conced that the print-zero-exponent option would come across as quite pedantic.
– Mico
Jan 5 at 1:33
• @Mico, as usual you are right. I already edited my answer. Happy and prosper 2024! Jan 5 at 7:29

Just get rid of the \hline directives or replace them with \addlinespace directives. And, do get rid of all vertical rules.

\documentclass[12pt]{article}
\usepackage[margin=1in,letterpaper]{geometry} % set page parameters as needed
\usepackage{array} % for '\newcolumntype' macro
\newcolumntype{L}{>{$}l<{$}}
\usepackage{amsmath}  % for '\cfrac' macro
\usepackage{booktabs} % for well-spaced horizontal rules
\begin{document}

\begin{table}[ht]
\footnotesize % optional, for a 20% linear reduction in font size
\centering
$\begin{array}{@{} c >{\displaystyle}l L L @{}} \toprule n & \text{Formula} & Error & Credit\\ \midrule 1 & 1=1 & 2.14E0 & Simd, 2012rcampion\\ \addlinespace 2 & 1+2=3 & 1.42E-1 & Simd, 2012rcampion\\ \addlinespace 3 & 3=3 & 1.42E-1 & Simd, 2012rcampion\\ \addlinespace 4 & 3+\frac{1}{2\cdot4}=3.125 & 1.66E-2 & Simd, 2012rcampion\\ \addlinespace 5 & 3+\frac{1}{2+5}=\frac{22}{7} & 1.26E-3 & 2012rcampion\\ \addlinespace \vdots \\ \addlinespace 17 & \Bigl(\frac{1}{10}\Bigr)^{(4-6)/3} -\frac{7}{12-2}-\frac{17-13}{14-9} & 5.28E-9 & CrSb0001\\ \addlinespace 18 & \dots \\ \addlinespace 19 & \dots \\ \addlinespace 20 & 3+\cfrac{1}{7+\cfrac{6-5}{15+\cfrac{2}{(10-8)+\cfrac{11-9}{(20\cdot14+12)+\cfrac{17-16}{13\cdot4}}}}} & 2.21E-13 & Bubbler \\ \addlinespace \bottomrule \end{array}$
\end{table}

\end{document}


I'd opt for a more open look; also using siunitx for the third column seems the best.

If you set the font to \small and the continued fraction in \footnotesize, you're able to set the table in the standard text width. However, these adjustments depend on the text width you use.

\documentclass[12pt]{article}
\usepackage{amsmath}
\usepackage{booktabs}
\usepackage{siunitx}

\sisetup{
output-exponent-marker=\mathrm{E},
}

\begin{document}

\begin{table}
\centering
\small

\begin{tabular}{@{}ccS[table-format=1.2e-1]c@{}}
\toprule
$n$ & Formula & {Error} & Credit\\
\midrule
1 & $1=1$ & 2.14E0 & Simd, 2012rcampion\\
2 & $1+2=3$ & 1.42E-1 & Simd, 2012rcampion\\
3 & $3=3$ & 1.42E-1 & Simd, 2012rcampion\\
4 & $3+\frac1{2\times4}=3.125$ & 1.66E-2 & Simd, 2012rcampion\\
5 & $3+\frac1{2+5}=\frac{22}7$ & 1.26E-3 & 2012rcampion\\
17 & $\left(\frac1{10}\right)^{(4-6)/3}+8^{5-11}-\frac7{12-2}-\frac{17-13}{14-9}$ &
5.28E-9 & CrSb0001\\
18 & & & \\
19 & & & \\
20 &
\footnotesize
$3+\cfrac{1}{ 7+\cfrac{6-5}{ 15+\cfrac{2}{ (10-8)+\cfrac{11-9}{ (20\times14+12)+\cfrac{17-16}{ 13\times4 } } } } }$ & 2.21E-13 & Bubbler\\
\bottomrule
\end{tabular}

\caption{The caption}
\end{table}

\end{document}


Why -2pt? Because if I set the table without this adjustment, the overfull is a tad less than 12pt and there are six intercolumn spaces to exploit.

Alternatively, you might do

\begin{table}
\centering
\small
\setlength{\tabcolsep}{0pt}

\begin{tabular*}{\textwidth}{
@{\extracolsep{\fill}}
c
c
S[table-format=1.2e-1]
c
}
[identical body of the tabular]
\end{tabular*}

\caption{Table caption}

\end{table}

• +1. Did you mean to write \setlength{\tabcolsep}{0pt} in the second solution? Adding table-alignment=left as an option for the S column type would help left-align the header word "Error". Incidentally, neither "18" nor "19" appear to occur anywhere in the continued fraction expression; this could be remedied [ouch!] by, say, replacing 2 with 2\times(19-18). :-)
– Mico
Jan 5 at 2:11
• @Mico Thanks for spotting the typo. Why are you suggesting left alignment? The header is perfectly centered in the column. Jan 5 at 7:06
• Ah, I was somehow thinking that the header cells should be left-aligned. Not needed.
– Mico
Jan 5 at 7:38