1

I am not sure the bug below has already been reported as I cannot find clear information online. See the MWE: if \usepackage{hyperref} is not commented, the space below the equation is fairly large, way more than when the package is commented. It looks like it is a bad interaction between hyperref and the STATE command of the algorithmic package:

\documentclass{book}
\usepackage{algorithmic}
\usepackage{hyperref}
\begin{document}
\setlength\abovedisplayshortskip{0pt}
\setlength\belowdisplayshortskip{0pt}
\setlength\abovedisplayskip{0pt}
\setlength\belowdisplayskip{0pt}
\begin{algorithmic}
\STATE text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
\STATE text text text text text text text text text text text text text
\STATE text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
text text text text text text text text text text text text text
\end{algorithmic}
text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
text text text text text text text text text text text text text
\end{document}

enter image description here

  • A solution by adding: \usepackage{etoolbox} \AfterEndEnvironment{equation}{\vskip-0.5\baselineskip} – M.Ahmadi Oct 6 '19 at 20:21
  • @M.Ahmadi Not sure because it affects all equations in the document and only very few of them have an issue. – pluton Oct 7 '19 at 15:19
  • usepackage algorithmicx greatly improved algorithmic – M.Ahmadi Oct 7 '19 at 20:48
2

Changing the

\usepackage{algorithmic} 

to

\usepackage{algorithmicx} 

OR

\usepackage{algpseudocode}

And \STATE to \State does not create an empty space

The Minimal example:

\documentclass{book}
\usepackage{algorithmicx} 
%\usepackage{algpseudocode}
\usepackage{hyperref}

\begin{document}
\setlength\abovedisplayshortskip{0pt}
\setlength\belowdisplayshortskip{0pt}
\setlength\abovedisplayskip{0pt}
\setlength\belowdisplayskip{0pt}
\begin{algorithmic}
\State text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
\State text text text text text text text text text text text text text
\State text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
text text text text text text text text text text text text text
\end{algorithmic}
text text text text text text text text text text text text text
\begin{equation}
\cos\pi=-1
\end{equation}
text text text text text text text text text text text text text
\end{document}

Output: enter image description here

  • Interesting. Then this is a bug to be reported to the algorithmic package maintainer. – pluton Oct 7 '19 at 22:25

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.