LaTeX algorithm typesetting

method one

Need to be included

\usepackage[noend]{algpseudocode}

\usepackage{algorithmicx,algorithm}

Source code

\begin{algorithm}[t]
\caption{algorithm caption}The name of the algorithm
\hspace*{0.02in} {\bf Input:}The input of the% algorithm, \ hspace * {0.02in} is used to control the position, while using \\
input parameters A, B, C\\
\hspace*{0.02in} {\bf Output:}% Algorithm output
output result
\begin{algorithmic}[1]
\StateWrite some general statements after some description% \ State
\For{condition}The% For statement, which needs to correspond to EndFor
  \State ...
  \If{condition}% If statement, need to correspond to EndIf
    \State ...
  \Else
    \State ...
  \EndIf
\EndFor
\While{condition}% While statement, need to correspond to EndWhile
  \State ...
\EndWhile
\State \Return result
\end{algorithmic}
\end{algorithm}

  Results screenshot

Note

1. The capitalization of keywords, otherwise Undefined control sequence will appear.

2. The control flow should correspond back and forth. If there is While, but there is no EndWhile, otherwise Some blocks are not closed.

Method 2

Need to be included

\usepackage[ruled]{algorithm2e}

Source code

\begin{algorithm}[H]
\caption{algorithm caption}% Algorithm name
\LinesNumbered% Requires a line number to be displayed
\KwIn{input parameters A, B, C}%Input parameters
\KwOut{output result}% Output
some description\;% \; For line breaks
\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}

Results screenshot

Method three

Need to be included

\usepackage[ruled,vlined]{algorithm2e}

Source code

Same method two

Results screenshot

Intelligent Recommendation

latex- typesetting (summary)

This article is a summary of the paper in front of LaTeX typesetting article. Previous articles are papers were several ways to tell LaTeX typesetting issue, where a combination of the foregoing,It gi...

latex- typesetting 3

A picture is worth a thousand words (a picture is worth a thousand words). The importance of drawing in the paper self-evident,Mainly on the graph paper production and insertion. 1, the image insertio...

Texmaker installation for LaTex typesetting

About LaTex Texmaker Texmaker is a cross-platform typesetting artifact that supports win, linux, macos. It includes unicode support, spell checking, auto-completion, code folding, and a built-in pdf v...

LaTex typesetting skills (1)

Presentation beamer 1. Algorithm Macro package Code Effect picture: 2. Optimization problem Effect picture: 3. Quote pictures Effect picture:...

LaTex basic typesetting tutorial

I just used a little free time in the afternoon to make a LaTeX tutorial. I think it is usually enough. This is very similar to the use of code for typesetting in web page design. Like the HTML langua...

More Recommendation

Latex typesetting-table insertion

Latex typesetting-table insertion  (2010-07-16 12:35:44) http://blog.sina.com.cn/s/blog_57235cc70100jnpo.html Reprint▼ label:  latex   tabel   Miscellaneous talk classification:&nb...

Latex typesetting complete solution

LATEX (English pronunciation: /ˈleɪtɛk/ LAY-tek or English pronunciation: /ˈlɑːtɛk/ LAH-tek, transliteration "Laterhe") is a typesetting system based on TEX. American computer scientist Lesl...

Install LATEX, related typesetting

  The first part software installation 1. First install LATEX download link:http://www.miktex.org/download. Follow the steps to install, the new version of Latex will come with its own document e...

Typora and LaTeX typesetting

Knowledge reserve: HTML、CSS、JS MathType、LaTeX 1. Typora common editing skills Title: Ctrl + 1,2...6 Highlight: == Highlight content == Select: Ctrl + D (word)/L (line) Center: <center>Center con...

latex typesetting notes

The format written in latex does not need to be adjusted by yourself, which is similar to programming. For the relationship between latex and winedt, please refer to Baidu: Getting started content: pr...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top