1

I am currently adapting an article to the MDPI template and I have encountered some problems with the algorithm package. Code lines overlap and the last code line appears below the end horizontal line. This is my main file:

\documentclass[sensors,article,submit,moreauthors,pdftex,10pt,a4paper]{Definitions/mdpi}

\usepackage{conf-simple}


\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}[H]
    \caption{: do something \label{alg:1}}
    \begin{algorithmic}[1] % The number tells where the line numbering should start
    \Procedure {Do}{something $n$}
         \If {connected}
           \State send 
         \Else 
           \State store 
         \EndIf
     \EndProcedure 
    \end{algorithmic} \end{algorithm}


\end{document}

My conf-simple.sty file:

\ProvidesPackage{conf-simple}

\usepackage{algorithm}
\usepackage[noend]{algpseudocode} 
\renewcommand{\ALG@beginalgorithmic}{\scriptsize}

This is my desired output: enter image description here

If I change documentclass to \documentclass{article} it is generated. However what I get with the mpdi template is: enter image description here

I have found this question and I have tried to follow the proposed solution. However, adding \setlength\baselineskip{20pt} has no effect on my output. It only has effect if I comment my configuration line that sets the font size to scriptsize. Then, it solves the overlapping lines problem but not the problem with the final horizontal line. This is the output: enter image description here

However, I would rather maintain the scriptsize.

Is there any way to obtain my desired output?

0

I haven't figured out where this incompatibility comes from. But I have a solution. Use the spacing environment to increase the spacing:

\begin{algorithm}[H]
    \caption{: do something \label{alg:1}}
    \begin{spacing}{2} %% you can adjust the amount of spacing here
    \begin{algorithmic}[1]
    \Procedure {Do}{something $n$}
         \If {connected}
           \State send 
         \Else 
           \State store 
         \EndIf
     \EndProcedure 
    \end{algorithmic} 
    \end{spacing} %% end of the spacing environment
\end{algorithm}

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.