Latex algorithm Typesetting notes

Source: Internet
Author: User

Way One
    • Need to include the

      \usepackage[noend]{algpseudocode}\usepackage{algorithmicx,algorithm}
    • Source

      %算法的名字%算法的输入, \hspace*{0.02in}用来控制位置,同时利用 \\ 进行换行%算法的结果输出% \State 后写一般语句% For 语句,需要和EndFor对应% If 语句,需要和EndIf对应% While语句,需要和EndWhile对应  \State ...\EndWhile\State \Return result\end{algorithmic}\end{algorithm}

Note :

    1. The capitalization of the keyword is problematic, otherwise Undefined control sequence will appear.
    2. The control flow should correspond to the front and back. If there is while but there is no endwhile, the Some blocks is not closed appears.
Way Two
    • Need to include the

      \usepackage[ruled]{algorithm2e}
    • Source

      \begin{algorithm}[H]    \caption{algorithm caption}%算法名字    %要求显示行号    \KwIn{input parameters A, B, C}%输入参数    \KwOut{output result}%输出    %\;用于换行    \For{condition}{        only if\;        \If{condition}{            1\;        }    }    \While{not at end of this document}{        if and else\;        \eIf{condition}{            1\;        }{            2\;        }    }    \ForEach{condition}{        \If{condition}{            1\;        }    }\end{algorithm}
Mode three
    • Need to include the

      \usepackage[ruled,vlined]{algorithm2e}
    • Source

      \begin{algorithm}[H]    \caption{algorithm caption}%算法名字    %要求显示行号    \KwIn{input parameters A, B, C}%输入参数    \KwOut{output result}%输出    %\;用于换行    \For{condition}{        only if\;        \If{condition}{            1\;        }    }    \While{not at end of this document}{        if and else\;        \eIf{condition}{            1\;        }{            2\;        }    }    \ForEach{condition}{        \If{condition}{            1\;        }    }\end{algorithm}

For more information on the form, refer to:

    • Drawing of various forms of "LaTeX Tips"

Latex algorithm Typesetting notes

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.