Latex use: Adding algorithmic modules to latex

Source: Internet
Author: User

Under MiKTeX, there are three latex algorithm bags, respectively: algorithm,algorithmic,algorithm2e Three, of which algorithm,algorithmic are used in a regular package:

The algorithm template in Latex is:

Top of the package included in the Latex file:

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

Algorithm block code:

\begin{algorithm}[htb]\setstretch{1.35}% sets the length of the rubber with the specified elasticity (1.35 times times the width of the original line) \caption{}\label{alg:framwork}\begin{algorithmic}\require~~\theSetof positive samples forCurrent batch, $P _n$;\theSetof unlabelled samples forCurrent batch, $U _n$;\ensemble of classifiers on former batches, $E _{n-1}$;\ensure~~\ensemble of classifiers on the current batch, $E _n$; Extracting theSetof 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 $ in $T _n \cup p_n$, with Hel P of Datainchformer batches;\\label{code:fram:trainbase} $E _n=e_{n-1}\cup e$;\\label{code:fram:add}classifying Samplesinch$U _n-t_n$ by $E _n$;\\label{code:fram:classify}deleting some weak classifiersinch$E _n$ So asTo keep the capacity of $E _n$;\\label{code:fram:Select} $E _n$;\\end{algorithmic}\end{algorithm}

The actual algorithm results are shown as:

Second usage:

Processing with the ALGORITHM2E package

\documentclass{article}\usepackage{algorithm2e,setspace}\begin{document}\begin{algorithm}\setstretch{1.35}\setalgolined\kwdata{ ThisText}\kwresult{how to write algorithm with \latex2e}initialization\;\while{not at end of ThisDocument} {Read Current\;\eif{understand}{go to next section\;current section becomes Thisone\;} {Go back to the beginning of current section\;}} \caption{how to write algorithms}\end{algorithm}\bigskip\begin{algorithm}\setalgolined\kwdata{ ThisText}\kwresult{how to write algorithm with \latex2e}initialization\;\while{not at end of ThisDocument} {Read Current\;\eif{understand}{go to next section\;current section becomes Thisone\;} {Go back to the beginning of current section\;}} \caption{how to write Algorithms}\end{algorithm}\end{document}

The above code corresponds to two algorithms respectively, the algorithm blocks obtained are:

Common algorithm blocks in latex as described above, other techniques used in the process can be queried and then set.

The above record is only used to summarize the experience of latex during its use.

Personal sentiment: Write latex must be quiet, otherwise it is prone to low-level errors. When you encounter a format or method that doesn't work, use a search engine to find answers.

In fact, here itself is the problem of the line is stuck for a long time, encountered the problem is because the algorithm line spacing is too small:

The setting of the line spacing problem can be solved by the network search, and consult the Liu "Latex primer" can also be well solved.

Latex use: Adding algorithmic modules to latex

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.