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:
- [latex] latex adjust row spacing
- How to Use Subfigure in Latex
- LaTeX Error: Can be used only in preamble
- Latex row overflow problem overfull / hbox (1.1499pt too wide) in paragraph
- Some common problems in the use of vs2017
- There are many problems in the use of vs2017
- Algorithm error: LaTex error: \caption outside float
- What should be paid attention to in socket programming — bind socket error: address already in use
- How to use latex argmin argmax subscript
- How to use Latex to Write Matrices
- Port 4200 is already in use.Use ‘-port’ to specify a different port error Reasons
- Troubleshooting of errors in the installation and use of scienceplots
- Add a new page in latex
- The use of Chinese characters in Qt and the solution to the “error C2001: newline in constant” problem
- How to use dangerously set inner HTML in react
- How to use JavaScript in HTML
- Solution to the problem that listen TCP 0.0.0.0:3306: bind: address already in use port is occupied in Linux centos7
- AR# 57595 – Vivado Synthesis – ERROR: [Synth 8-4169] error in use clause: package ‘xxx‘ not found in
- Use Python to insert the specified content in the specified line of the specified file
- Use of rep function in R