I'm trying to define a new command \multiboxed in LaTeX so that I can put n boxes around an equation without having to manually nest \boxed commands. So far I have (using the pgffor package):
def\multiboxed#1#2{
\foreach \index in {1, ..., #1} {
Hello
}
#1
\foreach \index in {1, ..., #1} {
World
}
}
which successfully wraps the second argument with Hello and World a number of times equal to the first argument. However, changing this to
def\multiboxed#1#2{
\foreach \index in {1, ..., #1} {
\fbox{
}
#1
\foreach \index in {1, ..., #1} {
}
}
}
really doesn't work, as expected. As such, I have two questions which I only really need an answer to one of:
- How do I successfully modify the for loops to achieve the desired behaviour?
- Alternatively, how do I define a recursive command to achieve the same output?
Obviously an answer to (2) would be better as this is a better way of solving the problem, but I have a feeling I'd better understand an answer to (1). Ideally I'd also not have to rely on the pgffor package. Thanks for any light you can shed on this matter.



