This repository contains a bilingual template (Spanish/English) to produce digital exams in PDF using Pandoc, Lua filters, and a LaTeX base originally created by Driss Drissi. Questions live in Markdown and solutions can be stored in a separate document and injected automatically.
¿Prefieres la documentación en español? Consulta README.es.md.
- Dual language support (
--lang esor--lang en). - Shared LaTeX template with shaded solution blocks.
- External solutions files (
exam/solutions_es.md/exam/solutions_en.md) linked via thesolutions-filemetadata. - Minimal maths samples in both languages (
exam/questions_es.mdandexam/questions_en.md).
# Generate Spanish exam (default)
./scripts/export.sh
# Generate Spanish exam with answers
./scripts/export.sh --answers
# Generate English exam
./scripts/export.sh --lang en
# Generate English exam with answers
./scripts/export.sh --lang en --answersThe script creates PDFs in export/:
export/exam.pdfandexport/exam_answers.pdffor the Spanish sample.export/exam_en.pdfandexport/exam_en_answers.pdffor the English sample.
Clean the directory before committing if you do not want to version the generated files.
The generated PDFs contain a very small set of maths exercises you can replace with your own content.
- Pandoc (≥ 3.x recommended).
- LaTeX distribution with
lualatex. - Liberation fonts (install
fonts-liberation/fonts-liberation2depending on your distribution).
-
Ubuntu / Debian
sudo apt update sudo apt install pandoc texlive-full fonts-liberation
If
texlive-fullis too large, installtexlive,texlive-luatex, andtexlive-latex-extrainstead. -
Fedora / RHEL
sudo dnf install pandoc texlive-scheme-small texlive-luatex texlive-collection-latexrecommended texlive-booktabs sudo dnf install liberation-serif-fonts liberation-sans-fonts liberation-mono-fonts
-
Arch / Manjaro
sudo pacman -Syu pandoc texlive-most ttf-liberation
-
macOS
brew update brew install pandoc mactex-no-gui brew install --cask font-liberation
After installing MacTeX, launch
/Library/TeX/texbin/texhashor reopen the terminal solualatexis on PATH. -
Windows
- Install Pandoc using the MSI.
- Install MiKTeX including the
luatexpackages. - Install Liberation fonts (run the
.ttfinstallers). - Add the Pandoc and MiKTeX binaries to the
PATHenvironment variable if the installers do not do it automatically.
Check that Pandoc and the LaTeX engine work:
pandoc --version
lualatex --versionfilters/ # Lua filters (solution injector)
exam/ # Sample statements (questions_es.md / questions_en.md)
scripts/ # CLI exporter
templates/ # LaTeX template and original resources
export/ # Output PDFs (ignored)
- Edit
exam/questions_es.mdorexam/questions_en.mdto adjust the sample statements. - Place blocks
::: {#id .solution-placeholder}where each answer should appear. Use the same IDs in the matching solutions file (exam/solutions_es.mdorexam/solutions_en.md) as::: {#id .solution}containing the actual answer in LaTeX-friendly syntax. - Update the header metadata to set fonts, department, logo, etc.
- Default fonts are Liberation and are defined in
exam/questions_es.md. Adjust themainfont,sansfont,monofontandmathfontvalues if you want other fonts installed on the system. - The header supports optional metadata:
departmentandlogo(relative path to the repository). The first appears left-aligned in small caps and the second on the right. - To modify headers, footers or question styles, edit
templates/exam-template/exam-template.tex. - The Lua filters applied are
filters/solution_injector.lua(injects solutions) andtemplates/exam-template/exam-filter.lua(converts@q). - Change the LaTeX engine by exporting the variable before the script (for example,
PDF_ENGINE=xelatex ./scripts/export.sh).
- If the command fails due to missing fonts, confirm their installation with
fc-list | grep "FontName". - For LaTeX errors, add
-V log=exam.logto the Pandoc invocation to get a detailed log:pandoc exam/questions_es.md \ --pdf-engine lualatex \ --template templates/exam-template/exam-template.tex \ --lua-filter templates/exam-template/exam-filter.lua \ --lua-filter filters/solution_injector.lua \ --from markdown+tex_math_dollars+tex_math_single_backslash+fenced_divs \ -V log=exam.log -o export/exam_debug.pdf
- Run
npx markdownlint "**/*.md"to check Markdown formatting before generating the PDF.
- Original LaTeX exam template by Driss Drissi
(included in
templates/exam-template/and translated/adapted). - Spanish documentation is available in
README.es.md.
