Some TeX and LaTeX Tips

LaTeX is a great document description language that allows anyone to create documents and papers with a professionally looking layout.

This post describes some handy tricks how to easily type German Umlauts, how to achieve better font rendering in PDF files created by LaTeX on Linux, and more.

Umlauts in Your LaTeX Document

It can be a pain to type (German) Umlauts and special characters (ä, ö, ü, ß) in you latex document. Traditionally, you would have to type something like \”a to get an ä, or something like \ss{} to get a ß. But if you put the following lines in the preamble of your tex-document:

\usepackage[german]{babel}
\usepackage[T1]{fontenc}
\usepackage[latin1]{inputenc}

This will allow you to simply type “ä” and “ß” to get the appropriate special characters. Actually you don’t need the German babel package (the first line) but this will give you German typesetting (dates, hyphenation).

Nice Fonts in Your PDF Documents Produced on Linux Using PDFLaTeX

Analogous to $ latex document.tex, which will produce document.dvi, $ pdflatex document.tex will produce the file document.pdf. For some reason this will result in a pdf file that displays with extremely ugly fonts in acrobat reader. To circumvent this problem, put the following in your tex file:

\usepackage{aeguill}

This will use a different font, which displays nicely in acroread.

If you use LyX, simply choose “Format->Document->Font->ae” which has the same effect.

Using Vi/Vim to Efficiently Work with LaTeX

If you put the following line in your ~/.vimrc:

:map ^K :w!^M:!clear; echo Making Postscript % ...; latex %; xdvi %<.dvi&^M^M

you can simply press <ctrl>+k to save, compile the tex file you’re editing to dvi and then disply the output in xdvi.
This makes for a very nice WYSIWYG-experience: Simply edit your tex-file, press <ctrl>+k, look at xdvi, then press “q” to quit xdvi, and you’re back in your tex-file.

Please note: You cannot simply paste the above line into your ~/.vimrc. There are some special characters in it (^K = <ctrl>, ^M = <return>) that can’t be pasted. Instead, open the file ~/.vimrc in vi, scroll to the end, and paste the whole line into it. Then, delete these special characters (^K and ^M). To get them back, place your cursor where the ^K was, and (in input mode), press <ctrl>+k, which will display a “?”, i.e. it’s now waiting for a special character. Now, press <ctrl>+k twice, which will result in a “^K”, but this is now *one* (special) character.
Similarly, the “^M”: go into insert mode, then press <ctrl>+k, and when the “?” appears, press <return> twice. This should result in a “^M” as *one* character.

Some Links

Leave a Reply

Your email address will not be published. Required fields are marked *