❀✿❀ SuperLaserNino ✿❀✿

LaTeX

2 June 2015

Modified: 13 March 2016

2106 words

I have helped typeset three theses and many shorter documents in LaTeX and I realized that I find myself googling the same things over and over again. Therefore I decided to collect all the problems I have solved so far on this page. At the bottom there is a list of unsolved problems. The reader is invited to give me advice in the comments.

I will update this page when I learn new things.

This page is meant mostly as a reference for myself or others, for how to solve certain problems, technically. There won’t be much discussion of why you should do something a particular way. If you want to know more about that, I suggest you start with Practical Typography and if you’re still interested in typography after that, you can move on to The Elements of Typographic Style or something.

Contents

Standard packages for every document

\usepackage[a4paper, left=4.5cm, right=4.5cm, top=3cm, bottom=4.5cm, marginparwidth=4cm]{geometry}
\usepackage[utf8]{inputenc}
\usepackage{amsmath,amssymb}
\usepackage[hidelinks=true]{hyperref}
\usepackage[T1]{fontenc}

You probably know what most of these do. The geometry settings used here work well for symmetrical layouts. For asymmetrical layouts I like to use 2cm/6cm for inner/outer. That way I can put footnotes and pictures in the margins.

Microtype

\usepackage[activate={true,nocompatibility},final=true,kerning=true,spacing=true,tracking=true,shrink=30,stretch=30,factor=0]{microtype}
\microtypecontext{spacing=french}

Apart from the standard packages above, the microtype package is the single most important package in existence and should be included in every document. It does a number of things:

Fonts

I don’t have a huge problem with Computer Modern, but (1) it is overused, and (2) since it’s the default, most typographic sins are committed with Computer Modern, so I sometimes get a bad feeling about it (like with Times).

These are some acceptable fonts:

Palatino

\usepackage[osf,sc]{mathpazo}

Palatino is like the Times New Roman of pretty fonts. It’s like everyone who’s unsatisfied with Times goes through their system fonts and says, “oh, that looks fancy!” and chooses Palatino. This means it comes close to being overused, but it still looks good enough that you can use it without feeling bad. Also, the mathpazo package offers real small caps (sc), oldstyle numerals (osf), and most of the mathematical symbols you will ever need.

It also works well with Euler math if you’re into that kind of thing.

\usepackage{euler}

The Johannes Kepler Project

\usepackage[oldstylenums]{kpfonts}

I’ve not used this font yet but, apart from the capital T, I like the look of it. Like Palatino, Kepler offers real oldstyle figures, real small caps, and extensive math support. There is also a sans serif version of Kepler that you might want to use in combination with the serif version, but I haven’t looked at that, so it might suck.

If you’re inclined to save ink, Kepler also has a light option.2

A note on numerals

In normal text, you want to use oldstyle figures3 (lowercase numbers). You only want to use lining figures (uppercase numbers) in combination with all caps, in mathematical expressions, or in tables. With the settings I’ve described above, Palatino and Kepler will automatically switch to lining figures in math mode. If you want to set all the numbers in a block as lining figures, you can place

\fontfamily{pplx}\selectfont

for Palatino, and

\fontfamily{jkpx}\selectfont

for Kepler at the beginning of the block.

Spacing

\usepackage{setspace}
\setstretch{1.1}
\setlength{\parskip}{0pt}
\setlength{\parindent}{1.4em}

The default line spacing (\setstretch) is usually too narrow. For most texts, a setting of 1.1 looks good, for very math-heavy or German texts I go up to 1.14 to avoid collisions between ascenders, descenders, accented mathematical symbols, etc.

I prefer indented paragraphs to vertically spaced paragraphs. If you like vertical space between your paragraphs, set \parindent to 0; if you like indented paragraphs, set \parskip to 0. Otherwise LaTeX may add spacing between paragraphs, which will look hideous if the paragraphs are indented.

Colors

To define colors:

\usepackage{color}
\definecolor{color-name}{gray}{0.8}
\definecolor{other-color}{rgb}{0.8, 0.9, 1}

To use colors:

\color{color-name}

Tables

\usepackage{booktabs,suinitx}

\begin{table}[htb]\fontfamily{pplx}\selectfont
\begin{center}
    \begin{tabular}{lrcS[table-format=1.1]}
    \toprule%
    left & right & centered & \multicolumn{1}{c}{aligned numbers}\\\midrule{}
    1 & 2 & 3 & 4.5 \\
    \bottomrule{}
    \end{tabular}
    \caption{Description}
    \label{tab:label}
\end{center}
\end{table}

The S alignment option aligns numbers by their decimal point. Because the column title isn’t a number, it needs to be wrapped inside the weird \multicolumn command. The [table-format=x.y] aligns the column in a way that numbers with x digits to the left and y digits to the right of the decimal point are centered. You can omit this option if everything looks fine, but it’s useful as soon as you have different numbers of digits in each row.

If you use S, the numbers will be set in math-mode, so they will automatically be lining figures. If you use l, r, or c, you will have to declare the \fontfamily at the top of the table to get them to look right.

Colored cells

Include the package

\usepackage{colortbl}

and call

\cellcolor{color-name}

inside your table-cell. The cell coloring doesn’t go all the way to horizontal rules, making the coloring discontinuous. That looks weird when you want to have entire columns in one color. I haven’t figured out how to prevent that.

Table with colored cells.

Prettier unordered lists

\newcommand{\sbt}{\,\begin{picture}(-1,1)(-1,-3)\circle*{2.2}\end{picture}\ }
\renewcommand{\labelitemi}{\sbt}
\renewcommand{\labelitemii}{\sbt}

The bullet character (•) is too large. To get better looking bulleted lists, this snipped works wonders. You can manipulate the size of the circle by changing the 2.2 above to something else. If you need more than two levels in your lists, you can duplicate the last line and change \labelitemii to \labelitemiii.

Prettier ordered lists

\usepackage{enumerate}

\begin{enumerate}[1]
\item Item One
\item Item Two
\end{enumerate}

Make numbered lists less cluttered.

Better lists

Headers and footers

If you’re using the book document class, never ever use the default headers. I don’t know whose idea it was to make the headers ITALIC ALL CAPS, but trust me, it was a terrible idea. This setting was surprisingly difficult to change, too.

\newcommand{\spacedlowsmallcaps}[1]{\lowercase{\textsc{#1}}}
\usepackage[automark]{scrpage2}
\clearscrheadings
\renewcommand{\chaptermark}[1]{\markboth{\spacedlowsmallcaps{#1}}{\spacedlowsmallcaps{#1}}}
    \renewcommand{\sectionmark}[1]{\markright{\thesection\enspace\spacedlowsmallcaps{#1}}}
\lehead{\mbox{\llap{\small\thepage\kern2em}\hfil{\headmark}}}
\rohead{\mbox{\hfil{\headmark}\rlap{\small\kern2em\thepage}}}
\renewcommand{\headfont}{\small}

I don’t even want to look at those settings.

Example headers

You can take this as inspiration and go from there.

Chapter and section headings + spacing

\usepackage{titlesec}

\newfont{\chapterNumber}{eurb10 scaled 7000}

\titleformat{\chapter}[display]%
{\relax}{\mbox{}\marginpar{\vspace*{-\baselineskip}\color{chapternumbergray}\chapterNumber\thechapter}}{0pt}%
    {\LARGE\itshape}[\normalsize\vspace*{.8\baselineskip}\titlerule]%

\titlespacing*{\chapter}{0pt}{0cm}{1cm}
\titleformat{\section}{\Large}{\makebox[0cm][r]{\thesection\hspace{1em}}}{0em}{\scshape\lowercase}
\titlespacing*{\section}{0pt}{\baselineskip}{\baselineskip}
\titleformat{\subsection}{\large}{\thesubsection}{.6em}{\itshape}
\titlespacing*{\subsection}{0pt}{\baselineskip}{\baselineskip}
\titleformat{\subsubsection}{\bfseries}{}{}{}
\titlespacing*{\subsubsection}{0pt}{\baselineskip}{\baselineskip}

Headings

These settings are strongly inspired by Robert Bringhurst’s The Elements of Typographic Style. The chapter numbers are set in the Euler font.

Custom table of contents

\usepackage{tocloft}
\usepackage{textcase}
\setcounter{tocdepth}{2}

Chapters:

\renewcommand{\cftchappresnum}{\bfseries}
\renewcommand{\cftchapfont}{\normalfont}
\renewcommand{\cftchappagefont}{\color{pagenumbergray}\normalfont}
\renewcommand{\cftchapleader}{\hspace{1.5em}}
\renewcommand{\cftchapafterpnum}{\cftparfillskip}

Sections:

\renewcommand{\cftsecpresnum}{\scshape}
\renewcommand{\cftsecfont}{\normalfont}
\renewcommand{\cftsecpagefont}{\color{pagenumbergray}\normalfont}
\renewcommand{\cftsecleader}{\hspace{1.5em}}
\renewcommand{\cftsecafterpnum}{\cftparfillskip}

Subsections:

\renewcommand{\cftsubsecpresnum}{\scshape}
\renewcommand{\cftsubsecfont}{\normalfont}
\renewcommand{\cftsubsecpagefont}{\color{pagenumbergray}\normalfont}
\renewcommand{\cftsubsecleader}{\hspace{1.5em}}
\renewcommand{\cftsubsecafterpnum}{\cftparfillskip}

This is in part influenced by Bringhurst and in part by common sense. Most tables of content are typeset terribly.

Title page

An example for a title page. The contents of this will depend very strongly on the specific document you’re making.

\begin{titlepage}
\begin{center}
{\LARGE University Name}\\
\begin{figure}[h]
\hbox{}\hfill
    \begin{minipage}[t]{10cm}
    \begin{center}
        \includegraphics[width=5cm]{university-logo}
    \end{center}
    \end{minipage}
\hfill\hbox{}
\end{figure}
{\large Department or something\\[2cm]}
{\huge Bachelor's Thesis\\[1cm]}
{\Large\bf Title\\[1.0cm]}
{\small Author:}\\[0.2cm] {\large Author}\\[0.2cm]
{\small date}\\[0.8cm] {\small Advisor:}\\[0.2cm]
{\large Advisor name}\\[0.2cm]
Advisor's employer\\[2.2cm]
{\small Address}
\end{center}
\end{titlepage}

Figures

Regular floating figures

\begin{figure}[tbh]
\centering
\includegraphics[width=8cm]{bunnies.jpg}
\caption{A normal figure.}
\label{fig:normal}
\end{figure}

Sometimes you want to put a p in the position options, too.

Margin figures

\marginpar{ %
    \includegraphics[width=\marginparwidth]{picture}%
    \captionof{figure}{A margin figure.}%
    \label{fig:marginfig}%
}

For best results, use \raggedright or \RaggedRight.

Footnotes as margin notes

\usepackage{ragged2e}

\newcounter{mnote}
\renewcommand{\footnote}[1]{ %
    \refstepcounter{mnote}%
    \mbox{\textsuperscript{\themnote}}%
    \marginpar{\footnotesize\RaggedRight\mbox{\themnote}\hspace{5pt}#1}%
}

You can call these with \footnote. If you need to move the content of the footnote up along the margin, use

\newcommand{\fnhere}[1]{\refstepcounter{mnote}\marginpar{\footnotesize\RaggedRight\mbox{\themnote}\hspace{5pt}#1}}
\newcommand{\fnref}{\mbox{\textsuperscript{\themnote}}}

Then you can call \fnhere{Footnote content} where you want the note to appear in the margin and \fnref{} where you want the reference to appear in the text. This is only for moving footnotes up. They should move down automatically, if there are other \marginpars in the way.

\raggedright makes the text left-aligned, which looks better because margins are usually too narrow for proper justified text. \RaggedRight requires the ragged2e package and will re-enable hyphenation for the left-aligned text.

Some symbols

Some symbols I sometimes forget.

Kerning

a\kern+1ptb

This adds 1pt of separation between the letters a and b. When I have the time, I use this extensively for adding space to the insides of paretheses since they’re set too tight in most fonts. Also works in math mode.

Colored boxes

I rarely use these because I always run into problems. But it can be kinda pretty and you can probably fix the issues if your document isn’t too complex.

\definecolor{boxblue}{rgb}{0.8, 0.9, 1}

\usepackage[framemethod=tikz]{mdframed}
\newmdenv[innerlinewidth=0.5pt,roundcorner=2pt,backgroundcolor=boxblue, linecolor=boxblue,innerleftmargin=6mm,innerrightmargin=6mm,innertopmargin=6pt,innerbottommargin=6pt,skipabove=1ex,skipbelow=1ex]{mybox}

You use this with

\begin{mybox}
Content
\end{mybox}

Colored boxes

Prettier ellipsis

\newcommand{\dotdot}{.\hspace{.6pt}.\hspace{.6pt}.}

The normal \ldots{} command creates too much space between the dots and, even with french spacing turned on, the amounts of space to the left and right of the ellipsis aren’t the same, so it looks uneven. You may need to adjust the amount of \hspace, depending on the font.

Comparison:

Comparison between \ldots and \dotdot

Only numbering certain lines of an align environment

\begin{align}
  1 + 2 &= a\nonumber\\
  3 + 4 &= b \cdot e^{2\tau}\nonumber\\
  6 + 1 &= c
\end{align}

Only the third line has a number

What I haven’t figured out yet

Footnotes

  1. From Practical Typography:

    Lowercase letters don’t ordinarily need letterspacing. Nor do capital letters when they appear at the beginning of a word or sentence, because they’re designed to fit correctly next to lowercase letters. But when you use capital letters together, that spacing looks too tight.

    That’s why you always add 5–12% extra letterspacing to text in all caps or small caps, particularly at small sizes.

  2. From the documentation:

    Save up your toner and the environment, use the “light” option, it’s 20% toner less!

    The metrics are the same. The display is not very good, but the print is fine if you like light fonts.

  3. I never know which word to use. “Numerals”? “Figures”? “Numbers”? And then I just end up using them all interchangeably and it’s terrible.

Observations

27 May 2015

438 words

Observations:

I’m curious to see how this develops.

How not to design a watch

17 May 2015

395 words

[This gets kinda rant-y. Don’t worry though, it’s not about the Watch.]

I found it irritating that I had to adjust the time on my wristwatch twice every year because of DST, so I bought a radio controlled watch that would do this automatically, and it’s working fantastically: Now I don’t even notice when DST starts or ends. Except when I stop and ask myself why I’m feeling so tired all of a sudden – but that’s beside the point. Here’s the thing:

Every 24 hours, the watch stops for around 20 seconds to look for a signal and reset itself to the correct time. This is good, of course. Otherwise the watch wouldn’t know when DST starts or ends, and it would all be for naught. And besides, you don’t need the second-hand most of the time anyway.

The watch.
The watch.

Still, it would be good to put the reset time at some point when most people don’t look at their watches. “How about at night?” one engineer probably said. “What a fantastic idea!” another exclaimed, “People sleep at night!” And they went forth and set the reset time to midnight. Of course things aren’t always accurate, so my watch stops every night at around 2–3 seconds before midnight.

There are not many times at which I need a sort of accurate second-hand, but the last few seconds before midnight are practically the worst time I can imagine for an interruption to happen. First of all, I would assume that a lot more people are asleep at, like, 3 AM than at midnight, and second of all, midnight is like the number one Schelling Point for things to count down to. Think birthdays or New Year’s. Nino is like, “You guys, I got this. I have an accurate watch.” And then everyone is like, “yeah, ok,” and then they say “10 … 9 … 8 …” and when they’re at “3” the watch stops and Nino is confused and the others keep counting, and this is not okay.

Why couldn’t they make the watch reset at 10 seconds after midnight? Or at 2 or 3 AM?

I have a feeling that this wasn’t super well thought through.

Reaching the goal is not an action

29 March 2015

814 words

[This was difficult to write in a way that makes sense to someone who doesn’t live inside my brain and I don’t know if I succeeded. I’d be curious to know if this makes any sense at all to anyone who is not me.]

Nate Soares writes

When I have a big problem that I want solved, I have found that there is one simple process which tends to work. It goes like this:

  1. Move towards the goal.

What I’m about to write is kind of part of what his post is about, but it adds a layer of framing that has allowed me to feel virtually no anxiety about the future for almost a week now, which is extremely unusual for me. I wanted to share my thoughts in case anyone finds them useful.

So I know what the goal is and I’ve figured out the next action that will move me closer to success. At this point everything is fine, but as soon as I look into the future and try to visualize the transition from the current state to the state of having reached the goal my mind tells me there’s some mysterious huge task that still needs to be completed – one that feels unlike any “next action” I can take along the way. Like all the next actions are just preparation, and the actual accomplishing of the goal is different – something I have no idea how to do because I’ve never done anything like it before.

This probably sounds vague, so here’s an example.

Say I want to make friends. I’ve made friends before, I have some memory of what I did prior to calling the relationship a friendship – talk to the person, maybe make a joke or two, don’t be a huge dick, don’t complain about their improper use of hyphens as dashes, that sort of thing. And then at some point: bam!, friendship. So I say to my brain, “brain,” I say, “let’s go talk to people.” And my brain says, “okay, but then what?” – “Then we can become friends.” – “But how does the actual becoming-friends work? You only know how to talk to them. You don’t know how to create a friendship. If you can’t figure that out we might as well not try at all.” And so I stay silent.

There are many other situations where I feel like this. When I’m trying to study, for example, a good next action might be to do one of the homework problems. And my brain tells me, “yeah, you can do this now, but have you looked at what’s still in front of you? You still have to work through this whole textbook and do all those exercises and pass those two exams and do you really think you can do all this? Those are really big tasks and you’re just a small, not particularly impressive person.” So I start worrying, which makes me unable to focus on the work I have to do now, which makes me fail later.

But fortunately, for once, the truth is more pleasant than what my intuition tells me: There are no big mysterious tasks you need to complete in order to reach your goals. Once you completed all the challenges that stand in the way of success, you have reached the goal. Everything you will ever need to do is find the next thing to do and do that in this moment. When you have done that, reaching the goal is not another task but a consequence that happens on its own.

And in the meantime, there are never any tasks too big for you to handle. You won’t need to study for three years, you won’t need to prepare that exam, you won’t need to write a whole novel, you won’t need to create a friendship out of thin air. All you need to do is look at one homework problem, read one more sentence in the textbook, type another key on your keyboard, say another word to someone you like.

Sure, from your current perspective you can see big tasks ahead, but you won’t exist anymore by the time those become the next action. Those tasks will be handled by the millions of consecutive future-you’s, all working on their own next action for the infinitesimal amount of time they exist and letting the next one continue.

Thinking about my goals this way helped me worry less about not knowing how to solve big problems and not being sure whether I will succeed in the end. Instead I can now focus on right now, and let “someone else” take care of the rest.

I have an excellent awkwardness memory

22 March 2015

334 words

People always tell me not to worry so much about seeming awkward in social situations. Like, “oh, nobody is ever going to remember you being weird or stuttery or that time where you didn’t know what to say, or said something wrong, or mispronounced something. They’re all just as caught up with thinking about their own awkwardness that they don’t even notice you’re being weird as well.”

And then I think, that makes sense, because I do spend a lot of time worrying about how I myself come across. And it’s good to keep in mind that other people probably do the same, because I tend to forget that other people are human as well and have emotions and issues themselves. (I think this is like a reverse typical mind fallacy. Does that already exist? If it doesn’t, we could call it the atypical mind fallacy.)

But when I think about it more, I realize that I am exceedingly good at detecting when other people might feel awkward – or, rather, when other people are in situations where I would feel awkward. And I always remember that. You know, that time when you were asked something by the teacher and you didn’t know the answer and looked really shameful and started blushing furiously and tried to force some words out, but you just didn’t know which ones and you were probably thinking, “Fuck, I should know this!” Or that time you were talking to a person at a party and you heard something wrong and replied something weird; chances are, I’ll obsess about your situations just as much as I would if it’d been me in the situation. And I’ll spend hours thinking what could you have done differently to avoid this?

So now I’m wondering: Is this whole “nobody notices/remembers how awkward you are”-thing all a big lie that therapists tell to calm me down, or do I just have an especially good awkwardness memory?