simplify mkpdf output
This commit is contained in:
parent
2478fb59e7
commit
2001785170
1 changed files with 22 additions and 19 deletions
|
|
@ -21,20 +21,32 @@
|
||||||
local tex_file="''${1}"
|
local tex_file="''${1}"
|
||||||
local output_dir="./out"
|
local output_dir="./out"
|
||||||
|
|
||||||
if [[ -z "$tex_file" ]]; then
|
mkdir -p "$output_dir"
|
||||||
# Build all .tex files in current directory
|
|
||||||
local found=0
|
|
||||||
for file in *.tex(N); do
|
|
||||||
found=1
|
|
||||||
echo "Building $file..."
|
|
||||||
latexmk -pdf -bibtex -shell-escape -interaction=nonstopmode \
|
|
||||||
-output-directory="$output_dir" -f "$file"
|
|
||||||
|
|
||||||
|
_mkpdf_build() {
|
||||||
|
local file="$1"
|
||||||
|
local log_file="$output_dir/''${file%.tex}.log"
|
||||||
|
|
||||||
|
printf "Building %s... " "$file"
|
||||||
|
if latexmk -pdf -bibtex -shell-escape -interaction=nonstopmode \
|
||||||
|
-output-directory="$output_dir" -f "$file" > "$log_file" 2>&1; then
|
||||||
local basename="''${file%.tex}"
|
local basename="''${file%.tex}"
|
||||||
if [[ -f "$output_dir/$basename.pdf" ]]; then
|
if [[ -f "$output_dir/$basename.pdf" ]]; then
|
||||||
cp "$output_dir/$basename.pdf" "./"
|
cp "$output_dir/$basename.pdf" "./"
|
||||||
echo "Copied $basename.pdf to current directory"
|
echo "done"
|
||||||
|
return 0
|
||||||
fi
|
fi
|
||||||
|
fi
|
||||||
|
echo "failed (see $log_file)"
|
||||||
|
tail -20 "$log_file"
|
||||||
|
return 1
|
||||||
|
}
|
||||||
|
|
||||||
|
if [[ -z "$tex_file" ]]; then
|
||||||
|
local found=0
|
||||||
|
for file in *.tex(N); do
|
||||||
|
found=1
|
||||||
|
_mkpdf_build "$file"
|
||||||
done
|
done
|
||||||
if [[ $found -eq 0 ]]; then
|
if [[ $found -eq 0 ]]; then
|
||||||
echo "No .tex files found in current directory"
|
echo "No .tex files found in current directory"
|
||||||
|
|
@ -45,16 +57,7 @@
|
||||||
echo "File not found: $tex_file"
|
echo "File not found: $tex_file"
|
||||||
return 1
|
return 1
|
||||||
fi
|
fi
|
||||||
|
_mkpdf_build "$tex_file"
|
||||||
latexmk -pdf -bibtex -shell-escape -interaction=nonstopmode \
|
|
||||||
-output-directory="$output_dir" -f "$tex_file"
|
|
||||||
|
|
||||||
# Copy PDF to current directory
|
|
||||||
local basename="''${tex_file%.tex}"
|
|
||||||
if [[ -f "$output_dir/$basename.pdf" ]]; then
|
|
||||||
cp "$output_dir/$basename.pdf" "./"
|
|
||||||
echo "Copied $basename.pdf to current directory"
|
|
||||||
fi
|
|
||||||
fi
|
fi
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue