diff options
-rw-r--r-- | posts/latex.md | 120 | ||||
-rw-r--r-- | public/img/latex.png | bin | 0 -> 7014 bytes |
2 files changed, 120 insertions, 0 deletions
diff --git a/posts/latex.md b/posts/latex.md new file mode 100644 index 0000000..4234c84 --- /dev/null +++ b/posts/latex.md @@ -0,0 +1,120 @@ +[meta]: <title> (My LaTeX setup) +[meta]: <subtitle> (How to set up a simple LaTeX environment with XeTeX and latexmk) +[meta]: <author> (Loek) +[meta]: <date> (January 24 2022) +[meta]: <tags> (software, latex, git) +[meta]: <cover> (/img/latex.png) + +I started using LaTeX instead of MS Word about two years ago, and I've never +regretted the decision. I switched out of frustration because Word makes it +really easy to mess up your document structure without you noticing. + +## Cool features LaTeX gets you + +- Automatically numbered figures with references that automatically update +- Really simple bibliography management with `biblatex` +- Packages that help you typeset scientific things like chemistry or physics +- Professional looking output documents with very little effort +- Automation of repetitive things with macros +- It's a plain text format, so it works well with `git` or other version + control software +- Probably more + +## Installation + +This guide is for Arch Linux and it's derivatives, but you can use +[pkgs.org](https://pkgs.org) to find the mentioned packages if they're under a +different name in your distro's package manager. + +### Required packages + +- `biber` +- `texlive-most`, containing: + - `texlive-bibtexextra` + - `texlive-core ` + - `texlive-fontsextra ` + - `texlive-formatsextra` + - `texlive-games` + - `texlive-humanities` + - `texlive-latexextra` + - `texlive-music` + - `texlive-pictures` + - `texlive-pstricks` + - `texlive-publishers` + - `texlive-science` +- `latex-mk` + +tl;dr + +``` +# pacman -S texlive-most biber latex-mk +``` + +### Force XeTeX compiler with latexmk + +To force latexmk to use the `xelatex` compiler instead of `pdflatex` you can +create `~/.config/latexmk/latexmkrc` with the following content: + +``` +$pdflatex = "xelatex %O %S"; +$pdf_mode = 1; +$dvi_mode = 0; +$postscript_mode = 0; +``` + + +## Hello world + +LaTeX uses a lot of auxiliary files for compilation, so it's a good idea to +create a new directory for every document. After creating a new directory, +create a .tex file and open it with a text editor. + +```tex +\documentclass[12pt, a4paper, dutch]{article} +\usepackage[margin=1in]{geometry} +\usepackage{babel} + +\bigskipamount=7mm +\medskipamount=4mm +\parindent=0mm + +\begin{document} +Hello world! +\end{document} +``` + +This is the starting point I generally use for all my documents. It uses a4 +paper and 2.54cm margins, which is the default in Word (in Europe). Because +most of my documents are in Dutch, I add the `dutch` option to my document +class, and import the babel package for correct word breaking and built-in +latex heading translations. I also disable paragraph indenting, and modify the +`\bigskip` and `\medskip` distances. + +After creating the .tex file, you can run `latexmk <your .tex file>` to compile +the document. When it's done, you should have a new .pdf file in your directory +with the same name as the .tex file. + +Keep in mind that you can probably install an extension for your text editor to +have it automatically compile and refresh your document for you. If you're +using Visual Studio Code, you can use the [LaTeX +Workshop](https://marketplace.visualstudio.com/items?itemName=James-Yu.latex-workshop) +extension, and for vim I use [vimtex](https://github.com/lervag/vimtex) with +[coc-vimtex](https://github.com/neoclide/coc-vimtex) for +[coc](https://github.com/neoclide/coc.nvim). + +## Notes + +### LaTeX and git + +Because LaTeX creates a lot of temporary files, you should add the following to +your repository's `.gitignore`: + +```gitignore +**/*.aux +**/*.fdb_latexmk +**/*.fls +**/*.log +**/*.out +**/*.synctex.gz +``` + diff --git a/public/img/latex.png b/public/img/latex.png Binary files differnew file mode 100644 index 0000000..9489d51 --- /dev/null +++ b/public/img/latex.png |