Overview

This page contains ready to use templates for the most common use cases and make it easy to get started with BFH LaTeX. Look at the specific template, download the archive and start writing your own documents from there.

Note

The examples and templates are pre-installed if you use the VS Code Docker image.

How to use the Templates

Note

This part comes from the templates source, don’t follow all of it. Start reading from Build instructions

BFH LaTeX Templates

This directory contains various templates to get started quickly with BFH LaTeX. To compile the document, you will need BFH LaTeX installed (see below).

Installing the dependencies

Install a recent LaTeX distribution and the latest version of the LaTeX package bfh-ci. How to do this is described in detail in the online manual. Follow the instructions for your operating system.

Build instructions

The instructions below apply to all templates, but there may be specific instruction in the templates README as well.

Parameterization

For each template, there is a local latexmk configuration file called “.latexmkrc”. This file contains some pre-configurations like the name of the output directory (“_build”) and the default latex compiler (“lualatex”). Modify or delete this file.

Note

We recommend using Git for version control. If you are using Git, create a gitignore file with a good set of ignore patterns. For a quick start, we recommend the following patterns.

  • Get a general set of ignore patterns

    • https://www.toptal.com/developers/gitignore?templates=latex,windows,linux,vim,emacs,osx

    curl -L -o .gitignore https://www.toptal.com/developers/gitignore/api/latex,windows,linux,vim,emacs,osx
    
    • Ignore all directories that start with an underscore ‘_*/’

    echo '_*/' >> .gitignore
    
Compiling

To compile the LaTeX document, use your favorite LaTeX editor together with the TeX compiler (xelatex and lualatex are supported). Thre is no support for pdflatex compiler.

If you use latexmk on the command line, the following command will do the compilation.

Running Latexmk
  • In the simplest case you just have to type

    latexmk -lualatex
    

This runs LaTeX on all .tex files in the current directory using the output format specified by the configuration files.

  • If you want to make sure to get a .pdf file as output, just mention it:

    latexmk -pdflua
    
  • If you want to compile only one specific .tex file in the current directory, just provide the file name:

    latexmk -lualatex myfile.tex
    
  • If you want to preview the resulting output file(s), just use

    latexmk -pv -lualatex
    
  • And now the killer feature: If you want LaTeXmk to continuously check all input files for changes and re-compile the whole thing if needed and always display the result, type

    latexmk -pvc -lualatex -interaction=nonstopmode
    

    Then, whenever you change something in any of your source files and save your changes, the preview is automatically updated. But: This doesn’t work with all viewers, especially not with Adobe Reader. See the section about configuration files below for setting a suitable viewer application.

  • Of course, options can be combined, e.g.

    latexmk -outdir=_build -pdf -pv myfile.tex
    
Cleanup
  • After running LaTeX, the current directory is contaminated with a myriad of temporary files; you can get rid of them with

    latexmk -c
    
  • Previous command doesn’t delete the final .pdf/.ps/.dvi files. If you want to delete those too, use

    latexmk -C