3

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:

$1+\dfrac{1}{2+
\dfrac{1}{\scalebox{.9}{2+{}}
\dfrac{\hfill\scalebox{.9}{1}\hfill}{\scalebox{.8}{2+{}}
\dfrac{\hfill\scalebox{.8}{1}\hfill}{\scalebox{.7}{2+{}}
\dfrac{\hfill\scalebox{.7}{1}\hfill}{\scalebox{.6}{2+{}}
\dfrac{\hfill\scalebox{.6}{1}\hfill}{\scalebox{.5}{2+{}}
\dfrac{\hfill\scalebox{.5}{1}\hfill}{\scalebox{.4}{2+{}}
\dfrac{\hfill\scalebox{.4}{1}\hfill}{\scalebox{.3}{2+{}}
\dfrac{\hfill\scalebox{.3}{1}\hfill}{\scalebox{.2}{2+{}}
}}}}}}}}}$

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 '18 at 14:43
4

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\fracscale{.8}
\def\etcfrac {\bgroup\def\egroups{\egroup}\etcfracA}
\def\etcfracA#1{\ifx\dots#1\cdots\egroups\else 
   \edef\egroups{\egroup$\egroup 
      \hbox{\pdfsave\pdfsetmatrix{\fracscale\space 0 0 \fracscale}%   
         \dimen0=\fracscale\wd0 \wd0=0pt \ht0=\fracscale\ht0 \dp0=\fracscale\dp0 
         \box0 \pdfrestore \kern\dimen0}\egroups}%
   \setbox0=\hbox\bgroup$\displaystyle\bgroup
   \expandafter\etcfracB\expandafter#1\fi
}
\def\etcfracB#1/#2#3{\dimen0=.8\dimen0
   \strut#1\over #2#3\etcfracA}

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

\bye

etcfrac

  • 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 – David Carlisle Mar 18 '18 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 '18 at 5:10
9

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

enter image description here

\documentclass{article}

\usepackage{amsmath}

\begin{document}

\[
1+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{2+\cfrac{1}
{\dots}}}}}}}}
\]

\end{document}
5

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

\documentclass{article}
\usepackage{amsmath,graphicx}

\newcommand{\scaledfrac}[3]{%
  \dfrac{#2}{\scalebox{#1}{$#3$}}%
}

\begin{document}

\[
1+
\scaledfrac{1}{1}{2+
\scaledfrac{.95}{1}{2+
\scaledfrac{.90}{1}{2+
\scaledfrac{.85}{1}{2+
\scaledfrac{.80}{1}{2+
\scaledfrac{.75}{1}{2+
\scaledfrac{.70}{1}{2+
\scaledfrac{.65}{1}{2+
\scaledfrac{.60}{1}{2+
\scaledfrac{.55}{1}{2+\dotsb}
}}}}}}}}}
\]

\end{document}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.