summaryrefslogtreecommitdiff
path: root/2005/flow-accounting-ols2005/OLS2005/Texmf/make-toc
blob: 3998ea148fa389cd3d9401388d1c5ac3e067050a (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
#! /bin/sh

# Generate a table of contents for the proceedings, listing all of the
# papers with their short authors.  Each entry in the table of contents
# is a line like this:
#
# \item \textbf{Name of paper\hspace{\fill}pageno}\\
#       \textit{A.N. Author}
#
# The data comes from two lines in each .aux file, which look like this:
#
# \@writefile{toc}{\contentsline {toctitle}{Name of Paper}{pageno}}
# \@writefile{toc}{\contentsline {tocauthor}{A.N. Author}{pageno}}


if [ $# -lt 2 ]; then
    echo "usage: $0 output inputs..." >&2
    exit 2
fi

output="$1"
shift

for auxfile in "$@"; do
    titleline=$(sed -ne 's|\\@writefile{toc}{\\contentsline {toctitle}{||p' \
	        "$auxfile" | sed -e 's/}}$//')
    author=$(sed -ne 's|\\@writefile{toc}{\\contentsline {tocauthor}{||p' \
	     "$auxfile" | sed -e 's/}{[0-9][0-9]*}}$//')

    title=$(printf '%s\n' "$titleline" | sed -e 's/}{.*$//')
    pageno=$(printf '%s\n' "$titleline" | sed -e 's/.*}{//')

    printf '\\item \\textbf{%s\\hspace{\\fill}%s}\\\\\n' "$title" "$pageno"
    printf '      \\textit{%s}\n' "$author"

done > "$output"T

./Texmf/move-if-change "$output"T "$output"
personal git repositories of Harald Welte. Your mileage may vary