-
Notifications
You must be signed in to change notification settings - Fork 3
/
Copy pathrunlatex.sh
115 lines (105 loc) · 2.89 KB
/
runlatex.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
107
108
109
110
111
112
113
114
115
#!/bin/bash
# PharmTeX Linux start script, part of the PharmTeX platform.
# Copyright (C) 2023 Christian Hove Claussen ([email protected]).
# This program is free software: You can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program (see file named LICENSE). If not, see <https://www.gnu.org/licenses/>.
# Path to texfs
BSTDIR="$LDIR/texlive/texmf-local/bibtex/bst/pharmtex"; export BSTDIR
CLSDIR="$LDIR/texlive/texmf-local/tex/latex/pharmtex"; export CLSDIR
# If no options set, prompt user
USERINP=0
if [ "$1" == "" ]; then
read -p 'File to edit = ' NAME
MODE=gui
USERINP=1
fi
# Change paths if PharmTeX bundle is present
OLDPATH="$PATH"
OLDMANPATH="MANPATH"
OLDINFOPATH="INFOPATH"
if [ -d "$LDIR" ]; then
source $LDIR/bin/setpath
fi
texhash > /dev/null 2>&1
# Check for Rstudio Sweave
if [ -f run-counter ]; then
read -r i<run-counter
fi
if [ "$1" == "--version" ] && [ -z "$2" ] && [ -z "$3" ]; then
echo 1 > run-counter
exit
elif [ "$1" == "-synctex=1" ] && [ "$i" = 1 ]; then
echo 2 > run-counter
exit
elif [ "$1" == "-synctex=1" ] && [ "$i" = 2 ]; then
i=3
sweave=1
if [ -f run-counter ]; then
rm run-counter
fi
NAME=$(basename "${*: -1}")
EXT="${NAME##*.}"
if [ "$EXT" == "$NAME" ]; then
EXT="Rnw"
fi
NAME="${NAME%.*}"
if [ -n "$PHARMTEX_MODE" ]; then
MODE="$PHARMTEX_MODE"
else
MODE="full"
fi
else
sweave=0
if [ $USERINP == 0 ]; then
NAME=$(basename "$1")
MODE="$2"
fi
EXT="${NAME##*.}"
if [ "$EXT" == "$NAME" ]; then
if [ -e "$NAME.Rnw" ]; then
EXT="Rnw"
else
EXT="tex"
fi
fi
NAME="${NAME%.*}"
fi
# Load Texlive manager if requested and exit
if [ "$NAME" == "texpath" ]; then
exit
fi
# Load Texlive manager if requested and exit
if [ "$NAME" == "texman" ]; then
tlshell
exit
fi
# Choose batch mode if no mode set
if [ -z "$MODE" ]; then
MODE=batch
fi
# If .tex file does not exist, exit
if [ ! -e "$NAME.$EXT" ]; then
echo "Input file $NAME.$EXT does not exist, exiting..."
sleep 1
exit
fi
# Load MiKTeX Tool if gui mode
if [ "$MODE" == "gui" ]; then
texstudio "$NAME.$EXT"
else
perl $PHARMTEXDIR/runlatex.pl "$NAME.$EXT" "$MODE"
fi
# Clean up
if [ -e jabref.xml ] && [ -d "$LDIR/jabref" ]; then
mv jabref.xml "$LDIR/jabref/jabref.xml"
elif [ -e jabref.xml ]; then
rm jabref.xml
fi
if [ -e dodel.txt ]; then
rm dodel.txt
if [ -e "$NAME.pdf" ]; then
rm "$NAME.pdf"
fi
fi
PATH="$OLDPATH"; export PATH
MANPATH="OLDMANPATH"; export MANPATH
INFOPATH="OLDINFOPATH"; export INFOPATH