![revtex4-2 文档类未对齐 algpseudocodex 右边距](https://linux22.com/image/465403/revtex4-2%20%E6%96%87%E6%A1%A3%E7%B1%BB%E6%9C%AA%E5%AF%B9%E9%BD%90%20algpseudocodex%20%E5%8F%B3%E8%BE%B9%E8%B7%9D.png)
当使用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 输出的屏幕截图。
如果我更改以下之一,问题就会消失:
revtex4-2
到article
twocolumn
到onecolumn
algpseudocodex
至algpseudocode
(并删除\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}