To create a continued fraction that truly symbolizes the endless, ever-ongoing nature of an infinite continued fraction, I have taken up this following "notation," where the font size shrinks with every step of the fraction:

fraction with each additional continuation becoming smaller

I generated it with the following code, compiled with amsmath and graphicx:


While I think that the design is decent for now, I would like to know how to fix a few problems in the appearance of the continued fraction, and why these problems arise:

  • The spacing of the plus operators get further and further distant from the fraction bar as the descent continues. How can I change my code to make the plus operators look more natural?
  • The numerators seem to be drifting away from the fraction bars. How can I refine the spacing between fractions? I suspect this has something to do with \scalebox not changing the size of the box of the fraction's numerator, and only scaling the text, but I haven't figured out how to improve this. Also, if this is the case, why does \scalebox do this?

Also, I feel that my code is in general very inefficient, considering that I need to employ so many braces at the end; solutions that alter the structure of my code are welcome.

  • 2
    This is not exactly "duplicate". The linked thread solves only continued fraction but the scaling and problem with alignment when scalebox is used is main issue here.
    – wipet
    Mar 17, 2018 at 14:43

3 Answers 3


It seem to more practical to create a macro which allow you to be more comfortable when you are writing these fractions. For example like this:

\def\etcfrac {\bgroup\def\egroups{\egroup}\etcfracA}
      \hbox{\pdfsave\pdfsetmatrix{\fracscale\space 0 0 \fracscale}%   
         \dimen0=\fracscale\wd0 \wd0=0pt \ht0=\fracscale\ht0 \dp0=\fracscale\dp0 
         \box0 \pdfrestore \kern\dimen0}\egroups}%
   \strut#1\over #2#3\etcfracA}

$  1 + \etcfrac 1/2+1/2+1/2+1/2+1/2+1/2+1/2+\dots $



  • It is surely bad advice to use pdftex specific primitives rather than use an abstraction like \scalebox that works on multiple systems. with pdftex I get multiple warnings pdfTeX warning: pdftex: Misplaced \pdfrestore by (4072955sp, 0sp) and it doesn't work at all with etex, xetex, or luatex Mar 18, 2018 at 19:18
  • That is your opinion. My opinion is that it is much more important that user of my code is free from using LateX, from using miniltx and from using any LaTeX package. If user needs to use xetex then only four well known lines of code need to be added (see lines 52, 64--66 from file opmac-xetex.tex, for example). And similar definitions can be done when user needs to use PostScript. BTW, thank you for your notice about "misplaced \pdfrestore". I corrected this bug in my code.
    – wipet
    Mar 19, 2018 at 5:10

Avoid applying scaling to text. amsmath has a specific command for continued fractions:

enter image description here






I wouldn't use this graphic device, but it's not difficult to obtain it:






enter image description here

You must log in to answer this question.

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