chrmatt / algpseudocodex

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

Unexpected end of Indent line for if elsif else blocks #9

Closed vepain closed 2 years ago

vepain commented 2 years ago

Issue

When the if/elsif/else blocks contain another block, then the indent line finishes before the end of the if chain.

What is expected

The indent line of a if-elsif-chain should not finish after the end of the \EndIf

MWE

\documentclass[a4paper,10pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{algpseudocodex}
\usepackage{algorithm}

\begin{document}

\begin{algorithm}[H]
    \begin{algorithmic}[1]
        \If{test}
            \Comment{indent line end before else: wrong.}
            \For{\(a \in A\)}
                \State{for body}
            \EndFor{}
        \ElsIf{elseif}\Comment{indent line end after else: correct.}
            \State{state in elsif}
        \Else{}
            \State{state in else}
        \EndIf{}
        \If{test}\Comment{indent line end after elsif: correct.}
            \State{state in if}
        \ElsIf{elseif}
            \Comment{indent line end before else: wrong.}
            \For{\(a \in A\)}
                \State{for body}
            \EndFor{}
        \Else{}
            \State{state in else}
        \EndIf{}
        \LComment{all correct.}
        \If{test}
            \State{state in if}
        \ElsIf{elseif}
            \State{state in elsif}
        \Else{}
            \State{state in else}
        \EndIf{}
    \end{algorithmic}
\end{algorithm}

\end{document}

main.pdf

Configuration

 *File List*
 article.cls    2021/10/04 v1.4n Standard LaTeX document class
  size10.clo    2021/10/04 v1.4n Standard LaTeX file (size option)
algpseudocodex.sty    2021-12-05 v1.0.1 pseudocode typesetting
kvoptions.sty    2022-06-15 v3.15 Key value format for package options (HO)
  keyval.sty    2022/05/29 v1.15 key=value parser (DPC)
 ltxcmds.sty    2020-05-10 v1.25 LaTeX kernel commands for general use (HO)
kvsetkeys.sty    2019/12/15 v1.18 Key value parser (HO)
algorithmicx.sty    2005/04/27 v1.2 Algorithmicx
  ifthen.sty    2022/04/13 v1.1d Standard LaTeX ifthen package (DPC)
etoolbox.sty    2020/10/05 v2.5k e-TeX tools for LaTeX (JAW)
fifo-stack.sty    2014/03/24 v1.0 Multi-FIFO/stack system
varwidth.sty    2009/03/30 ver 0.92;  Variable-width minipages
   tabto.sty    2018/12/28  v 1.4  Another tabbing mechanism
    tikz.sty    2021/05/15 v3.1.9a (3.1.9a)
     pgf.sty    2021/05/15 v3.1.9a (3.1.9a)
  pgfrcs.sty    2021/05/15 v3.1.9a (3.1.9a)
pgfrcs.code.tex
 pgfcore.sty    2021/05/15 v3.1.9a (3.1.9a)
graphicx.sty    2021/09/16 v1.2d Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty    2022/03/10 v1.4e Standard LaTeX Graphics (DPC,SPQR)
    trig.sty    2021/08/11 v1.11 sin cos tan (DPC)
graphics.cfg    2016/06/04 v1.11 sample graphics configuration
  luatex.def    2021/06/01 v1.2c Graphics/color driver for luatex
  pgfsys.sty    2021/05/15 v3.1.9a (3.1.9a)
pgfsys.code.tex
pgfsyssoftpath.code.tex    2021/05/15 v3.1.9a (3.1.9a)
pgfsysprotocol.code.tex    2021/05/15 v3.1.9a (3.1.9a)
  xcolor.sty    2022/06/12 v2.14 LaTeX color extensions (UK)
   color.cfg    2016/01/02 v1.6 sample color configuration
mathcolor.ltx
pgfcore.code.tex
pgfcomp-version-0-65.sty    2021/05/15 v3.1.9a (3.1.9a)
pgfcomp-version-1-18.sty    2021/05/15 v3.1.9a (3.1.9a)
  pgffor.sty    2021/05/15 v3.1.9a (3.1.9a)
 pgfkeys.sty    
pgfkeys.code.tex
 pgfmath.sty    
pgfmath.code.tex
pgffor.code.tex
tikz.code.tex
   expl3.sty    2022-08-30 L3 programming layer (loader) 
l3backend-luatex.def    2022-08-30 L3 backend support: PDF output (LuaTeX)
l3keys2e.sty    2022-06-22 LaTeX2e option processing using LaTeX3 keys
  xparse.sty    2022-06-22 L3 Experimental document command parser
algorithm.sty    2009/08/24 v0.1 Document Style `algorithm' - floating environment
   float.sty    2001/11/08 v1.3d Float enhancements (AL)
  ts1cmr.fd    2019/12/16 v2.5j Standard LaTeX font definitions
supp-pdf.mkii
epstopdf-base.sty    2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg    2010/07/13 v1.3 Configuration of (r)epstopdf for TeX Live
 ***********
chrmatt commented 2 years ago

Thank you for the detailed explanation and MWE! The issue should be fixed in the next release (v1.0.2).

vepain commented 2 years ago

Thank you for your great work!