[TxMt] Re: Recursive LaTeX macros... (LaTeX question)
Will Robertson
wspr81 at gmail.com
Tue Aug 12 00:00:57 UTC 2008
On 12/08/2008, at 9:17 AM, Evan Berkowitz wrote:
> I want one function to specify some amount of white space.
Couple of problems with your macro :)
Here's a working version:
\documentclass{article}
\usepackage{ifthen}
\begin{document}
\newcommand{\indentLength}{3}
\newcommand{\indentUnit}{em}
\newcommand{\indentFull}{\indentLength\indentUnit}
\newcommand{\indents}[1]{%
\ifthenelse{\numexpr#1\relax>0}{%
\hspace{\indentFull}%
\indents{#1-1}}{}%
}
hello \indents{3} hello
\end{document}
The ifthen package doesn't provide \greaterthan. Also, you need that
\numexpr in order to evaluate the #1-1 expression before it's used in
the conditional. Recursion with the ifthen package is a bit awkward :)
Also note that there's a \whiledo command in ifthen, as well.
Anyway, there's an easier way to do what you're after:
\newlength\IND
\setlength\IND{3em}
hello \hspace*{3\IND} hello
I.e., you could use something like \newcommand\indents[1]
{\hspace*{#1\IND}}.
Hope this helps,
Will
-------------- next part --------------
A non-text attachment was scrubbed...
Name: smime.p7s
Type: application/pkcs7-signature
Size: 2415 bytes
Desc: not available
URL: <http://lists.macromates.com/textmate/attachments/20080812/02474774/attachment.p7s>
More information about the textmate
mailing list