Andre Poenitz wrote:

> On Tue, Feb 11, 2003 at 09:47:13PM +0100, Georg Baum wrote:
>> Am Dienstag, 11. Februar 2003 12:00 schrieb Angus Leeming:
>> > I have a trivial patch to the reLyX minibuffer output:
>> >
>> >         * reLyX/BasicLyX.pm: Wrap minipage width and height output in
>> >         inverted commas to keep the LyX parser happy with "4.5 cm".
>> >         (Note the space.)
>> 
>> While you are at it: "4,5cm" (with comma) is also valid latex (learned
>> that the other day when I fed some more old tex files to reLyX.
> 
> And I believe '4.5 Cm' and '4.5 cM' are valid as well...

Geeez. Would this suffice do you think?
Angus

$ ./trial ' - 3.5 cM' ' + 4,5 Cm ' ' + 4.5 \columnWidth '
' - 3.5 cM' becomes '-3.5cm'
' + 4,5 Cm ' becomes '+4.5cm'
' + 4.5 \columnWidth ' becomes '+4.5\columnWidth'

where 'trial' is:
#! /usr/bin/perl

sub regularizeLatexLength {
        my $LatexLength = shift;

        # '4,5cm', '4.5 Cm' and '4.5 cM' are all valid LaTeX.
        # Turn them into a common, standard form.
        # First, deal with '- 5,5 ' as '-5.5'
        $LatexLength =~ s/^\s*([+-]?)\s*(\d+)[.,]?(\d*)\s*/$1$2.$3/;
        # Now ensure that 'Cm', 'cM' are output as 'cm'.
        # This does not act on \macro
        $LatexLength =~ s/(\d+\.?\d*)([a-z]*)/$1\L$2/i;
        # Strip off any trailing whitespace
        $LatexLength =~ s/\s*$//;

        return $LatexLength;
}

foreach (@ARGV) {#while (<>) {
        chomp;
        print "'$_' becomes '", regularizeLatexLength($_), "'\n";
}


Reply via email to