当使用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}