2

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.

enter image description here

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!

  • Please make a small example document and add it inline to your question. this question and its answers are archived forever and will not make sense unless you also keep that github project unchanged forever. – David Carlisle Jul 5 '18 at 6:38
  • @DavidCarlisle Just updated this question with my demo tex code as well as a link to download the template files. The styling files are too big and it is beyond my ability to make it inline. – Qoros Jul 5 '18 at 6:52
  • better thanks (a MWE would be better still, but this will do:-) incidentally \bf isn't supposed to be used in latex – David Carlisle Jul 5 '18 at 6:57
  • @DavidCarlisle Thanks for the suggestions. updated with \bf removed. – Qoros Jul 5 '18 at 7:13
1

enter image description here

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:

\section{Hello}
\begin{algorithm}[t]
\setlength\baselineskip{13.5pt}
  • Thanks for your reply. It works. Actually, I also get a reply from MDPI editor, they shared a similar answer. – Qoros Jul 5 '18 at 8:43
  • +1 I am also using the MDPI template and I am encountering the same problem. This got me through. – Jimmy R. Jul 28 at 11:57

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.