Skip to content

Instantly share code, notes, and snippets.

@Kirens
Created December 2, 2018 16:18
Show Gist options
  • Save Kirens/4980b5f5e7d5e636b305874691049186 to your computer and use it in GitHub Desktop.
Save Kirens/4980b5f5e7d5e636b305874691049186 to your computer and use it in GitHub Desktop.
Things that cause trouble in tex
% Forgetting an unexpandable after advance has unpredictable errors
% creeping up when numbers are processed afterwards.
\advance\ThrottleCounter by -1%
\ifnum\the\ThrottleCounter=0%
#1%
\fi
% The above fails misserably if the counter is on 0 and the first
% argument happens to be a number, then it will be expanded to.
\advance\ThrottleCounter by -1#1
% which turns out to be
\advance\ThrottleCounter by -15
% The solution is to use `\relax`
\advance\ThrottleCounter by -1\relax%
% Expandafters of blocks
% Not sure how tihs works, but expandafters cant seem to jump past a
% block. Yet I allways try. Use a temporary declaration instead.
\ea...\ea\macro\ea...\ea{a group of stuff that will never be expanded after}\this
% do this
\def\tmp{...}
\ea\macro\ea\tmp\this
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment