About swk

I am a computational linguist, teacher of computer science and above all a huge fan of LaTeX. I use LaTeX for everything, including things you never wanted to do with LaTeX. My latest love is lilypond, aka LaTeX for music. I'll post at irregular intervals about cool stuff, stupid hacks and annoying settings I want to remember for the future.

Mitgliederbeiträge mit Hibiscus und JVerein einziehen

Der Einzug hat zwei Teile: Erstmal müssen wir definieren für wen wir den Beitrag einziehen wollen, dann müssen wir die Lastschriften über die Bank einziehen lassen.

Die Ermittlung der Mitglieder und ihrer Beiträge geht in JVerein unter Abrechnung im Ordner Abrechnung. Dort ist folgendes einzugeben:

  • Modus: Alle
  • Fälligkeit: Datum eintragen an dem eingezogen werden soll
  • Stichtag: 31.12.[Jahr]
  • Zahlungsgrund: Mitgliedsbeitrag [Jahr]
  • SEPA-Datei: Nein
  • Abbuchungsausgabe: Hibiscus

In Hibiscus gibt des dann unter SEPA Zahlungsverkehr den Punkt SEPA Lastschriften. Dort sollte jetzt für jedes Mitglied eine Lastschrift mit dem korrekten Mitgliedsbeitrag aufgeführt sein. Um sie tatsächlich auszuführen muss man mit rechts klicken und Jetzt ausführen wählen. Dann sollte Hibiscus nach einer TAN fragen. Und dann sollte Geld abgebucht werden.

Leider kann man in unserer Version von Hibiscus nur einzelne Lastschriften machen, d.h. man muss für jedes Mitglied neu klicken und die TAN eingeben. Alternativ kann man eine SEPA-Datei erzeugen und die bei der Bank im Online-Banking hochladen.

Cropmarks (Beschnittmarken)

If you print a professional book where graphics go until the very edge of the page, you need to give a file with cropmarks (Beschnittmarken) to the printer. This is how to produce them in LaTeX, it is actually very simple with the package crop:


The book in question was A5 paper which has a size of 148mm x 210mm. I wanted to have 3 more milimeters to each side. This makes the final paper size I want to have 154mm x 216mm, which I have given above. As I want the markings equally on each side, I use the option center to center the content in the middle of the larger page. The option cam print standard cropmarks (this is also the default).

Now the only thing left to do is adjust the graphics. For every page where a graphic goes to the edge of the page, increase it a little bit over the margin. There are several ways to do that, depending on what exactly it is you do. This is an example for a colored background image that fills the whole page. The important part is \dimexpr\paperwidth+6mm which just adds 6mm to the height of the picture:

\begin{tikzpicture}[remember picture, overlay]
\node[inner sep=0pt] at (current page.center) { 

Find file names with invalid encoding on Linux

I have files copied from Windows computers in ancient times. The filenames contain special characters and they have been messed up somewhere along the way. For example I got a file named 9.5.2 Modelo de aceptaci??n (espa??ol).doc in the folder 9 Garant??a del Estado.

First, I want to find and list these files. Stackexchange tells us how to do that:

LC_ALL=C find . -name '*[! -~]*'

This will find all names that have non-ASCII letters, not only those that are broken. But in my case I have folders where ALL of the names are broken, so I don’t mind.

Second, I want to fix the names. I did it manually, but for future reference, if I ever were to do anything like that again, I might use one of the solutions proposed in this thread on serverfault.com.

Unison preferences for syncing

Unison is a tool to compare and synchronize two folders. You can configure it by GUI, but at least for me (Kubuntu 18.04) not all settings work. Specifically, I cannot set the value “0”. But there is an easy way around the problem. Unison puts a file called Profilename.prf (where “Profilename” should be replaced with the actual name of your profile) into the folder .unison in your home directory. This is simply a text file with key-value pairs, that you can edit at your leisure.

Here are standard settings for comparing two directories without comparing the file permissions:

label = My first comparison
root = /home/test/FolderOne/
root = /home/test/FolderTwo/
perms = 0
dontchmod = true

Now for the coolest feature of Unison: It is written in OCaml!! OCaml was used in my third semester to teach functional programming. I remember clearly the teacher telling us about the “usefulness” of the language. She had one slide with examples of programs written in OCaml. And she must have looked very hard to find any. There were a grand total of three programs on the slide. Two formal logic resolvers or something to that effect (we were like “yeah, really useful”). And MLDonkey (peer-to-peer filesharing was BIG in those days before Netflix, Spotify and fast internet) which she clearly didn’t know what it was for. So now, if she still has that slide, I can add another program! And a really useful one at that!

Typearea settings for a scrbook

Here are dirty hacks for page layout in LaTeX and a few useful standard settings.

I load the following document class:


The option bibliography=totoc puts the bibliography into table of contents. The option 12pt sets normal font size to 12pt instead of the usual 11pt. This font size was a requirement for my thesis. The option a4paper sets DIN A4 paper (which should be the default anyway). The option headsepline adds a line below the header content on pages without a title.

A useful additional option may be oneside, which creates symmetric margins for one-sided print. Again, that was a requirement for the manuscript of my thesis. For the final print, I needed a normal two-sided print. A useful option there is titlepage=firstiscover, which gives equal margins for the first two pages (the book cover).

Usually you don’t want to tamper with the margins that LaTeX gives you. But in some cases, you may have specific guidelines that you need to adhere to. Or you have a fixed number of pages and run out of space, so you want smaller margins. Anyway, this is not recommended, I am just showing you how it works, because I can.

We have loaded the documentclass scrbook which is the KOMA-Script document class for an DIN A4 page book with a font size of 12pt. At that paper and font size, KOMA-Script uses a value of DIV=12 to calculate margins and text area sizes. The page has a width of 157.50mm and a height of 222.75mm for the text area. The top margin is 24.75mm and the inner margin 17.50mm. You can increase or decrease the margins by setting a different DIV value. So if you use the option DIV=13 for example, you will have a bigger text area (161mm wide instead of only 157mm). You can play around with the values until you find something you like. Here are the measurements for different DIV values for an DIN A4 page:

If you don’t find anything you like, you can set all values by hand with the geometry package. Use at your own peril. This is an example with a larger text height:

\usepackage[width=157.50mm,top=35mm,left=24mm]{geometry}  % gives textheight=226.36mm

When you play around with margins and text area settings, the package showframe is useful to see what you are doing:


“Non-sciency” table-of-contents in a LaTeX book

One of my “customers” wanted a book that didn’t look so “sciency” (i.e., like LaTeX). In addition to the look of the chapter and sections headings (described in my last post), my “customers” wanted the table-of-contents to also look “non-sciency”. So this is what I did.

The package to use for manipulations of the table-of-contents is titletoc:


The entry for a chapter specifies that chapters are prefaced with the chapter label (which is “Teil X” in our case) and otherwise pretty standard:

    [3.2em] % left margin from the left page margin. % default 1.5em
    {\addvspace{1em}\usekomafont{title}} % global formatting of the entry.
    {\contentslabel{3.2em}}  % numbered entry
    {\hspace*{-1.3em}} % non-nubered entry
    {\titlerule*[.5pc]{}\contentspage}  % filler-page format

Sections are not numbered and otherwise rather standard, except for a few adjustments of spacing:

    [1em] % left margin from the left page margin.
    {} % global formatting of the entry.
    {} % numbered entry, default \contentslabel{2.3em}
    {} % non-nubered entry
    {~\titlerule*[.7pc]{.}\contentspage} % filler-page format

“Non-sciency” chapters and sections in a LaTeX book

One of my “customers” wanted a book that didn’t look so “sciency” (i.e., less like LaTeX). The first few tweaks (described in my last post) were more general, this one deals with the look of chapter and section headings.

I use the package titlesec for the task:


Each chapter should start on its own page. On top it will say “Teil X”, then a line, then the chapter name centered. At the bottom of the page a picture is included. This is the code for it:

\titleformat{\chapter} % command
[display] % shape: display, block, runin, hang (default)
{\bfseries\Large\itshape} % format
{\thechapter} % label
{0.5ex} % sep btw. label and title body
{\rule{\textwidth}{1pt} \vspace{1ex} \centering} % before-code
[{\vfill\includegraphics[width=\linewidth]{\Chapterimg}\pagebreak}] % after-code

The image for a chapter is set before each chapter with the custom-defined command Chapterimg:


A section is just the title in large bold font, no number in front of it:

\titleformat{\section} % command
[block] % shape
{\usekomafont{title}\large} % format
{}  % label
{0pt} % sep 
{} % before-code
[] % after-code

I also adjusted the spacing a bit:

\titlespacing{\section}{0pt}{1ex}{0pt} % less space for sections
\titlespacing{\subsection}{0pt}{0pt}{0pt} % subsection is like a paragraph

In a previous version of the book, the images were supposed to be placed next to the section headings. My attempt at doing that was to include the image in the “after-code” of the section format and add a bit of space at the right margin for it. It looked ok, but there were some issues with one-line vs. multi-line titles that I didn’t fix, because the images moved to the chapters instead.

[{\vspace{-3em}\hfill\includegraphics[width=4em]{\Chapterimg}\hspace{-5em}~}] % after-code
\titlespacing{\section}{0pt}{1ex}{0pt}[6em] % left margin / before / after / [right]

A “non-sciency” LaTeX book

One of my “customers” wanted a book that didn’t look so “sciency” (i.e., less like LaTeX). So here are a few tweaks to match their expectations.

Chapters should have letters as references with the prefix “Teil”:

\renewcommand{\thechapter}{Teil \Alph{chapter}}

Sections have the letter, a hyphen and the number:


Figures have no numbers, only the caption text below (using the package caption):


The first line of a paragraph is not indented. To compensate, the space between paragraphs is bigger:


The header line of a page contains no section, but only the name of the chapter (using the package scrlayer-scrpage):

\clearpairofpagestyles % empty default header/footer markings
\automark[chapter]{chapter} % only chapter as mark
\ihead{\headmark} % inner margin has name of chapter
\ohead{\pagemark} % outer margin has page number

Compact lists in LaTeX

New environments that take up a lot less space than the original ones:

\newenvironment{compactitemize} % compact itemize list
\newenvironment{compactdescription} % compact description list
\newenvironment{compactenumerate} % compact enumerate list

A numbered environment for example sentences

I want an environment for example sentences where sentences are numbered and can be referenced. This is common in publications in the area of linguistics and there are a few packages that do the trick. But here is my own.

First, we need a counter that provides the number for the sentence:


We reset sentence counter for each chapter:


We print the sentence number as (chapter.sentence):


Then we define an environment for one example sentence, where the number will be printed in the beginning of the line and then the sentence follows:

{% start env
\begin{enumerate} \small%
\itemsep0pt \parskip0pt%
{% end env

Next is an environment for more than one example sentence. Here the sentence number will be printed in the beginning of the line and the individual sentences get an a., b., c., in front of them:

{% start env
\begin{enumerate} \itemsep0pt \parskip0pt%
{% end env