# Algorithm: overlapping code lines and misplaced final horizontal line

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}
\history{Received: date; Accepted: date; Published: date}

% 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}

$^{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:

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

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:

However, I would rather maintain the scriptsize.

Is there any way to obtain my desired output?

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}