#!/bin/sh # Bengt Martensson # Generates a nice LaTeX file of the abbreviations in the bibtex-styles in # the arguments. # Bugs: # REQUIRES that the definition is written in ONE line # Does not check for consistency of the abbreviated versions and the # full versions short_file=/tmp/short$$ full_file=/tmp/full$$ outfile=printabbrevs.tex usage='usage: printabbrevs [-output|-preview|-cpp|-latex] bibtexstyle-file...' cpp=false latex=false preview=false dvipreviewcommand="xdvi" while : do case "$1" in -cpp) cpp=true; shift;; -debug) set -x; shift;; -preview) preview=true; shift;; -l|-latex) latex=true; shift;; -o|-output) outfile="$2"; shift 2;; -*|+*) echo "$usage" >&2; exit 1;; *) break;; esac done if [ $# -lt 1 ] then echo $usage >&2 exit 1 fi dvifile=`echo $outfile | sed -e 's/\.tex$/.dvi/'` echo "Outputting to $outfile" >&2 warning=false if $cpp then cat $* | /lib/cpp -P > $short_file cat $* | /lib/cpp -P -DMONTH_FULL -DJOUR_FULL > $full_file else cat $* > $full_file cp /dev/null $short_file if grep "#include" $full_file >/dev/null then warning=true echo "Warning: Ignoring #include in the file(s). (Use the -cpp flag to invoke cpp.)" >&2 fi fi echo "\\documentstyle[a4wide]{article} \\frenchspacing \\begin{document} \\title{Abbreviations in file(s): $*" > $outfile if $warning then echo "\\\\(cpp not invoked)" >> $outfile fi echo "} \\author{Generated by printabbrevs on `date '+%a %d-%h-%y %H:%M'`} \\date{} \\maketitle \\begin{list}{}{\\settowidth\\labelwidth{1234567} \itemsep=2pt plus 1pt \def\makelabel#1{\tt #1\hfil}}" >> $outfile awk ' /MACRO/ { key = substr($2,2,length($2)-2) it = substr($0,index($0,"\"")+1) it = substr(it,1,index(it,"\"")-1) if (full == 1) { full_array[key] = it } else { short_array[key] = it } } END { for (i in full_array) { printf "\\item[%s] %s {\\em %s}\n",i,full_array[i],short_array[i] } }' full=1 $full_file full=0 $short_file |sort +1 >> $outfile echo "\\end{list} \\end{document}" >> $outfile rm -f $full_file $short_file if $latex then latex $outfile fi if [ $? -ne 0 ] then exit 1 fi if $preview then $dvipreviewcommand $dvifile & fi