Compare commits

...

3 Commits

Author SHA1 Message Date
Pedro Cabral
49b33fdbd4 added tasks to compile manually 2026-02-21 00:06:36 +01:00
Pedro Cabral
be2a389edf added smart build 2026-02-21 00:06:04 +01:00
Pedro Cabral
fbb9e400a1 ignore .DS_Store 2026-02-21 00:05:36 +01:00
4 changed files with 89 additions and 2 deletions

1
.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
.DS_Store

19
.vscode/settings.json vendored
View File

@@ -1,3 +1,20 @@
{ {
"latex-workshop.latex.recipe.default": "latexmk (xelatex)" "latex-workshop.latex.recipes": [
{
"name": "Smart LaTeX Build",
"tools": ["smart-build"]
}
],
"latex-workshop.latex.tools": [
{
"name": "smart-build",
"command": "bash",
"args": [
"%WORKSPACE_FOLDER%/build/build-latex-smart.sh",
"%DOC%"
]
}
],
"latex-workshop.latex.recipe.default": "Smart LaTeX Build",
"latex-workshop.formatting.latex": "latexindent"
} }

34
.vscode/tasks.json vendored Normal file
View File

@@ -0,0 +1,34 @@
{
"version": "2.0.0",
"tasks": [
{
"label": "Build Current File (XeLaTeX)",
"type": "shell",
"command": "xelatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"${file}"
],
"group": {
"kind": "build",
"isDefault": true
},
"problemMatcher": []
},
{
"label": "Build Current File (pdfLaTeX)",
"type": "shell",
"command": "pdflatex",
"args": [
"-synctex=1",
"-interaction=nonstopmode",
"-file-line-error",
"${file}"
],
"group": "build",
"problemMatcher": []
}
]
}

35
build/build-latex-smart.sh Executable file
View File

@@ -0,0 +1,35 @@
#!/bin/bash
set -euo pipefail
# Color definitions
BOLD='\033[1m'
RED='\033[31m'
BLUE='\033[34m'
RESET='\033[0m'
# Ensure a file parameter is passed
if [[ $# -lt 1 ]]; then
echo -e "${BOLD}${RED}Error${RESET}${RED}: No .tex file provided.${RESET}"
echo "Usage: $0 <file.tex>"
exit 1
fi
FILE="$1"
# append .tex file extension, iff not already passed
[[ "$FILE" != *.tex ]] && FILE="${FILE}.tex"
# Check that the file exists
if [[ ! -f "$FILE" ]]; then
echo -e "${BOLD}${RED}Error${RESET}${RED}: File '$FILE' not found.${RESET}"
exit 1
fi
# Detect active \usepackage{fontspec} (ignore commented lines)
if grep -Eq '^[^%]*\\usepackage\{fontspec\}' "$FILE"; then
echo -e "${BLUE}Detected fontspec → Using XeLaTeX${RESET}"
xelatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE"
else
echo -e "${BLUE}No active fontspec → Using pdfLaTeX${RESET}"
pdflatex -synctex=1 -interaction=nonstopmode -file-line-error "$FILE"
fi