Documentation: Latex - zhaw-timetable/zhawo GitHub Wiki

Content

Set Up

You will need pdflatex and the markdown package to edit our documentations.

Install Latex

Osx : Install Latex

Windows: Install Latex

Install markdown package

Osx : Installing LaTeX Packages for macTeX

Windows: Installing LaTeX Packages for MikTeX on Windows

Vscode Set Up

We recommend using Vscode to edit your Latex files.

Install LaTeX Workshop.

Add to settings:

  "latex-workshop.latex.recipes": [
    {
      "name": "pdflatex ➞ bibtex ➞ pdflatex`×2",
      "tools": ["pdflatex", "bibtex", "pdflatex", "pdflatex"]
    }
  ],

  "latex-workshop.latex.tools": [
    {
      "name": "pdflatex",
      "command": "pdflatex",
      "args": [
        "--shell-escape",
        "-synctex=1",
        "-interaction=nonstopmode",
        "-file-line-error",
        "%DOC%"
      ],
      "env": {}
    },
    {
      "name": "bibtex",
      "command": "bibtex",
      "args": ["%DOCFILE%"],
      "env": {}
    }
  ],
  "latex-workshop.view.pdf.viewer": "tab"

Cheatsheet

Main file

pdf_doc.tex

all sections included

%Name of Section
\include{nameoffile}

Header/Footer

The Header and Footer are created using the fancyhdr package. In Main File:

% Header & Footer
\pagestyle{fancy}
\fancyhf{}
\lhead{PA - 2018}
\chead{ZHAWo}
\rhead{\theauthor}
\lfoot{}
\cfoot{\thepage}
\rfoot{}

Sections

A new .tex file is created for each section. Add ref to the root file to each section so that build on save works from the sections.

% !TEX root = pa_doc.tex

Example Code -> test.tex:

% !TEX root = pa_doc.tex
\begin{markdown}

# Test title
some text
## Testing tex commands

\blindtext
\cite{DUMMY}

\end{markdown}

You can use both latex and Markdown syntax.

Markdown Files

If needed Markdown files can be included.

\markdownInput{example.md}

Images

Images are placed in the assets folder.

% Added as is and placed by latex
\includegraphics{./assets/zhawoLogo.png}

% width/height
\includegraphics[width=4cm]{./assets/zhawoLogo.png}

% float --> left/right/center (\usepackage[export]{adjustbox})
\includegraphics[left]{./assets/zhawoLogo.png}

% image with citation
\begin{figure}[H]
  \includegraphics[width=4cm, center]{./assets/zhawoLogo.png}
  \caption{\textsf{Our Logo{\cite{OurReadme}}}}
\end{figure}

Use textsf so label use san serif font

cross-references

\begin{figure}[h]
    \centering
    \includegraphics[width=0.25\textwidth]{mesh}
    \caption{a nice plot}
    \label{fig:mesh1}
\end{figure}

As you can see in the figure \ref{fig:mesh1} % adds figure number

https://www.overleaf.com/learn/latex/Inserting_Images

Quotes

Typing quotations with this package is quite easy:

\say{Here, a quotation is written and even some \say{nested} quotations
are possible}

https://www.overleaf.com/learn/latex/Typesetting_quotations

Bibliography

Current Cition Style: ieee change in Main File:

\usepackage[backend=bibtex,style=ieee]{biblatex}

Sources are added to source.bib using the BibTeX Format: Book:

@BOOK{DUMMY,
AUTHOR="John Doe",
TITLE="The Book without Title",
PUBLISHER="Dummy Publisher",
YEAR="2100",
}

Website and multiple authors:

@online{OurReadme,
  author = {Bachmann, Dominik and Visser, Julian},
  title = {{Readme}},
  year = 2018,
  url = {https://github.com/zhaw-timetable/zhawo},
  urldate = {2018-12-10}
}

Reference the source:

\cite{DUMMY}
\cite{OurReadme}

https://www.latex-tutorial.com/tutorials/bibtex/

Font

Chnage Font default = Computer Modern

\usepackage[sfdefault]{roboto}  %% Option 'sfdefault' = base font, fallback
\usepackage[T1]{fontenc}

Find supported fonts: http://www.tug.dk/FontCatalogue/

Include PDF

\usepackage{pdfpages}

This will insert the first page of external.pdf without numbering the inserted page.

\includepdf{external.pdf}

If you want to the inserted page to have a page number add the option pagecommand={}. With this option, the command will be:

\includepdf[pagecommand={}]{external.pdf}

To insert specific pages, say pages 2, 4, and 7, use:

\includepdf[pages={2, 4, 7}, pagecommand={}]{external.pdf}

To insert a range of pages, say pages 9 through 13, use:

\includepdf[pages={9-13}, pagecommand={}]{external.pdf}