我不确定下面的错误是否已被报告,因为我无法在网上找到明确的信息。请参阅 MWE:如果没有注释,则方程式下方的空间相当大,比注释包时的空间大得多。看起来这是与包命令\usepackage{hyperref}
之间的不良交互:hyperref
STATE
algorithmic
\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}
答案1
改变
\usepackage{algorithmic}
到
\usepackage{algorithmicx}
或者
\usepackage{algpseudocode}
并且\STATE
不会\State
产生空白空间
最小示例:
\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}