duplicate
I am using algorithm
package (built with pdflatex -shell-escape -synctex=1 -interaction=nonstopmode
under TexStudio
) to draw my algorithm. It works well on a template, but when I switch to another template, it is presented with lines overlapped as below.
The main tex file code is described below, please download the template source from mdpi.com:
\documentclass[journal,article,submit,moreauthors,pdftex,10pt,a4paper]{Definitions/mdpi}
\usepackage{algorithm}% http://ctan.org/pkg/algorithms
\usepackage[noend]{algpseudocode}
\firstpage{1}
\makeatletter
\setcounter{page}{\@firstpage}
\makeatother
\pubvolume{xx}
\issuenum{1}
\articlenumber{1}
\pubyear{2018}
\copyrightyear{2018}
\externaleditor{Academic Editor: name}
\history{Received: date; Accepted: date; Published: date}
\Title{Title}
% Author Orchid ID: enter ID or remove command
\newcommand{\orcidauthorA}{0000-0000-000-000X} % Add \orcidA{} behind the author's name
%\newcommand{\orcidauthorB}{0000-0000-000-000X} % Add \orcidB{} behind the author's name
% Authors, for the paper (add full first names)
\Author{Firstname Lastname $^{1,\dagger,\ddagger}$\orcidA{}, Firstname Lastname $^{1,\ddagger}$ and Firstname Lastname $^{2,}$*}
% Authors, for metadata in PDF
\AuthorNames{Firstname Lastname, Firstname Lastname and Firstname Lastname}
% Affiliations / Addresses (Add [1] after \address if there is only one affiliation.)
\address{%
$^{1}$ \quad Affiliation 1; e-mail@e-mail.com\\
$^{2}$ \quad Affiliation 2; e-mail@e-mail.com}
\corres{Correspondence: e-mail@e-mail.com; Tel.: +x-xxx-xxx-xxxx}
\firstnote{Current address: Affiliation 3}
\secondnote{These authors contributed equally to this work.}
\begin{document}
\section{Hello}
\begin{algorithm}[t]
\caption{algorithm caption}
\hspace*{0.02in} {Input:}
input parameters A, B, C\\
\hspace*{0.02in} {Output:}
output result
\begin{algorithmic}[1]
\State some description
\For{condition}
\State ...
\If{condition}
\State ...
\Else
\State ...
\EndIf
\EndFor
\While{condition}
\State ...
\EndWhile
\State \Return result
\end{algorithmic}
\end{algorithm}
\end{document}
I have set up an git project on github, please feel free to clone it and try compiling it with pdflatex
,
git clone https://github.com/qorost/latex-demo-algorithm.git
Any suggestions to increase the space between lines? any reply are appreciated!
Best Answer
It's some strange interaction with
setspace
package and the other settings used. I didn't trace everything but you can reset the baselineskip so it isn't so cramped: