Closed note286 closed 1 year ago
After testing, I found that the \lineskip
value set outside does not take effect within the minipage
.
Your testing is correct: The reason it does not work with algpseudocodex is that it places everything in a varwidth environment, which resets certain values. You can place the following at the beginning of the algorithmic environment:
\makeatletter\pretocmd{\algpx@endCodeCommand}{\addtolength{\lineskip}{10pt}}{}{}\makeatother
This changes the lineskip for every command.
If noEnd=true
, the position of the end will be added twice. If noEnd=false
, It seems like there's no problem.
\documentclass[twocolumn]{article}
\usepackage[noEnd=true]{algpseudocodex}
\makeatletter
\pretocmd{\algpx@endCodeCommand}{\addtolength{\lineskip}{10pt}}{}{}
\makeatother
\newcommand{\xxx}{Lorem ipsum dolor sit amet $\sum\limits_i^1$}
\begin{document}
\begin{algorithmic}[1]
\Require \xxx
\Ensure \xxx
\For{\xxx}
\For{\xxx}
\State \xxx
\EndFor
\State \xxx
\EndFor
\State \xxx
\State \xxx
\State \xxx
\end{algorithmic}
\newpage
\begin{algorithmic}[1]
\Require \xxx
\Ensure \xxx
\State \xxx
\State \xxx
\State \xxx
\State \xxx
\State \xxx
\State \xxx
\State \xxx
\end{algorithmic}
\newpage
\begin{algorithmic}[1]
\Require \xxx
\Ensure \xxx
\For{\xxx}
\State \xxx
\State \xxx
\State \xxx
\EndFor
\State \xxx
\State \xxx
\State \xxx
\end{algorithmic}
\end{document}
noEnd=false
The following configuration results are good, I'm not sure if there are any omissions in principle? As the author, you are more familiar with the implementation details.
\usepackage[noEnd=true]{algpseudocodex}
\AtBeginEnvironment{algorithmic}{
\apptocmd{\State}{\addtolength{\lineskip}{10pt}}{}{}
\addtolength{\lineskip}{10pt}
}
If you just modify \State
, it will not affect text inside, for, if, etc., that is spanning multiple lines.
I've pushed a quick update to the package such that the lineskip value is automatically restored. You can try the newest version from GitHub, it should behave the same as algpseudocode
. It should be available via CTAN as version 1.1.1 soon.
Thank you very much. Considering the actual use, we still need to restore the value of \lineskiplimit
. I have submitted the PR.
Great, thank you!
I need to modify the
lineskip
value in a certainalgorithmic
environment so that it applies uniformly throughout the environment. It works in thealgpseudocode
package, but not in thealgpseudocodex
package. In thealgpseudocodex
package, I have to manually set it after each\State
, which is very inconvenient. I have roughly read the source code, but I haven't found the reason. It seems like\State
is resetting some values.But if with
algpseudocodex
.With
algpseudocodex
, must add after to\State
.