[OS X TeX] Re: Inserting text based on length of its input?

Charilaos Skiadas cskiadas at gmail.com
Wed May 7 03:11:37 CEST 2008


Answering my own question, with the help of: http:// 
isilanes.blogspot.com/2007/08/latex-programming-how-to-implement.html

The following seems to work:

\newcommand{\addzero}[1]{\ifnum#1<10 0\fi}
\newcommand{\fig}[2]{\href{http://lmdvr.r-forge.r-project.org/figures/ 
figures.html?chapter=\addzero{#1}#1;figure=\addzero{#1}#1_\addzero{#2} 
#2;theme=stdColor;code=right}{Figure~#1.#2}}

\fig{2}{3}
\fig{2}{10}

Don't know if there are any gotchas however. Are things like \ifnum  
documented somewhere nice?

Haris Skiadas
Department of Mathematics and Computer Science
Hanover College

On May 6, 2008, at 8:51 PM, Charilaos Skiadas wrote:

> Sorry, couldn't come up with a better title. It's also not mac  
> specific. The situation is the following: I want to create links in  
> my text to the pages in a website that have corresponding figures.  
> So for instance I want a command that on \fig{2}[3} will produce  
> the text "Figure 2.3", and have it be a hyperlink to the following  
> address:
>
> http://lmdvr.r-forge.r-project.org/figures/figures.html? 
> chapter=02;figure=02_03;theme=stdColor;code=right
>
> So I was planning to use \href for the linking, but the problem is:  
> how to add that extra 0, when the chapter number or section number  
> are single digits. I am guessing some kind of \newif could do the  
> trick, but my if-knowledge is, shall we say, very iffy. Any help  
> much appreciated. I guess to generalize the question: How do we  
> create conditionals that actually check something in the text,  
> rather than them relaying on us directly setting them true or false  
> as flags.
>
> Haris Skiadas
> Department of Mathematics and Computer Science
> Hanover College







Haris Skiadas
Department of Mathematics and Computer Science
Hanover College







More information about the macostex-archives mailing list