LaTeX连分数的输入

\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}

效果图

Result

\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}

效果图

enter image description here

\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}

效果图

enter image description here

\documentclass{article}
\usepackage{amsmath,mathtools}
\newcommand*{\underBracket}[2][1]{\underbracket[.6pt][0pt]{~#1\vphantom{g}~}_{\displaystyle #2\vphantom{g+1}}}

\begin{document}
    \begin{equation}
    a_0 + \underBracket{a_1\mathrlap{{}+ \underBracket{a_2\mathrlap{{} + \underBracket{a_3\mathrlap{{}+{}\raise-2.2ex\hbox{$\smash\ddots$}}}}}}}
    \hphantom{a_1 + a_2 + a_3 + {}} % to reset the spacing/aligning
    \end{equation}
\end{document}

效果图

enter image description here

\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}

enter image description here

自定义

% -----------------------------------------------------------------------------------
% Continued fractions for use in math environment
% Use \cofrac{a}{b}{c} for a/(b+c) at highest level
% Set c to a continued fractior to build recursive structure
% Use \cofracel{a}{b}{c} for recursive terms
% Matches line for fractions to correct size
% -----------------------------------------------------------------------------------
% Temporary variables
%
\newlength{\cfDeleted}
\newlength{\cfA}
\newlength{\cfB}
\newlength{\cfC}
\newlength{\cfX}
\newlength{\cfY}
% -----------------------------------------------------------------------------------
\newcommand{\cofrac}[3]
    {
        \setlength{\cfDeleted}{0pt}
        \cofracel{#1}{#2}{#3}\; \hspace{\cfDeleted}
    }
% ------------------------------------------------------------------------------------
\newcommand{\cofracel}[3]   
    {
        \settowidth{\cfA}{$#1$}
        \settowidth{\cfB}{$#2\;$}
        \settowidth{\cfC}{$#3$}
        % Calculate B + C and take max of B + C and A
        \setlength{\cfY}{\cfB}
        \addtolength{\cfY}{\cfC}
        \setlength{\cfX}{\maxof{\cfY}{\cfA}}
        % \cfX has "true" width of fraction - at least at this level
        % Now get 1/2 (A + B + C) and take greater of that and A by itself
        \addtolength{\cfY}{\cfA}
        \setlength{\cfY}{0.5\cfY}
        \setlength{\cfY}{\maxof{\cfY}{\cfA}}
        % \cfY has shortened width of fraction
        % calculate amount deleted
        \setlength{\cfC}{\cfX}
        \addtolength{\cfC}{-\cfY}
        \addtolength{\cfDeleted}{\cfC}
        % Promote to global here and save for later
        \global\cfDeleted=\cfDeleted
        \setlength{\cfX}{\cfDeleted}
        % then draw .. this may include multiple additional recursions
            {
                \mathrlap{\cfrac{#1}{{#2\;}{#3}}}\hspace{\cfY}
            }
        % and restore the saved deleted
        \global\cfDeleted=\cfX
    }
% ------------------------------------------------------------------------------------
\newcommand{\cofracdots}{\genfrac{}{}{0 pt}{}{\phantom{1}}{\ddots}}
% End of continued fractions
% ---------------------------------------------------------------
\cofrac{a}{b+}{\cofracel{aa}{bb+}{\cofracel{aaa}{bbb+}{\cofracdots}}}

效果图

example of continued fraction

以上选自How to typeset a continued fraction in the following format?

\documentclass{article}

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

\def\cFracB#1#2{%
\vcenter{\hbox{\strut$#1$\,\vrule}\hrule\hbox{\strut\vrule\,$#2$}}}

\begin{document}

$ A + \cFrac{B}{C} + \cFrac{D}{E}$.

$ A + \cFracB{B}{C} + \cFracB{D}{E}$.

\end{document}

enter image description here

\documentclass{standalone}

\usepackage{holtpolt}

\begin{document}

\[
a_0+\polter{1}{a_1}+\polter{1}{a_2}+\cdots+\polter{1}{a_n}+\cdots
\]

\end{document}

效果图

enter image description here

选自How do I typeset continued fractions in Pringsheim's concise notation?

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值