summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/hepnames/mkmacrotables
blob: 3c06ffbec820de9b5d31c2c218ba300f08711249 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
#!/bin/bash

## For each package...
for package in hepnicenames heppennames; do
    echo "Processing package $package"

    ## Make the macro list document fragment
    TMP=macrolist-$$.tmp
    > $TMP
    echo "\begin{multicols}{2}{" >> $TMP
    echo "\begin{itemize}" >> $TMP
    cat ${package}.sty | egrep "^\\\DeclareRobustCommand|^%\\\DeclareRobustCommand" | while read line; do
        item=$( echo $line | sed -e s/'^%'// -e s/"DeclareRobustCommand{\([^}]\+\)}[^%]*"/"\1"/g -e s/'%.*'//g )
        if [[ -z $item ]]; then continue; fi
        description=$( echo $line | sed -e s/'^.*DeclareRobustCommand[^%]*'//g -e s/'%%.*'//g -e s/'^%\ *'//g )
        if [[ -n $description ]]; then description="$description\newline"; fi
        echo "\item ${description} \texcmd{$(echo $item | sed -e s/'\ .*'/''/g)} \$\Rightarrow\$ \\${item}" >> $TMP
    done
    echo "\end{itemize}" >> $TMP
    echo "}\end{multicols}" >> $TMP

    ## Make the LaTeX files
    PKGOUT=${package}-macros.tex
    echo "Making $PKGOUT"
    cat $TMP > $PKGOUT

    for style in it rm; do
        PKGOUT=${package}-${style}.tex
        echo "Making $PKGOUT"
        > $PKGOUT
        if [[ "$style" = "rm" ]]; then pkgopts=""; else pkgopts="[italic]"; fi
        SECTIONCMD="\section"
        echo "\documentclass[12pt]{article}" >> $PKGOUT
        echo "\usepackage${pkgopts}{${package}}" >> $PKGOUT
        echo "\usepackage{a4wide,multicol,setspace,color}" >> $PKGOUT
        echo "\title{Testing \\textsf{${package}}}" >> $PKGOUT
        echo "\author{Generated by \texttt{$USER}}" >> $PKGOUT
        echo "\onehalfspacing" >> $PKGOUT
        echo '\newcommand{\texcmd}[1]{\textcolor{red}{\texttt{\char`\\#1}}}' >> $PKGOUT
        echo "\newcommand{\texenv}[1]{\textcolor{red}{\texttt{#1}}}" >> $PKGOUT
        echo "\newcommand{\texopt}[1]{\textcolor{purple}{\texttt{#1}}}" >> $PKGOUT
        echo "\newcommand{\texopts}[1]{\textcolor{purple}{\texttt{[#1]}}}" >> $PKGOUT
        echo "\newcommand{\texarg}[1]{\textcolor{violet}{\texttt{#1}}}" >> $PKGOUT
        echo "\newcommand{\texargs}[1]{\textcolor{violet}{\texttt{\{#1\}}}}" >> $PKGOUT
        echo "\newcommand{\texpkg}[1]{\texttt{#1}}" >> $PKGOUT
        echo "\newcommand{\texcls}[1]{\texttt{#1}}" >> $PKGOUT
        echo "\newcommand{\gen}[1]{\ensuremath{\braket{#1}}}" >> $PKGOUT
        echo >> $PKGOUT
        echo "\begin{document}" >> $PKGOUT
        echo "\maketitle" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Normal font}" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Bold font}" >> $PKGOUT
        echo "\textbf{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}" >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Italic font}" >> $PKGOUT
        echo "\textit{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}" >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Bold italic font}" >> $PKGOUT
        echo "\textbf{\textit{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}}" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Sans font}" >> $PKGOUT
        echo "\textsf{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}" >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Bold sans font}" >> $PKGOUT
        echo "\textsf{\textbf{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}}" >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Italic sans font}" >> $PKGOUT
        echo "\textsf{\textit{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}}" >> $PKGOUT
        echo "\clearpage" >> $PKGOUT
        echo >> $PKGOUT
        echo "$SECTIONCMD{Bold italic sans font}" >> $PKGOUT
        echo "\textsf{\textbf{\textit{" >> $PKGOUT
        cat $TMP >> $PKGOUT
        echo "}}}" >> $PKGOUT
        echo >> $PKGOUT
        echo "\end{document}" >> $PKGOUT
    done
    rm -f $TMP

done