-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcompile.sh
More file actions
executable file
·66 lines (54 loc) · 1.81 KB
/
Copy pathcompile.sh
File metadata and controls
executable file
·66 lines (54 loc) · 1.81 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
#!/bin/bash
# Program paper compilation script
# Compiles program.tex with bibliography support
set -e # Exit on error
# Configuration
TEX_FILE="tex/program.tex"
OUTPUT_DIR="out"
MAIN_NAME="program"
# Colors for output
RED='\033[0;31m'
GREEN='\033[0;32m'
YELLOW='\033[1;33m'
NC='\033[0m' # No Color
echo -e "${GREEN}=== Compiling Program paper ===${NC}"
# Create output directory if it doesn't exist
if [ ! -d "$OUTPUT_DIR" ]; then
echo -e "${YELLOW}Creating output directory: $OUTPUT_DIR${NC}"
mkdir -p "$OUTPUT_DIR"
fi
# Set TEXINPUTS to include tex directory for .cls and .bib files
export TEXINPUTS=".:./tex:${TEXINPUTS}"
# Step 1: First pdflatex run
echo -e "${GREEN}Step 1/5: First pdflatex run${NC}"
pdflatex -file-line-error -interaction=nonstopmode -synctex=1 \
-output-directory="$OUTPUT_DIR" \
-recorder \
"$TEX_FILE"
# Step 2: Run bibtex
echo -e "${GREEN}Step 2/5: Running bibtex${NC}"
cd "$OUTPUT_DIR"
BSTINPUTS="../tex:${BSTINPUTS}" BIBINPUTS="../tex:${BIBINPUTS}" bibtex "$MAIN_NAME"
cd ..
# Step 3: Second pdflatex run (for bibliography)
echo -e "${GREEN}Step 3/5: Second pdflatex run${NC}"
pdflatex -file-line-error -interaction=nonstopmode -synctex=1 \
-output-directory="$OUTPUT_DIR" \
-recorder \
"$TEX_FILE"
# Step 4: Third pdflatex run (for cross-references)
echo -e "${GREEN}Step 4/5: Third pdflatex run${NC}"
pdflatex -file-line-error -interaction=nonstopmode -synctex=1 \
-output-directory="$OUTPUT_DIR" \
-recorder \
"$TEX_FILE"
# Step 5: Final check
if [ -f "$OUTPUT_DIR/$MAIN_NAME.pdf" ]; then
echo -e "${GREEN}=== Compilation successful ===${NC}"
echo -e "Output: $OUTPUT_DIR/$MAIN_NAME.pdf"
ls -lh "$OUTPUT_DIR/$MAIN_NAME.pdf"
else
echo -e "${RED}=== Compilation failed ===${NC}"
echo -e "Check $OUTPUT_DIR/$MAIN_NAME.log for errors"
exit 1
fi