chrmatt / algpseudocodex

LaTeX package for typesetting pseudocode.
38 stars 2 forks source link

Line spacing is broken #2

Closed havrikov closed 3 years ago

havrikov commented 3 years ago

Since the latest update to the TexLive and MikTeX distributions (as of 2021-06-06) the spacing between the lines in algpseudocodex is off, and as a result, the indent lines are also misplaced.
Consider the following snippet:

\documentclass[10pt,a4paper]{book}

\usepackage{algorithm}
\usepackage{algpseudocodex}

\begin{document}

\begin{algorithm}
  \caption{Example Algorithm}
  \label{alg:example}
  \begin{algorithmic}[1]
    \Function{foo}{x,y}
    \While{\(x \ne y\)}
    \State \(x\gets x+1\) \Comment{Hello there}
    \EndWhile
    \State \Return \(x\)
    \EndFunction
  \end{algorithmic}
\end{algorithm}

\end{document}

Since the update, it renders as follows:

Screenshot 2021-06-07 124125

chrmatt commented 3 years ago

This is caused by a new behavior in the varwidth package that algpseudocodex is using internally, see https://tex.stackexchange.com/q/600349/123920.

chrmatt commented 3 years ago

This answer on StackExchange describes a workaround that fixes the problem: https://tex.stackexchange.com/a/600420/123920 I hope that varwidth will get fixed soon and I don't plan to implement a workaround in algpseudocodex for now.

havrikov commented 3 years ago

Understood.
Thank you for clarifying.

FWIW, this is what it looks like with the workaround applied: Screenshot 2021-06-08 173558

As you can see, the comment is still slightly offset with regards to its line.
Nevertheless, feel free to close this issue.

chrmatt commented 3 years ago

Thanks for pointing out the offset comments! The problem seems to disappear if you use rightComments=false. I'll leave this open and hope it will be fixed soon with a proper fix of varwidth.

If you need a properly formatted document now and you don't use \BeginBox and \EndBox, you can download a copy of algpseudocodex.sty and replace varwidth with minipage everywhere in there. This fixes it for me (but makes all boxes maximal width).

chrmatt commented 3 years ago

Issue appears to be fixed in newest version of TeX Live (including the offset comments).