This repository has been archived by the owner on Jul 19, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
package_for_aas.sh
executable file
·106 lines (94 loc) · 2.66 KB
/
package_for_aas.sh
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
101
102
103
104
105
106
#!/bin/bash
# Package up paper files for submission to ApJ, arXiv, etc. This
# compiles all the TeX source files into a single file, removes the
# dependency on PythonTeX, generates all of the figures, and fixes
# the figure paths.
#
# Usage:
# ./package_for_aas.sh /path/to/top/level/dir
# ./package_for_aas.sh /path/to/top/level/dir --cover-letter
# ./package_for_aas.sh /path/to/top/level/dir --arxiv
# Check for cover letter option
if [[ $* == *--cover-letter* ]]
then
COVER_LETTER=true
else
COVER_LETTER=false
fi
# Check for arXiv option
if [[ $* == *--arxiv* ]]
then
ARXIV=true
else
ARXIV=false
fi
# Create target directory
if $ARXIV
then
DIR_NAME="arxiv-submission"
else
DIR_NAME="aas-submission"
fi
DEST_DIR="$1/$DIR_NAME"
mkdir -p $DEST_DIR
# Copy over all paper files
cp -r paper/sections $DEST_DIR
cp -r paper/data $DEST_DIR
cp -r paper/python $DEST_DIR
cp paper/aasjournal.bst $DEST_DIR
cp paper/aastex62.cls $DEST_DIR
cp paper/pythontex.tex $DEST_DIR
cp paper/paper.tex $DEST_DIR
cp paper/references.bib $DEST_DIR
cp paper/software.bib $DEST_DIR
cp fix_latex.py $DEST_DIR
if $COVER_LETTER ; then cp cover-letter.md $DEST_DIR ; fi
# Flatten to a single file
cd $DEST_DIR
mv paper.tex _paper.tex
latexpand _paper.tex --empty-comments --keep-comments -o paper.tex
rm _paper.tex
# Run PythonTeX
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
pythontex --interpreter python:python paper.tex
bibtex paper
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
# Remove Pythontex dependence and fix figure paths
depythontex paper.tex --overwrite -o paper.tex
python fix_latex.py remove-pythontex-block -i paper.tex -o paper.tex
python fix_latex.py fix-figure-paths -i paper.tex -o paper.tex
cp figures/* .
rm -r figures
# Build PDF again without pythontex
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
bibtex paper
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error paper.tex
# (optionally) Generate PDF of cover letter
if $COVER_LETTER
then
pandoc -s cover-letter.md -o cover-letter.pdf --bibliography="references.bib"
fi
# Cleanup
rm -r sections
rm -r data
rm -r pythontex-files-paper
rm -r python
rm *.aux
if ! $ARXIV ; then rm *.bbl ; fi
rm *.blg
rm *.depytx
rm *.log
rm *.out
rm *.pytxcode
rm *.synctex.gz
rm *.py
rm pythontex.tex
if $COVER_LETTER ; then rm cover-letter.md ; fi
if $ARXIV ; then rm paper.pdf ; fi
if $ARXIV ; then rm *.bib ; fi
# Compress directory and cleanup
cd $1
tar cvzf "$DEST_DIR.tar.gz" $DIR_NAME
rm -r $DIR_NAME