Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- \documentclass{article}
- \makeatletter
- \newcommand\myrepeat[3]{%
- % #1 is the number of repetitions
- % #2 is the code to repeat
- % #3 is the code to put in the middle
- \expandafter\myrepeat@aux\expandafter{\romannumeral\number\number#1 000}{#2}{#3}%
- }
- \newcommand{\myrepeat@aux}[3]{\myrepeat@auxi{#2}{#3}#1;;}
- \def\myrepeat@auxi#1#2#3#4{%
- \ifx#3;%
- \expandafter\@gobble % recursion has ended
- \else
- \expandafter\@firstofone % still one m to swallow
- \fi
- {\myrepeat@auxii{#1}{#2}{#4}}%
- }
- \def\myrepeat@auxii#1#2#3{%
- #1\ifx#3;\else#2\fi
- \myrepeat@auxi{#1}{#2}#3% restart the recursion
- }
- \makeatletter
- \begin{document}
- \myrepeat{5}{Non devo}{\\}
- \end{document}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement