-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmakearticle
More file actions
executable file
·125 lines (115 loc) · 2.84 KB
/
Copy pathmakearticle
File metadata and controls
executable file
·125 lines (115 loc) · 2.84 KB
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
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
#!/bin/sh
#####################################################
# Convert TEX-files to PDF-files
# Initially written by Marko Kosunen
# Last modification by Marko Kosunen, marko.kosunen@aalto.fi, 19.07.2017 10:53
# Version 1.6
# Date: 26.10.2022
#
# Software required:
# latex
# ps2pdf
# pdflatex
# bibtex
# makeindex
#
# Usage: Try makearticle -h
#
# Modification history:
# - Made pdflatex default in release 1.1
# - Removed annoying '-synctex' option in release 1.2
# - Added the default input file option in v1.3
# - Merged makearticle and makesides in v1.4
#
####################################################
# function to display help with -h argument
help_f()
{
cat << EOF
MAKEARTICLE Release 1.6 (26.10.2022)
makearticle - Script for producing PDF document from TEX-files
Written by Marko Pikkis Kosunen
SYNOPSIS
makeslides [OPTIONS] [FILE]
DESCRIPTION
Produce PDF-document from given TEX-files
Output defaults to ./pdffiles/[FILE].pdf .
OPTIONS
-c
Continuous compilation.
-H
Produce handouts.
-h
Show this help.
EOF
}
#Initialize variables
size=a4;
#numargs=$#
HANDOUT=0;
LOOP="1";
LOOPING="0";
while getopts cHh opt
do
case "$opt" in
c) LOOPING="1";;
H) HANDOUT="1";;
h) help_f; exit 0;;
\?) help_f;;
esac
shift
done
#
# check if source file exists
if [ -z "$1" ]; then
echo "Assuming dirname ad default filename"
DIR=`pwd`
doc=`basename $DIR`
echo "Using default filename $doc."
if [! -f "${doc}.tex" ]; then
echo "ERROR: Input file does not exist."
exit 1
fi
elif [ ! -f "$1" ]; then
echo "ERROR: Input file does not exist."
help_f
exit 1
else
# remove extension of source file
doc=`echo $1 | sed 's/\(.*\)\(.[Tt][Ee][Xx]$\)/\1/g'`
fi
while [ "$LOOP" -eq "1" ]; do
# compile
if [ ! -d ./pdffiles ]; then
mkdir ./pdffiles
echo "Created directory ./pdffiles"
fi
latexmk -pdf -pdflatex="pdflatex -shell-escape -interaction=nonstopmode" -use-make $doc.tex
pdflatex $doc.tex
mv $doc.pdf ./pdffiles/
if [ $HANDOUT == "1" ]; then
echo "\PassOptionsToClass{handout}{beamer}" > ${doc}_handout.tex
cat ${doc}.tex >> ${doc}_handout.tex
latexmk -pdf -pdflatex="pdflatex -shell-escape -interaction=nonstopmode" -use-make $doc_handout.tex
mv ${doc}_handout.pdf ./pdffiles/
fi
touch $doc.timestamp
if [ "${LOOPING}" -eq "1" ]; then
LOOP="1"
while [ "$doc.timestamp" -nt "$doc.tex" ]; do
sleep 1
done
else
LOOP="0"
fi
done
# remove useless crap
for i in *.dvi *.aux *.bbl *.blg *.log *.out \
*.toc *.nlo *.nls *.ilg *.snm ${doc}_handout.tex \
$doc.timestamp; do
if [ -f ./"$i" ]; then
echo "Cleaning up $i"
rm -f "./$i"
fi
done
exit 0