Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix infinite loop in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex #485

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

hansonchar
Copy link

@hansonchar hansonchar commented Jul 11, 2024

Fixes a bug in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex.

How to locally build TeX-programming-notes.pdf from source

Pre-requisite

wget https://mirrors.ctan.org/macros/latex/contrib/acrotex.zip
unzip arotex.zip
DEST=$(kpsewhich -var-value TEXMFHOME)/tex/latex
mkdir -p $DEST
mv acrotex $DEST/
cd $DEST/acrotex

# Entering Ctrl-D whenever stuck
for i in $(ls *.ins); do
    lualatex $i
done

Build the pdf

git clone [email protected]:hansonchar/pgfplots.git
cd pgfplots/doc/latex/pgfplots
git checkout -b Section2.6.2-infiniteloop origin/Section2.6.2-infiniteloop
# Enter 'X' when error out for the first time
make notes

# Second time should generate the pdf without a TOC
make notes

# Third time to generate the final TeX-programming-notes.pdf
make notes

@hansonchar hansonchar force-pushed the Section2.6.2-infiniteloop branch from dffaa98 to e2b52c5 Compare July 11, 2024 06:08
provided under Section 2.6.2 of TeX-programming-notes.tex
@hansonchar hansonchar force-pushed the Section2.6.2-infiniteloop branch from e2b52c5 to 2531e37 Compare July 11, 2024 06:12
@hansonchar hansonchar changed the title Fix infinite loop in example under Section 2.6.2 Loops over list of items Fix infinite loop in the example on Loops over list of items provided under Section 2.6.2 of TeX-programming-notes.tex Jul 11, 2024
@plante3
Copy link

plante3 commented Jul 11, 2024

This fix fails if the item iterated over starts with two identical tokens. Example: \listingloop\x in{aa}{...}.
It seems to me the "proper" fix is to remove the \par in the definition of \listingloopENDMARKER, ie.

\def\listingloopENDMARKER{\listingloopENDMARKER}

@hansonchar
Copy link
Author

This fix fails if the item iterated over starts with two identical tokens. Example: \listingloop\x in{aa}{...}. It seems to me the "proper" fix is to remove the \par in the definition of \listingloopENDMARKER, ie.

\def\listingloopENDMARKER{\listingloopENDMARKER}

Thanks! Will make the changes as you suggested.

@@ -933,10 +933,10 @@ \subsubsection{Loops over list of items}
#2%
\def\next{\looppicker{#1}{#2}}%
\fi
\next
\next%
Copy link
Author

@hansonchar hansonchar Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please note I needed to append % here so make notes won't get into an infinite loop. Basically a hack to get around what seems to be a flaw of the existing build system.

}%
\listingloop\x in{a,b,c,,d,e}{%
The current item is `\x'
\listingloop\x in{aa, b,c ,,d,e}{%
Copy link
Author

@hansonchar hansonchar Jul 11, 2024

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I modified the test cases to have a wider range of coverage of what otherwise could have gone wrong without being noticed.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants