[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




-------------- next part --------------
 
-------------------------- Helpful Info --------------------------
TeX FAQ: http://www.tex.ac.uk/faq
List Reminders and Etiquette: http://www.esm.psu.edu/mac-tex/list/
List Info: http://email.esm.psu.edu/mailman/listinfo/macosx-tex
List Archive: http://tug.org/pipermail/macostex-archives/
Mac-TeX Website: http://www.esm.psu.edu/mac-tex/



More information about the macostex-archives mailing list