Package added at the top of latex files:

\usepackage{algorithm} \usepackage{algorithmic} \usepackage{setspace}

Algorithm block code:

\begin{algorithm}[htb] \setstretch{1.35} %Set the length of the rubber with the specified elasticity (1.35 times the original line width). \caption{} \label{alg:Framwork} \begin{algorithmic} \REQUIRE ~~\\ The set of positive samples for current batch, $P_n$;\\ The set of unlabelled samples for current batch, $U_n$;\\ Ensemble of classifiers on former batches, $E_{n-1}$; \ENSURE ~~\\ Ensemble of classifiers on the current batch, $E_n$; Extracting the set of reliable negative and/or positive samples $T_n$ from $U_n$ with help of $P_n$;\\ \label{ code:fram:extract } Training ensemble of classifiers $E$ on $T_n \cup P_n$, with help of data in former batches;\\ \label{code:fram:trainbase} $E_n=E_{n-1}\cup E$;\\ \label{code:fram:add} Classifying samples in $U_n-T_n$ by $E_n$;\\ \label{code:fram:classify} Deleting some weak classifiers in $E_n$ so as to keep the capacity of $E_n$;\\ \label{code:fram:select} $E_n$;\\ \end{algorithmic} \end{algorithm}

The actual algorithm results are shown as follows:

Second usage:

The processing is done using the Algorithm2e package

\documentclass{article} \usepackage{algorithm2e,setspace} \begin{document} \begin{algorithm} \setstretch{1.35} \SetAlgoLined \KwData{this text} \KwResult{how to write algorithm with \LaTeX2e } initialization\; \While{not at end of this document}{ read current\; \eIf{understand}{ go to next section\; current section becomes this one\; }{ go back to the beginning of current section\; } } \caption{How to write algorithms} \end{algorithm} \bigskip \begin{algorithm} \SetAlgoLined \KwData{this text} \KwResult{how to write algorithm with \LaTeX2e } initialization\; \While{not at end of this document}{ read current\; \eIf{understand}{ go to next section\; current section becomes this one\; }{ go back to the beginning of current section\; } } \caption{How to write algorithms} \end{algorithm} \end{document}

The above codes correspond to two algorithms respectively, and the algorithm blocks obtained are:

Common blocks of algorithms in Latex are set after querying, as described above, with other tricks of the process.

The above notes are only used to summarize experience in latex usage.

Latex typesetting needs to be kept calm, otherwise it is easy to make silly mistakes. If you encounter a format or method that you don’t know, use search engines frequently to find the answer.

In fact, I was stuck for a long time by the line spacing problem. The problem I encountered was because the line spacing of the algorithm was too small:

The problem of line spacing can be solved by web search, and also by consulting Liu Haiyang’s latex Latex Primer.

### Read More:

- Algorithm error: LaTex error: \caption outside float
- [latex] latex adjust row spacing
- LaTeX Error: Can be used only in preamble
- 11. Center text
- How to Use Subfigure in Latex
- One of the common mistakes of tex
- Let’s get started with latex 05, line feed, paragraph feed, page feed, first line indent, etc
- Add a new page in latex
- Three ways of latex supporting Chinese
- Several common methods of inserting pictures into latex documents
- About errors:! Package natbib error: Bibliography not compatible with author year citations
- The use of BibTex
- BibTeX: How to cite a website
- Causes and solutions of errors in “insufficient ram for flash algorithms”
- How to use Latex to Write Matrices
- “Error! Reference source not found.” “error! Reference source not found solution to problem for
- “Error! Reference source not found.” “error! The source of the problem was not found
- Package pdftex.def Error: PDF mode expected, but DVI mode detected!_ mdpi_ Templatex compilation error in winedt
- Latex bracket size control
- ! LaTeX Error: Option clash for package hyperref.