
Ich verwende es, algpseudocodex
um meine Algorithmen zu setzen, und ich hätte gerne zu jeder Zeile einen Kommentar.
Minimales Beispiel:
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocodex}
\begin{document}
\begin{algorithm}[h]
\begin{algorithmic}[1]
\Repeat \Comment{Comment1}
\State $x$ \Comment{Comment2}
\Until{$y$} \Comment{Comment3}
\State $z + x + y3$ \Comment{Comment4}
\end{algorithmic}
\end{algorithm}
\end{document}
Beim Kompilieren wird Comment3 jedoch fälschlicherweise nach rechts verschoben. Dies scheint nicht von der Textmenge in der Until
Klausel oder von der Comment
Klausel selbst abzuhängen:
Wie kann ich das beheben und alle Kommentare richtig rechtsbündig ausrichten? Ich erhalte Overfull \hbox (15.00002pt too wide)
in der betreffenden Zeile eine Fehlermeldung.
Antwort1
Auf das Problem wird hingewiesen indieses Problem auf algpseudocodes Github, ab 5. Dez. 2021.
Ich gehe davon aus, dass Sie eine Plattform verwenden, auf der nicht die neueste Version des Pakets (v1.0.1) installiert ist.
Verwenden Sie Overleaf?Overleaf ist im Oktober 2021 auf TeX Live 2021 umgestiegenfür seine Pakete, daher vermute ich, dass sie nicht aktualisiert wurden, um die Änderungen aus dem neuesten Patch von TexLive 2021 (der meines Wissens diesen Patch enthält) einzuschließen.
Antwort2
Ich kann das Problem mit TeX Live 2020 reproduzieren, auf dem algpseudocodex
Version 1.0 vom 16.08.2020 läuft.
Mit TeX Live 2021 ist die Version algpseudocodex
1.0.1, veröffentlicht am 05.12.2021 (das ist die aktuelle Version), das Problem verschwindet.
Antwort3
Mit derselben Datei wie Sie habe ich das richtige Ergebnis und keine Warnungen erhalten.
Ich habe den Befehl \listfiles
am Anfang hinzugefügt. Sehen Sie sich das Ende der .log-Datei an, um alle geladenen Dateien und ihre Versionen anzuzeigen.
Meine eigene Liste finden Sie unten.
% !TeX TS-program = pdflatex
\listfiles
\documentclass{article}
\usepackage{algorithm}
\usepackage{algpseudocodex}
\begin{document}
\begin{algorithm}[h]
\begin{algorithmic}[1]
\Repeat \Comment{Comment1}
\State $x$ \Comment{Comment2}
\Until{$y$} \Comment{Comment3}
\State $z + x + y3$ \Comment{Comment4}
\end{algorithmic}
\end{algorithm}
\end{document}
.
*File List*
article.cls 2020/04/10 v1.4m Standard LaTeX document class
size10.clo 2020/04/10 v1.4m Standard LaTeX file (size option)
algorithm.sty 2009/08/24 v0.1 Document Style `algorithm' - floating environment
float.sty 2001/11/08 v1.3d Float enhancements (AL)
ifthen.sty 2014/09/29 v1.1c Standard LaTeX ifthen package (DPC)
algpseudocodex.sty 2021-12-05 v1.0.1 pseudocode typesetting
kvoptions.sty 2020-10-07 v3.14 Key value format for package options (HO)
keyval.sty 2014/10/28 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
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 2020/09/09 v1.2b Enhanced LaTeX Graphics (DPC,SPQR)
graphics.sty 2020/08/30 v1.4c Standard LaTeX Graphics (DPC,SPQR)
trig.sty 2016/01/03 v1.10 sin cos tan (DPC)
graphics.cfg 2016/06/04 v1.11 sample graphics configuration
pdftex.def 2020/10/05 v1.2a Graphics/color driver for pdftex
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 2016/05/11 v2.12 LaTeX color extensions (UK)
color.cfg 2016/01/02 v1.6 sample color configuration
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 2021-02-18 L3 programming layer (loader)
l3backend-pdftex.def 2021-03-18 L3 backend support: PDF output (pdfTeX)
l3keys2e.sty 2021-03-12 LaTeX2e option processing using LaTeX3 keys
xparse.sty 2021-01-09 L3 Experimental document command parser
xparse-2020-10-01.sty
supp-pdf.mkii
epstopdf-base.sty 2020-01-24 v2.11 Base part for package epstopdf
epstopdf-sys.cfg 2021/03/18 v2.0 Configuration of epstopdf for MiKTeX
***********