How to type a formula as below?

The following solution creates a macro called \bp -- short for "bottom-aligned plus symbol", I suppose -- which, in turn, is based on the \genfrac macro of the amsmath package.

enter image description here

\documentclass{article} % or some other suitable document class
\usepackage{amsmath} % for '\genfrac' macro
\newcommand\bp{\mathbin{\temp{+}}} % or: \newcommand\bp{\temp{+}}
\frac{426}{359} = 1+\frac15\bp\frac12\bp\frac11\bp\frac13\bp\frac11\bp\frac14 \,,

You can do it with a simpler user level syntax.

The command \contfrac has

  • an optional argument to print the value followed by =;
  • a mandatory argument for the integer part; if blank nothing is printed;
  • a mandatory argument for the sequence of integers in the continued fraction;
  • an optional argument to print the value preceded by =.

Of course one has to choose between the leading and the trailing optional argument.

This is to be used in displays only, of course.




  \tl_if_blank:nF { #1 } { #2 }

  \seq_set_from_clist:Nn \l_tmpa_seq { #1 }
  \seq_set_map:NNn \l_tmpb_seq \l_tmpa_seq { \__coeus_rfrac:n { ##1 } }
  $\displaystyle\seq_use:Nn \l_tmpb_seq { + }$

\cs_new_protected:Nn \__coeus_rfrac:n





The idea is to print the result and the integer part raised by the depth of a standard fractions; then all fractions are raised by the same amount, so the + signs are typeset at their regular height.

Finally we lower the whole thing to cover our tracks.

enter image description here