#!/usr/bin/perl -w use strict; use Getopt::Long; use Pod::Usage; my $output = "-"; my $input = "-"; GetOptions("output=s",\$output); $input = $ARGV[0] if @ARGV; open(FIN,$input) or die "Can't open input file."; open(FOUT,">$output"); my $line; while ($line=){ if ($line !~ m/symdef/ && $line !~ m/elldef/ && $line !~ m/abbrdef/){ print FOUT $line; next; } if ($line =~ m/\}\[\d,/){ print FOUT $line; next; } if ($line =~ m/\\(sym|abbr|ell)def\{\\([^\}]+)\}\[(\d)\]([^\n\%]+)(.*)/){ print FOUT "\\$1def{\\$2}[$3,name=$2]$4$5\n"; } else { if ($line =~ m/\\(sym|ell|abbr)def\{\\([^\}]+)\}([^\n\%]+)(.*)/){ print FOUT "\\$1def{\\$2}[0,name=$2]$3$4\n"; } } } close(FIN); close(FOUT); __END__ =head1 SYNOPSIS symdef [--output=outputfile] [texfile]