diff options
author | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
---|---|---|
committer | Norbert Preining <norbert@preining.info> | 2019-09-02 13:46:59 +0900 |
commit | e0c6872cf40896c7be36b11dcc744620f10adf1d (patch) | |
tree | 60335e10d2f4354b0674ec22d7b53f0f8abee672 /macros/latex/contrib/aomart/fullref.pl |
Initial commit
Diffstat (limited to 'macros/latex/contrib/aomart/fullref.pl')
-rw-r--r-- | macros/latex/contrib/aomart/fullref.pl | 62 |
1 files changed, 62 insertions, 0 deletions
diff --git a/macros/latex/contrib/aomart/fullref.pl b/macros/latex/contrib/aomart/fullref.pl new file mode 100644 index 0000000000..0414089ea0 --- /dev/null +++ b/macros/latex/contrib/aomart/fullref.pl @@ -0,0 +1,62 @@ +#!/usr/bin/perl +# +# Convert the refences to \fullref. Usage: +# perl fullref.pl original.tex > converted.tex +# +# +# Copyright (C) 2010 Annals of Mathematics. Public domain. +# +# Author: Boris Veytsman +# +# Version: 0.9, 2010/12/04 + +use strict; + +# List of patterns for 'equation' words +my @eqsynonyms = ('\S*equa\S*', 'relat\S*', 'item\S*', + 'condition\S*', + '\S*propert\S*'); + +# First we skip preamble +while(<>) { + print; + last if (/\\begin\{document\}/); +} + +# This is a trick to catch \ref being the first word on the line +my $prevline = ""; + +# Processing document +while (<>) { + if ((/^[\s~]*\(?\\ref/) || (/^[\s~]*\\eqref/)) { + chomp $prevline; + $_ = "$prevline $_"; + } else { + print $prevline; + } + + # Now the meat of the substitutions + # We add initial space, so all words have space before them. + $_ = " $_"; + foreach my $synonym (@eqsynonyms) { + s/(\s)($synonym)[\s~]*\(\\ref\{([^\}]+)\}\)/$1\\pfullref{$2}{$3}/gi; + s/(\s)($synonym)[\s~]*\\eqref\{([^\}]+)\}/$1\\eqfullref{$2}{$3}/gi; + } + s/(\s)([^\s\\]\S*[^~\s\(\)\[\]])[\s~]*\[\\ref\{([^\}]+)\}\]/$1\\bfullref{$2}{$3}/g; + s/(\s)([^\s\\]\S*[^~\s\(\)\[\]])[\s~]*\\ref\{([^\}]+)\}/$1\\fullref{$2}{$3}/g; + + # Now delete the extra space + s/^ //; + $prevline=$_; + if (/\\end\{document\}/) { + print; + last; + } +} + +# And processing whatever is left +while (<>) { + print; +} + +exit 0; |