Working with Latex
Don’t write your thesis in Word. Use LaTeX instead. Its a professional typesetting tool (whatever that means) and allows .. In theory it allows you to separate the what you write from how its going to look.
There’s many way on how to use Latex.
- Writing LateX with … on Windows (it sucks)
- Using VSCode with a plugin …(has live preview)
- As an an online service https://overleaf.com
I tried all above, but now I use a very barebones approach.
TLDR
- use Git and Conventional Commits
- break up long lines to ease version diffing
- autocompile latex using entr and viewing the pdf with zathura
- write a Makefile to automate commands
- use AI to generate complex LaTeX commands
Workflow
If the documentation needs to be changed, follow these steps:
- Update the repository (e.g., with
git pull -r
) - Start auto-compilation and open the PDF file
- Make changes (break up long lines)
- Write a useful commit message
- Push the changes (e.g., with
git push origin master
)
Setting up LaTeX
If you are using Linux, I recommend …
sudo pacman -S livetex
Using LateX
Let’s write a file called main.tex
with this content.
Now compile it to a pdf
Clean uo using
Automating Compilation
We want to
Versioning LaTeX Changes
The LaTeX compiler will take care of formatting and displaying text. It will ignore linebreaks and carriage returns.
So break up long lines of text.
Either start every sentence on a new line,
or use a word count as a limit
(Vim’s gq
motion will autoformat it for you).
The reason is that Git by default shows the entire line as changed if a single word is modified. If multiple sentences are on one line, they will all be marked as changed and it gets difficult to see what changed.
Writing useful Commit Messages
To track documentation changes consistently, commit messages should be structured like this:
-
Headline - Summarize the changes in a few words and one line. One of these prefixes should be used to distinguish commits:
[TASK]
- Represents a commit that changes content (text).[REFACTOR]
- Represents a commit that changes formatting, structure, or corrects errors in the text.
-
Blank line - A blank line separates the headline and the description.
-
Description - List the individual steps. If multiple steps are combined, separate them with a dash. For example:
[TASK] initialize repository - create IT-Grundschutz folder - create .gitignore file - delete test file
Example output of git log --oneline
with and without a blank line between the headline and description:
With blank line:
052855c
[TASK] initialize repository
b7ff419
[REFACTOR] format IT-Grundschutz
The first line of the commit message is used as the headline by many programs (GitLab, IDEs, etc.). If no blank line is used, the entire commit message will be displayed.
Without blank line:
052855c
[TASK] initialize repository - create IT-Grundschutz folder - create .gitignore file - delete test file
b7ff419
[REFACTOR] format IT-Grundschutz - add image - remove test content - add PDFs to .gitignore file
For more information on writing clean commit messages, see: https://chris.beams.io/posts/git-commit/
Branches & Tags
This repository is not intended to use multiple branches. Tags can be used in Git to mark a commit as a specific version. In the thesis, this feature can be used to label submissions.
Ignoring temporary files for Git
The hidden .gitignore
file specifies files that should not be versioned.
The rules apply to the directory where the .gitignore
file is located and all subdirectories.
Currently, only LaTeX files (.tex), PDF files (.pdf), and images (.jpg, .png) are versioned.
This is because LaTeX generates many files during compilation, which change frequently.
If additional files need to be added, ask me or try it yourself. The .gitignore
file has its own syntax.
Example .gitignore
file
Structuring LaTex Projects
Ideally, independent sections of the text (title page, abstract, chapters, etc.) should be written in separate files and then included in the main document.
Using a single Documents
Simple
Splitting into Multiple Documents
Use when working with other people in Git
In LaTeX, the command \input{folder/inp_document.tex}
can be used to import the file inp_document.tex into the current LaTeX document. The commands in the imported document are preserved. This feature can be used to split larger LaTeX documents.