how to extract LaTeX macro arguments?

From: ivo welch (ivo.welch_at_anderson.ucla.edu)
Date: 12/23/03

  • Next message: Gunnar Hjalmarsson: "Re: how to extract LaTeX macro arguments?"
    Date: 22 Dec 2003 16:58:05 -0800
    
    

    I know regex can't do this, so may I ask what the recommended
    procedure is for extracting a bracketed TeX argument, which itself can
    contain other bracketed TeX arguments?

    $string = " text \sometexmacro{arg1}{this is a second {\bf arg}
    argument} more text";

    and file.pm has a sub that makes it easy to describe all the arguments
    to sometexmacro

    \sometexmacro
       arg1: 'arg1'
       arg2: 'this is a second {\bf arg} argument'

    if it were even smarter, it could also handle TeX comments and
    escapes, such as

    file.tex: \sometexmacro{arg1}{this is a second %}
     {\bf arg} argument, which handles \} correctly }

    Life would be heaven if regex's could do this, because I could then
    automatically replace the second argument with what I want it to be.
    Alas, they cannot. will they be able to do this in perl6?


  • Next message: Gunnar Hjalmarsson: "Re: how to extract LaTeX macro arguments?"