Created
June 12, 2021 22:05
-
-
Save nonchris/c49d9b998eb6fd80dd2d6cd57d03b577 to your computer and use it in GitHub Desktop.
A basic loop written in tex
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
% NOTE: I do not guarantee that this is the best way of doing it | |
% but I wanna share it anyways since I can't really find any (commented) example code like this. | |
% --- | |
% command to print numbers one per line | |
% paste somewhere into your document (can be preamble or document itself) | |
% init counter variable | |
\newcount\i | |
% define macro with one input (integer) | |
\def\basicLoop#1{ | |
% init loop with breaking condition - kind of a whiel loop | |
% check if counter is less than input | |
\loop \ifnum \i < #1 | |
% print counter | |
\number\i | |
% increment i by one | |
\advance\i by 1 | |
% go to the beginning | |
\repeat | |
% print word done | |
done | |
} | |
% call function | |
\basicLoop{4} |
If you'll need to to the whole code as a one-liner to print the numbers in one line.
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
If you'd like to lean more about tex programming, have a look at the answer of this question.
https://tex.stackexchange.com/questions/12668/where-do-i-start-latex-programming