Tag Archives: Dr Career

There will be row spacing problems in algorithm use in latex. Please use the ‘setstretch {1.35}

The algorithm template in latex is:
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.

Package pdftex.def Error: PDF mode expected, but DVI mode detected!_ mdpi_ Templatex compilation error in winedt

Use LaTeX to compile the following file types as follows:

\documentclass[journal,article,pdftex,10pt,a4paper]{IEEEtran}

Error as shown in the title appears:

Package pdftex.def Error: PDF mode expected, but DVI mode detected!(pdftex.def) If you are using `latex', then call `pdflatex'. }\@ehc

It is probably because of the difference between the compilation of latex and pdflatex. Using the mode of latex, the latter cannot be compiled.

The option pdftex is for use with pdfLaTeX. If eps figure are used, remove the option pdftex and use LaTeX and dvi2pdf.

In other words, eps(embedded PostScript) image documents should be used with latex mode, while pdftex will cause problems (the solution is to try to delete pdftex).
In addition, the same problem will occur when I see my net friends in the following usage:

\usepackage[pdftex]{graphicx}

The solution is to remove the [pdftex], the graphicx package will compile normally, but in the pdftex mode, it is better to convert the . Eps file into the . PDF file.
If you use commands such as \includegraphics{file} to load the display image file, the two modes mentioned above will automatically complete the extension of the filefile, and latex mode will be supplemented with file.eps. While pdftex will be completed as file.pdf (or file.png, file.jpg).