![算法和 hyperref 包:奇怪的交互](https://linux22.com/image/402697/%E7%AE%97%E6%B3%95%E5%92%8C%20hyperref%20%E5%8C%85%EF%BC%9A%E5%A5%87%E6%80%AA%E7%9A%84%E4%BA%A4%E4%BA%92.png)
我不确定下面的错误是否已被报告,因为我无法在网上找到明确的信息。请参阅 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}