[p4] Keyword expansion in LaTeX documents

Jan Mikkelsen janm-perforce-user at transactionware.com
Sun Oct 30 18:18:49 PST 2005


Ken.Williams at thomson.com wrote:
> I'm trying to figure out a good way to use keyword expansion in a LaTeX 
> document.  Ideally, I'd have something like this in the header:
>  
>    \title{My Document}
>    \author{Ken Williams}
>    \date{$Revision: #2 $}
>  
> The problem is that both '$' and '#' are special characters in LaTeX - 
> the surrounding '$' characters will switch into math mode (which isn't a 
> huge deal, but looks kind of ugly), and the '#2' indicates parameter 
> number 2, which is meaningless in this context and causes parsing to fail.
>  
> Does anyone have any experience with this?  I'd be fine with a solution 
> either on the LaTeX side (some kind of escaping of the whole "$Revision: 
> #2 $" string) or on the Perforce side (some way of getting the revision 
> number without the special characters around it), but at this point I've 
> been able to think of neither.

In ConTeXt, I use \type or \starttyping.  The LaTeX equivalent is 
verbatim mode.  The primary drawback is that you can't use it as an 
argument to another command.

To get around the argument issue, I use a buffer in ConTeXt.  (I don't 
know the LaTeX equivalent):

\startbuffer
\type{$Revision: #2 $}
\stopbuffer

\subject{\getbuffer}

I hope this helps.

Regards,

Jan Mikkelsen
janm at transactionware.com



More information about the perforce-user mailing list