That's exactly what I was looking for - thanks alot!cgnieder wrote:Code: Select all
\newcommand*\saybla[1]{% \ifnum#1<0 \ERROR\fi \ifnum#1=1 bla% \else bla \saybla{\numexpr#1-1}% \fi }
Search found 4 matches
- Mon Jul 23, 2012 3:33 pm
- Forum: General
- Topic: Defining and manipulating variables in LaTeX
- Replies: 5
- Views: 11456
Defining and manipulating variables in LaTeX
- Mon Jul 23, 2012 1:28 am
- Forum: General
- Topic: Defining and manipulating variables in LaTeX
- Replies: 5
- Views: 11456
Re: Defining and manipulating variables in LaTeX
Thanks for the quick reply. I think my question was misunderstood - I'm familiar with both the ifthen package and loops. What I can't work out is how to define an integer and modify it (substracting one in this case). I'd be happy if I for instance could do this:
\newcommand{\oneless}[1]{
#1 - 1 ...
\newcommand{\oneless}[1]{
#1 - 1 ...
- Mon Jul 23, 2012 1:12 am
- Forum: General
- Topic: Defining and manipulating variables in LaTeX
- Replies: 5
- Views: 11456
Re: Defining and manipulating variables in LaTeX
Thanks for the quick reply. I'm familiar with both loops and conditional statements - I just wrote my problem in pseudocode for readability - perhabs a bit unclear.
I tried defining a counter to control a for-loop, but LaTeX doesn't support local variables, it seems, so I got an error the second ...
I tried defining a counter to control a for-loop, but LaTeX doesn't support local variables, it seems, so I got an error the second ...
- Mon Jul 23, 2012 12:24 am
- Forum: General
- Topic: Defining and manipulating variables in LaTeX
- Replies: 5
- Views: 11456
Defining and manipulating variables in LaTeX
Hi there
Does anybody know of a way to declare and manipulate variables in LaTeX in a way similar to a 'real' programming language?
Concretely, let's say I want to define a command \saybla{n} that prints 'bla' n times. What I'd like to write in my preamble is (in pseudocode) something like ...
Does anybody know of a way to declare and manipulate variables in LaTeX in a way similar to a 'real' programming language?
Concretely, let's say I want to define a command \saybla{n} that prints 'bla' n times. What I'd like to write in my preamble is (in pseudocode) something like ...