如何按以下格式排版连分数?

如何按以下格式排版连分数?

如何排版下面的连分数,如下所示?

在此处输入图片描述

来源:关于连分数和递归序列的注释作者:阿尔弗雷德·范德波尔滕 (Alfred van der Poorten)。

注意:Alf van der Poorten 的风格与欧拉 (在 E071 中) 的风格相似。

在此处输入图片描述

来源:欧拉档案,索引编号 E71。

答案1

此变体节省了垂直空间。由于线条缩短,本例中使用的连分数上方有许多可用空间。此外,它还保留了用于求和的数学轴。

\documentclass{article}
\usepackage{amsmath}

\begin{document}
\newcommand*{\cofrac}[2]{%
  {%
    \rlap{$\dfrac{1}{\phantom{#1}}$}%
    \genfrac{}{}{0pt}{0}{}{#1+#2}%
  }%
}
\[
  a_0 +
  \cofrac{a_1}{
    \cofrac{a_2}{
      \cofrac{a_3}{
        \genfrac{}{}{0pt}{0}{}{\ddots}
  }}}
\]
\end{document}

结果

答案2

我不知道如何以您展示的样式生成连分数。不过,该amsmath软件包提供了\cfrac命令,可用于生成以下表达式——我认为,该表达式比 van der Poorten 书中的表达式更容易解析。

\documentclass{article}
\usepackage{amsmath}
\begin{document}
\begin{equation*}
a_0+\cfrac{1}{a_1+\cfrac{1}{a_2+\cfrac{1}{a_3+\cdots}}}
\end{equation*}
\end{document}

在此处输入图片描述

答案3

这是我使用的解决方案。

在此处输入图片描述

\documentclass[10pt,a4paper]{article}
\usepackage[utf8]{inputenc}
\usepackage{fancyvrb}

\setlength{\parindent}{0cm}
\newcommand\latex{\verb}
\DefineVerbatimEnvironment{Latex}{Verbatim}{numbers=left,numbersep=2mm}

\renewcommand\quote[1]{"#1"}

% == PACKAGES USED == %

\usepackage{mathtools}
\usepackage{ifmtarg}


% == DEF : Continued Fractions == %

% Sources :
%    * https://groups.google.com/forum/?hl=fr&fromgroups#!topic/fr.comp.text.tex/UrUZiurKwm0
%    * http://tex.stackexchange.com/questions/68190/continued-fraction-in-inline-equations/68196#68196
%    * http://tex.stackexchange.com/questions/23432/how-to-create-my-own-math-operator-with-limits

\makeatletter
% Operator-like output
\def\contFracOpe{%
    \operatornamewithlimits{%
        \mathchoice{% * Display style
            \vcenter{\hbox{\huge $\mathcal{K}$}}%
        }{%           * Text style
            \vcenter{\hbox{\Large $\mathcal{K}$}}%
        }{%           * Script style
            \mathrm{\mathcal{K}}%
        }{%           * Script script style
            \mathrm{\mathcal{K}}%
        }
    }
}


% Operation-like output
    \newcommand\contFrac{\@ifstar{\@contFracStar}{\@contFracNoStar}}

    \def\singleContFrac#1#2{%
        \begin{array}{@{}c@{}}%
            \multicolumn{1}{c|}{#1}%
            \\%
            \hline%
            \multicolumn{1}{|c}{#2}%
        \end{array}%
    }

% No star version 
    \def\@contFracNoStar#1{%
% //\@nil is usefull if only one argument is given.
        \mathchoice{% * Display style
            \@contFracNoStarDisplay@#1//\@nil%
        }{%           * Text style
            \@contFracNoStarInline@#1//\@nil%
        }{%           * Script style
            \@contFracNoStarInline@#1//\@nil%
        }{%           * Script script style
            \@contFracNoStarInline@#1//\@nil%
        }%
    }

% No star version - Display style
    \def\@contFracNoStarDisplay@#1//#2\@nil{%
        \@ifmtarg{#2}{%
            #1%
        }{%
            #1+\cfrac{1}{\@contFracNoStarDisplay@#2\@nil}%
        }%
    }

% No star version - Inline style
        \def\@contFracNoStarInline@#1//#2\@nil{%
            \@ifmtarg{#2}{%
                #1%
            }{%
                #1 \@@contFracNoStarInline@@#2\@nil%
            }%
        }
        \def\@@contFracNoStarInline@@#1//#2\@nil{%
            \@ifmtarg{#2}{%
                + \singleContFrac{1}{#1}%
            }{%
                + \singleContFrac{1}{#1} \@@contFracNoStarInline@@#2\@nil%
            }%
        }

% Star version 
    \def\@contFracStar#1{%
        \mathchoice{% * Display style
% ////\@nil is usefull if only one argument is given.
            \@contFracStarDisplay@#1////\@nil%
        }{%           * Text style
% //\@nil is usefull if only one argument is given.
            \@contFracStarInline@#1//\@nil%
        }{%           * Script style
            \@contFracStarInline@#1//\@nil%
        }{%           * Script script style
            \@contFracStarInline@#1//\@nil%
        }%
    }

% Star version - Display style
    \def\@contFracStarDisplay@#1//#2//#3\@nil{%
        \@ifmtarg{#2}{%
            #1%
        }{%
            #1 + \cfrac{#2}{\@contFracStarDisplay@#3\@nil}%
        }%
    }

% Star version - Inline style
        \def\@contFracStarInline@#1//#2\@nil{%
            \@ifmtarg{#2}{%
                #1%
            }{%
                #1 \@@contFracStarInline@@#2\@nil%
            }%
        }
        \def\@@contFracStarInline@@#1//#2//#3\@nil{%
            \@ifmtarg{#3}{%
                + \singleContFrac{#1}{#2}%
            }{%
                + \singleContFrac{#1}{#2} \@@contFracStarInline@@#3\@nil%
            }%
        }
\makeatother


\begin{document}

\section{Unstarred version}

$\displaystyle \contFrac{u_0 // u_1 // u_2 // \dots // u_n}$


$\contFrac{u_0 // u_1 // u_2 // \dots // u_n}$


\section{Starred version}

$\displaystyle \contFrac*{a // b // c // d // e // f // \dots // y // z}$


$\contFrac*{a // b // c // d // e // f // \dots // y // z}$.

\section{Operator}

$\displaystyle
    \contFracOpe_{k=1}^{n} (b_k:c_k)
    =
    \cfrac{b_1}{\displaystyle \contFrac*{c_1 // b_2 // c_2 // b_3 // \dots // b_n // c_n}}
$

\end{document}

答案4

您可以修改垂直间距。

\documentclass{article} 
\usepackage{mathtools}
\begin{document}    
\[
a_0+
  \raisebox{-.25\height}{$\dfrac{1}{a_1\mathrlap{\,+}}$}\mkern15mu
    \raisebox{-1.1\height}{$\dfrac{1}{a_2\mathrlap{\,+}}$}\mkern15mu
      \raisebox{-2.0\height}{$\dfrac{1}{a_3\mathrlap{\,+}}$}\mkern15mu
        \raisebox{-3\height}{$\ddots$}
\]
\end{document}

在此处输入图片描述

相关内容