# Continued fractions

How do I make this in LaTeX? I keep losing track of the brackets.

• Do you know about the \cfrac macro provided by the amsmath package?
– Mico
Dec 30, 2016 at 18:25
• I don't have any packages, I use latex2png.com, as my teacher told me to use it. Dec 30, 2016 at 18:26
• \cfrac works at that site, I just tried Dec 30, 2016 at 18:31
• Checked with y = 2+\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{1+\dots}}} on that site, it works
– user31729
Dec 30, 2016 at 18:32
• See this answer of mine for being able to use the friendlier syntax e=\xcontfrac{2;1,2,1,4,1,1,6+\cfraccdots} (in math mode, of course). Dec 30, 2016 at 19:09

The following code is "full LaTeX":

\documentclass{article}
\usepackage{amsmath} % for "\cfrac" macro
\begin{document}
$\mathrm{e}= 2+\cfrac{1}{1+\cfrac{1}{2+\cfrac{1}{1+\cfrac{1}{1+ \cfrac{1}{4+\cfrac{1}{1+\cfrac{1}{1+\cfrac{1}{6+ \cdots\vphantom{\cfrac{1}{1}} }}}}}}}}$
\end{document}


If you want, you can copy and paste the math part -- the stuff between $ and $ -- into latex2png.com.

• I am SO grateful! Thank you very much Mico (and all others helping me out) Dec 30, 2016 at 18:35
• I learned something new today as well: the existence of the site latex2png.com!
– Mico
Dec 30, 2016 at 18:36
• Our teacher told us we had to use it in our assignments, glad we could learn each other something. I think it's really nice to get into such a respectful and friendly community Dec 30, 2016 at 18:38

Or, using no packages:

\documentclass{standalone}
\begin{document}
$e= 2+\frac{1}{1+\frac{1}{2+\frac{1}{1+\frac{1}{1+\frac{1}{4+\frac{1}{1+\frac{1}{1+\frac{1}{6+\cdots}}}}}}} }$
\end{document}


Yields:

Although \cfrac works better, this seemed to be what you were originally trying to get.

The copyable code for the website would be:

e=2+\frac{1}{1+\frac{1}{2+\frac{1}{1+\frac{1}{1+\frac{1}{4+\frac{1}{1+\frac{1}{1+\frac{1}{6+\cdots}}}}}}}}