revtex4-2 文档类未对齐 algpseudocodex 右边距

revtex4-2 文档类未对齐 algpseudocodex 右边距

当使用revtex4-2带有twocolumn选项的文档类时,包algorithmic的环境algpseudocodex的右边距延伸得太远。我该如何解决这个问题,让右边距与正文的右边距对齐?下面的 MWE。

\documentclass[twocolumn,nobalancelastpage]{revtex4-2}
\usepackage{algpseudocodex}

\begin{document}
See the following lines of code.
The right margin seems to go further than that of body text.
See the following lines of code.
The right margin seems to go further than that of body text.

\begin{algorithmic}
    \State A long first statement to demonstrate where statements linewrap.
    \State A short second statement.
    \Comment{Short comment.}
    \LComment{Long comment.}
\end{algorithmic}

\end{document}

nobalancelastpage选项的存在只是为了让我能够比较正文和algorithmic环境的边距。下面是 MWE 输出的屏幕截图。

MWE 的输出。

如果我更改以下之一,问题就会消失:

  • revtex4-2article
  • twocolumnonecolumn
  • algpseudocodexalgpseudocode(并删除\LComment{Long comment.}

答案1

快速而肮脏的破解:在算法周围使用一个小页面来缩短代码行:

\documentclass[twocolumn,nobalancelastpage]{revtex4-2}
\usepackage{algpseudocodex}

\begin{document}
See the following lines of code.
The right margin seems to go further than that of body text.
See the following lines of code.
The right margin seems to go further than that of body text.

\noindent\begin{minipage}{\dimexpr\linewidth-\parindent}
\begin{algorithmic}
    \State A long first statement to demonstrate where statements linewrap.
    \State A short second statement.
    \Comment{Short comment.}
    \LComment{Long comment.}
\end{algorithmic}
\end{minipage}

\end{document}

在此处输入图片描述

相关内容