# Floating minipages and other wizardry

Inspired by a current issue from my friend the LaTeX Noob, I wanted to give a short explanation on how you can combine floats (i.e. figures) and minipages. Why should you care? Well, if you need tikzpicture or images placed besides eachother or beside text. So most people will probably need this at some point 😉 A great resource is the WikiBook, as always. If you want the lengthy account – that’s the way to go. For everybody else, an explanation of my own.

## Floats and non-floating boxes

### What are floats?

Some fundamental explanations first: A figure is a float. A minipage is not a float but a box which sits at its fixed place. These are two fundamentally different things. When you combine them in a bad way, LaTeX might get fed up at this. So when planning your minipaging or floating situation, ask yourself which effects are really important to you and which aren’t.

### Do I even need a float?

A float will self-regulate positioning pretty much. If you need this feature, you need a float. But maybe this is a behaviour you explicitly don’t want anyway. Then maybe you don’t even need a float at all. Beginners often get confused and think they need to use figures everywhere but, strictly speaking, you don’t. You can, for example, just \includegraphics without a figure. Then the thing will just not have floating behaviour and you also might want captions and stuff, so an environment might be in order. But this need not be a figure. But if you don’t want all this, be aware that you might not need a figure at all and save yourself some trouble debugging.

I would suggest you probably go for figures anyway if it’s a long document where positioning might change dramatically after you first insert the picture, minipage or whatever. If, however, your result is pretty static and not a pages long document, you might just be better off leaving out the floats completely. Like, for example, in a poster, positioning isn’t really up for LaTeX to decide. You need it placed in a stable, reliable way and the way you want it and you exert lots of ‘control’ over the whole process.

Floats are better if you are dealing with a thing whose behaviour LaTeX is supposed to regulate acccording to its own best judgement. And as we all know, LaTeX’s judgement is pretty awesome. So this is a feature you might very well want to profit from in most cases. Also, you might want a \listoffigures. Or not. So think about that.

## A little rant on “LaTeX is not doing what I want”

Beginners often get fed up with this behaviour because “LaTeX is not doing what I want”. This is probably due to the fact that you are using structures you think are supposed to do XYZ while they actually are programmed to do ABC. This is just a ‘misunderstanding’ between LaTeX and the user and can be remedied by additional knowledge about how some things work internally. So a general good bit of advice would be to look up how a structure you are trying to use is programmed to work internally. Most of the time, looking up the official documentation will already suffice. Probably it is supposed to do something completely different than what you thought it was or wanted it to. This is not LaTeX’s fault. It’s the fault of the user who doesn’t bother to look up those basic functionalities, so don’t blame LaTeX. But of course, if you’re still a beginner, this is a normal thing to do or expect. A common false assumption among programming novices. So don’t worry either. Next time you will know what to do.

A computer will do what you wrote down. Not what you meant. Even and especially, if the two are not the same thing 😉

## The objective: placing things side by side

We will follow up with some examples of figures and minipages. By now, you are already informed what the differences are and can make an intelligent choice 😉

### Case 1: The figure placed right here

The following is just a figure, but it will be forced to be placed right here (as indicated per the H). Using a small h really only means ‘here if it fits’. Only h! or H actually mean HERE!!!Also, read this great (lenghty) information on floats if you want to know more. Don’t forget to \usepackage{float} if you want to use the H. Edit: Thanks to Karl from LaTeX ref who informed me that h! basically only sometimes accidentally results in “place it HERE”. Use H for reliability.

So depending on your other needs (\listoffigures, etc.), you might as well have not used a floating environment since obviously, you did not intend for the thing to float.

\begin{figure}[H]
\centering
\begin{tikzpicture}
\basesketch\bfseries
\angles
\end{tikzpicture}
\caption{Sketch}
\label{fig:Sketch}
\end{figure}



### Case 2: Figure beside text with wrapfigure

The same thing like with minipage, basically, can be achieved with a wrapfigure, which you might need at some point too. This will make an image float beside text. On this, read the Overleaf tutorial.


\begin{wrapfigure}{R}{0.3\textwidth}
\centering
\begin{tikzpicture}[opacity=0.8, scale=0.5]
\basesketch \angles
\filldraw[draw=black, fill=lila, fill opacity=0.3] (A) -- (B) -- (C) -- cycle;
\filldraw[draw=black, fill=myblue, fill opacity=0.3] (A) -- (C) -- (K2) -- (K1) -- cycle;
\end{tikzpicture}
\caption{T\textsubscript{1} und T\textsubscript{2}}
\label{fig:Triangles}
\end{wrapfigure}



## Case 3: lifesaving minipages

First, I’ll explain the basic functionality of minipages and then issue some personal tips on how to use them 😉

#### Options

As you might have noticed, you have options when configuring your minipage: \begin{minipage}[adjusting]{width of the minipage} are the available ones. Meaning minipage has a specified alignment and a predetermined width. Although, you can use relative widths, of course. So it can be {3cm} or {0.3\textwidth} according to your needs. Notice however, that you cannot use 100% textwidth in total while still having everything aligned. Take off 0.03 in total to be sure. So all your minipages which are placed side by side cannot take up a total of 100% of the textwidth.

c = center, t = top and b = bottom are the alignment choices. c is default, I mostly use t. It can be a bit difficult to grasp what they actually do. They specify at which line the content gets aligned. So t means, the alignment will be oriented on the topmost, so the highest line.

Also, we can add more options [t][3cm][b] which additionally says that we have a fixed height of 3cm and the content will be aligned at the bottom. The (multiple) minipages themselves will be aligned at their tops.

#### Alignment of multiple minipages

Also, if you want multiple minipages aligned at their sides and not below eachother, you can’t have blank lines between them. Inside the minipage environments is no problem, but not following the first one before the second one, for example. See also Sasha Frank’s page and this.

When you check StackOverflow “How to use a figure inside a minipage” – the short answer is: You don’t!


\begin{figure}[ht]
\begin{minipage}[b]{0.45\textwidth}
\centering
\includegraphics[width=\textwidth]{img1}
\caption{blabla}
\label{fig:fig1}
\end{minipage}
\hspace{0.5cm}
\begin{minipage}[b]{0.4\textwidth}
\centering
\includegraphics[width=\textwidth]{img2}
\caption{mycaption}
\label{fig:fig2}
\end{minipage}
\end{figure}


If you want to make two floats happily float, but in a row beside eachother, you can use the floatrow package, as detailed in this StackOverflow post.

#### Do I need a float now or what? Combining figure and minipage

If you don’t insist on having a float, people would probably go for minipage to make things sit aligned besides eachother and connected.

It is also not necessary to place your \includegraphics inside a figure, though a lot of beginners think so. Just put your images directly in a minipage if you don’t need floating behaviour. If you do – add a float. But not inside the minipage, this will cause an error. If you are confused about this, imagine a rubber duck floating in your bathtub. You cannot place it into a box because then it will sink. You can, however, make it carry a box on its back. So, this is basically the same thing with floats an minipages 😉

You cannot have a figure (=float) inside a minipage (non-floating box) since it will make the rubber duck sink. Don’t sink your rubber duck! Read up on it here (just to warn you, they don’t use rubber ducks for explanation, so don’t be disappointed).

And, by the way, it also doesn’t make sense to have float inside a fixed box. Float means, LaTeX decides where exactly to place elements. But if you put a fixed box, you have already made that decision. Nothing left for LaTeX to decide. Meaning LaTeX will go and sulk at you. If you need LaTeX to calculate where to put things and it is possible your document will change a lot, it’s better to use floats. If you want everything exactly where you want it, float will make you go crazy. You can put tikzpicture inside minipages. It’s confusing, I know.

And remember: If you don’t want the minipages to become “disconnected”, which is usually the case, make sure you don’t put an empty line after one of them. They should be “connected” in the code if you want them connected in the output.

Another example (snippet) from my personal CV template to visualize language skills. As you can see, you might be able to achieve what you want using a tabular as well.

This is how the code looks like:


\newcommand{\icon}[3]{\phantom{x}{#3\color{#2}#1}\phantom{x}}
%------------------- pictogram Fraction: pictoFraction
\newcommand{\pictofraction}[6]{%
\pgfmathparse{#3 - 1}\foreach \n in {0,...,\pgfma&amp;amp;amp;amp;amp;amp;lt;span 				data-mce-type="bookmark" 				id="mce_SELREST_start" 				data-mce-style="overflow:hidden;line-height:0" 				style="overflow:hidden;line-height:0" 			&amp;amp;amp;amp;amp;amp;gt;&amp;amp;amp;amp;amp;amp;lt;/span&amp;amp;amp;amp;amp;amp;gt;thresult}{\icon{#1}{#2}{#6}}%
\pgfmathparse{#5 - 1}\foreach \n in {0,...,\pgfmathresult}{\icon{#1}{#4}{#6}}%
}

\begin{minipage}[t]{\leftcolwidth}
\begin{tabular}{l | ll}
\textbf{German} &amp;amp;amp;amp;amp;amp;amp; C2 &amp;amp;amp;amp;amp;amp;amp; {\phantom{x}\footnotesize mother tongue} \\
\textbf{English} &amp;amp;amp;amp;amp;amp;amp; C2 &amp;amp;amp;amp;amp;amp;amp; \pictofraction{\faCircle}{blue}{3}{blue}{1}{\tiny}\\
\textbf{Latin}  &amp;amp;amp;amp;amp;amp;amp; C2 &amp;amp;amp;amp;amp;amp;amp; \pictofraction{\faCircle}{blue}{3}{blue}{1}{\tiny}\\
\textbf{French} &amp;amp;amp;amp;amp;amp;amp; C2 &amp;amp;amp;amp;amp;amp;amp; \pictofraction{\faCircle}{blue}{3}{blue}{1}{\tiny}\\
\textbf{Ancient Greek} &amp;amp;amp;amp;amp;amp;amp; B2 &amp;amp;amp;amp;amp;amp;amp; \pictofraction{\faCircle}{blue}{3}{grey!30}{1}{\tiny}\\

\end{tabular}
\end{minipage}


There also is the subcaption package (subfigure or subfig are deprecated). Here, you can use sub-floats inside a single float. Here is an example of how to use it.

You can also put minipages inside a float, to make the whole thing float again. And that’s about it 😉

And just for your reference, I included the actual TikZ at the bottom of the post. Just in case you wanted it or whatever 😉

I really love minipages. They are my go-to thing for anything and everything. Sometimes even when there probably would be another (better) option available. Minipages rock! And so do you!

Best,

the LaTeX Ninja

## The TikZ

\newcommand{\basesketch}{%
\scriptsize
\node[](Kreismittelpunkt) at (0,0) {};
\node[](K1) at (0,6) {};
\node[](K2) at (4,5) {};

\draw[] (Kreismittelpunkt) -- ++(0:5cm) node[](C){} -- ++(0:5cm) node[](K2){};
\draw[] (Kreismittelpunkt) -- ++(30:4cm)  node[](A){}  --  ++(30:2cm)  node[](B){}  -- ++(30:4cm) node[](K1){};
\draw[] (K2) -- (K1);
\draw[fill=myblue] (K2) circle (2.5pt) node[below=0.5em]{K\textsubscript{2}};
\draw[fill=myblue] (K1) circle (2.5pt) node[above=0.5em]{K\textsubscript{1}};

\draw[fill=myblue] (A) circle (2.5pt) node[above=0.5em]{A};
\draw[fill=myblue] (B) circle (2.5pt) node[above=0.5em]{B};
\draw[fill=myblue] (C) circle (2.5pt) node[below=0.5em]{C};
\draw[] (A) -- (C);
\draw[] (C) -- (B);
\draw[] (B) -- (K2);

% coordinates
\coordinate (K2) at (K2);
\coordinate (K1) at (K1);
\coordinate (A) at (A);
\coordinate (B) at (B);
\coordinate (C) at (C);

\draw[fill=myblue] (Kreismittelpunkt) circle (2.5pt) node[below=0.5em]{K};

% Alternative zu Arc zwischen zwei Punkten
\draw[-,draw=black!70] (K2) to[bend right=12] (K1);
\pgfresetboundingbox}

\newcommand{\angles}{%
\pic[draw=black!70,text=black!70, -,"$\alpha$"] {angle =A--C--Kreismittelpunkt};
\pic[draw=black!70,text=black!70, -,"$\delta$", angle eccentricity=1.3] {angle= B--C--A};
\pic[draw=black!70,text=black!70, -,"$\alpha$"] {angle = K2--C--B};
\pic[draw=black!70,text=black!70, -,"$\alpha$"] {angle = C--B--K2};

\pic[draw=black!70,text=black!70, -,"$\beta$"] {angle = A--B--C};
\pic[draw=black!70,text=black!70, -,"$\beta$"] {angle = K2--B--K1};

\pic[draw=black!70,text=black!70, -,"$\gamma$"] {angle = K1--K2--C};
\pic[draw=black!70,text=black!70, -,"$\gamma$"] {angle = B--K1--K2};

\pic ["\Huge $\cdot$", draw, -] {angle=C--A--B};
\pic ["\Huge $\cdot$", draw, -] {angle=Kreismittelpunkt--A--C};}



If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

# XML to LaTeX (simple)

Today, I wanted to share this super simple XML to LaTeX tutorial. Using XSLT, you are going to transform XML data to LaTeX output which you can then go on to compile into your desired output PDF. There will be no fancy stuff whatsoever in this post, just the basics and what to keep in mind with these transformations. It is the quick intro to XML to LaTeX I did with my students a while ago which was done one day after they had their first contact with XSLT, so it should really be beginner-friendly. I labeled it “Advanced LaTeX” anyway because I think starting to automate things is always a step in the right direction 😉

## Configuring the transformation scenario in Oxygen

I am going to assume you use Oxygen now because that’s what a lot of people in the DH do and this post is directed towards my friends in the DH. Especially those who think print editions are an obsolete concept in times of the Digital Edition. Maybe having a nice little intro to XML to LaTeX transformations available will change their minds 😉

To set up the transformation scenario, choose XML transformation using XSLT, then choose your XML document and your XSL stylesheet (set up and open those document in the editor before you configure the scenario). Then choose a Saxon 9 version (whichever you like). Then ignore the FO tab and get right to the output tab.

Here you configure how to name your output. Best click the green arrow and choose cfn, then append -latex.tex. So the result the current filename with -latex.tex appended to it. This is an important step so you don’t accidentally overwrite the original. Which in this case is not so dramatic since it has a different ending anyway but if you do XML to XML transformations, this is even more crucial. Then tell Oxygen to show it in the editor as XML (even though you know it isn’t). The editor will then, of course, complain about the non-valid XML but don’t worry. Just copy all (CTRL+ACTRL+C) and paste it (CTRL+V) into a completely empty (!) project in Overleaf  or just compile the LaTeX directly if you have it installed on your machine.

There it is, you’re set. Now let’s get to the stylesheet.

## The stylesheet

So, this is the whole thing. You can just grab it and go if you don’t care for the explanation or read on to find out why things were done the way they were done. This tutorial assumes you’re already familiar with how XSLT works, just haven’t done transformations to LaTeX yet, by the way. I am also assuming, your base XML is in the TEI standard.

<?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"     xmlns:xs="http://www.w3.org/2001/XMLSchema"     xmlns:t="http://www.tei-c.org/ns/1.0"     exclude-result-prefixes="xs"     version="2.0">
<xsl:strip-space elements="*"/>
<xsl:output method="text" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>

<xsl:template match="/">
<xsl:text>\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[english]{babel}
\DeclareUnicodeCharacter{2060}{\nolinebreak} % might not be necessary for you

\title{</xsl:text><xsl:apply-templates select="//t:title"/>
<xsl:text>}
\author{</xsl:text><xsl:apply-templates select="//t:author"/>
<xsl:text>}\date{\today}
\begin{document}
\maketitle
\tableofcontents\newpage</xsl:text>
<xsl:text>\begin{itemize}</xsl:text>
<xsl:text>\item </xsl:text>
<xsl:value-of select="." />
<xsl:text>

</xsl:text>
</xsl:for-each>
<xsl:text>\end{itemize}
\newpage</xsl:text>

<!--  <xsl:apply-templates/> OR -->
<xsl:apply-templates select="//t:text"/>
<!-- just use the pull paradigm on the TEI body so you don't get a meaningless TEI header dump in your document -->

<xsl:text>\end{document}</xsl:text>
</xsl:template>

<xsl:text>\section{</xsl:text><xsl:apply-templates/><xsl:text>} </xsl:text>
</xsl:template>

<xsl:template match="t:p">
<xsl:apply-templates/>
<xsl:text>

</xsl:text>
</xsl:template>

<xsl:template match="t:hi">
<xsl:text>\emph{</xsl:text><xsl:apply-templates/><xsl:text>} </xsl:text>
</xsl:template>

<xsl:template match="text()">
<xsl:analyze-string select="." regex="([&amp;])|([_])|([$])"> <xsl:matching-substring> <xsl:choose> <xsl:when test="regex-group(1)"> <xsl:text>\&amp;</xsl:text> </xsl:when> <xsl:when test="regex-group(2)"> <xsl:text>\_</xsl:text> </xsl:when> <xsl:when test="regex-group(3)"> <xsl:text>\$</xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>

</xsl:stylesheet>


### The XSLT declaration and the LaTeX preamble

Put the following after your XML declaration. This will ensure output is LaTeX-friendly.

<xsl:strip-space elements="*"/> <!-- for LaTeX -->
<xsl:output method="text" encoding="UTF-8" indent="no" omit-xml-declaration="yes"/>


\DeclareUnicodeCharacter{2060}{\nolinebreak} was added because LaTeX complained about an undefined character in some of my students XML data. Personally, I had never gotten this error before, so you might as well leave it out.

### Creating environments

As we had just learnt some XSLT basics, I wanted the students to use at least one push and one pull paradigm type template. So the task was to process any element from the TEI header using the push paradigm and then a pull paradigm template for the body. To make this little template more efficient teaching-wise, I decided to introduce how to create a LaTeX environment using XSLT for the TEI Header / push paradigm and do at least one other command using the pull paradigm on the TEI body. Also this demonstrates as opposed to for the body.

So this next piece of code sets up an itemize environment for persons present in the header. In a “real” stylesheet, it would probably be more wise to check, using whether there is one potential element like that present and only paste the \begin and \end on that condition.

Also, as you might have noticed, all the LaTeX commands are inside . This looks a bit confusing at first but really isn’t. Just make sure you don’t create invalid XSLT by shuffling them around.

<xsl:text>\begin{itemize}</xsl:text>
<xsl:text>\item </xsl:text>
<xsl:value-of select="." />
<xsl:text>

</xsl:text>
</xsl:for-each>
<xsl:text>\end{itemize}</xsl:text>


When creating simple commands using the pull paradigm, be sure that you don’t end up with too many “overlaps” since “simple” commands in LaTeX don’t take multiple paragraphs as arguments. If in doubt, always use environment and the global switches (like \bfseries). Since you are automating things, you always have to take into account that data might not always be marked-up in a way which makes sense to you. There can easily be linebreaks inside a single italic highlight. If this is the case in you data, better create an environment. For simple purposes, however, this is good enough:


<xsl:template match="t:hi"><xsl:text>
\emph{</xsl:text><xsl:apply-templates/><xsl:text>} <xsl:text></xsl:template>


With these commands (and genereally when transforming to LaTeX), you sometimes need to make sure you don’t involuntarily add spaces or lack space which will make the output hard to read and debug.

In this example, I made sure not to add any whitespace inside the template rule and also did not have Oxygen format or indent the XML to avoid these unwanted spaces.

### And finally: Escaping entities

As you might remember, markup languages tend to use entities to escape certain characters. Bad thing is, LaTeX and XML use different entities. So we need to escape them. I know that the OxGarage standard stylesheet does this using the translate() function but I prefer to use since it’s less “messy” than a nested translate() construct.

Ah, and side info by the way: There is this standard stylesheet from the TEI consortium which might be of help if you are looking for inspiration. Since it is very generic, however, it might not be helpful if you are a newbie at both XSLT and LaTeX. The XSLT is pretty advanced and also the LaTeX probably uses some commands you might not be aware of.

    <xsl:template match="text()">
<xsl:analyze-string select="." regex="([&amp;])|([_])|([$])"> <xsl:matching-substring> <xsl:choose> <xsl:when test="regex-group(1)"> <xsl:text>\&amp;</xsl:text> </xsl:when> <xsl:when test="regex-group(2)"> <xsl:text>\_</xsl:text> </xsl:when> <xsl:when test="regex-group(3)"> <xsl:text>\$</xsl:text>
</xsl:when>
<xsl:otherwise/>
</xsl:choose>
</xsl:matching-substring>
<xsl:non-matching-substring>
<xsl:value-of select="." />
</xsl:non-matching-substring>
</xsl:analyze-string>
</xsl:template>


And that’s it. I hope this was useful to you.

Cheers,

the Ninja

If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

# A Humanities’ seminar paper with LaTeX – in 10 minutes

Don’t believe me when I claim you could write a whole seminar paper in 10 minutes? I wouldn’t either 😉 But I firmly believe you can learn how to write the next one in LaTeX in just ten minutes, so I prepared this pretty self-explanatory document. Everything is explained there, so I won’t ramble on about it here. The document is here on Overleaf. There you go.

Little side note, in case you are completely new to LaTeX. Like in the picture below, LaTeX has source code (on the left) and the compiled output PDF on the right. If you mess up the source code, there might not be any ouput. Using CTRL+S will cause the Overleaf editor to try and compile automatically. You can download the resulting PDF by clicking on the symbol beside the ‘recompile’ button. Overleaf also provides info on how to use Overleaf.

So, that’s it with a very short post for today. Watch out for the upcoming “(Why) Should I use LaTeX for my PhD thesis” post!

So long and thanks for all the fish!

The Ninja

If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

# Fast typing LaTeX

I recently became aware of this post where somebody asked how you can become faster at typing LaTeX. Just a little post with a few recommendations.

## Experience from constantly using LaTeX for everything

I have to say, I think it really gets better with experience. And experience from doing your everyday stuff in LaTeX (like to do lists, taking notes, etc.). Else you probably just won’t get enough experience to become really fast.

## Raise awareness

But then again, slowing down might not be a bad thing if you’re supposed to produce high quality work. Using LaTeX, then, will force you to take the subconscious back into your conscious mind. Maybe not what you want when just quickly taking notes, but maybe something to reflect upon in the long term.

I also found that, since I don’t constantly use MS Word’s auto-correct anymore, I’m actually better at spelling and grammar (even though, as someone holding a degree in Latin, I probably never was bad in the first place).

However, I find it useful that LaTeX forces you to be more conscious on some stuff (like typing correctly instead of bad touch typing and relying on auto-correct to clean up your mess).

## 10 finger system touch typing

Quick typing generally comes down to correct 10 finger system touch typing (Zehnfingersystem being the German name, focusing on the fact that  you use all your ten fingers, whereas the English name touch typing focuses on the fact that you type by muscle memory and don’t look at the keyboard). So if you don’t know that already, please stop complaining about LaTeX. You’re probably super slow and make tons of mistakes, so don’t pretend LaTeX plays a big part in slowing you down.

The free open-source Tipp10 app is a great resource for learning touch typing (available for all distributions, your Linux package mangager will probably have it) . Especially as you can use it to target LaTeX-specific typing effectively since the program allows you to use your own texts for typing practice. This means, if you want to get better at typing LaTeX, you should create a “fake” document which contains tons of the commands you use most often, then add it to the app as a custom practice text and practice for 5 minutes daily (ideally before starting work as a “warm-up“). You will get better very quickly. Here is an example text I created for this purpose. Feel free to add what you need or remove what you don’t need.

This is what I would recommend for now,

Cheers,

the LaTeX Ninja

If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

# The power of simplicity, or: How to use tutorials

This is just a quick post, telling you to use tutorials selectively. If you don’t have time, don’t burden yourself with the not-so-short intro to LaTeX or 30 min introductions. Jumpstart in 3 minutes and go.

This morning, I realized one thing: depending on what you want to do with LaTeX, you only need a very limited amount of commands. Even I use a very limited amout of commands for everyday tasks. Going through a whole tutorial might actually be a waste of time for you.

## You only need 3-5 go-to commands

What you always need (and, for example, an Overleaf blank document already supplies): You will typically need the general document setup (minimal example), \newpage, \maketitle, \tableofcontents, and \sections and \emph{}.

For teaching documents, I will additionally need \textbf{boldface}, enumerate and itemize environments. Then maybe \href{http://latex-ninja.com}{links} (\usepackage{hyperref}), \texttt{typeface} for code or the verbatim environment. And, of course, I often use my cheatsheet template.

For writing scientific articles, I will need bibliographic citation (biblatex), mostly using \footcite{} and \footnote{}. Then maybe sometimes the quote environment for longer quotes. Then a Pandoc conversion to .docx (see the post on how to quit MS Word).

But that’s basically it. The more complicated stuff I use only when I have real typesetting needs or do something overly visual. That’s how I managed to use LaTeX for 5+ years without going any deeper.

## The power of simplicity

What I want to say with this is: You don’t need to learn all the concepts to get started. You won’t be able to use all of them anyway. Only learn the ones you need right now to get going. Learn the rest as you go.

30 minute (or longer) introductions to LaTeX are great, but depending on your needs (especially if your a Humanities person who never uses any math or the like), you don’t need to go through complicated tutorials. Just starting  using LaTeX and add skills as you go.

LaTeX is supposed to have “a high learning curve” and take way more time than just using Word. People often say that if you’re not interested in typesetting technical stuff, there is no point in learning “complicated LaTeX”, but LaTeX is not complicated. Not unless you have complicated needs, then it is adequate. Especially if you’re a Humanities scholar – be happy that you can enjoy excellent typesetting without learning the more complicated technical parts of LaTeX. Once you’re used to the general gist, you can add the more fancy features without stress.

Don’t let listings of commands scare you away – you probaby won’t need them and, most importantly, you don’t need to remember them now. You probably don’t even need to know of their existence. If you have a problem, just type "latex how to [...]" in Google and you’ll most certainly find help. Or drop me a note, I’m always happy to help.

So, that’s all I wanted to say for now.

Cheers,

the LaTeX Ninja

If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!

€3.00

# Jumpstarting: Learn LaTeX in 3 minutes

Inspired by the learn x in y minutes tutorials, here comes my contribution to starting LaTeX quickly. If you want to jumpstart learning LaTeX, open your Overleaf account (or get one, they just require your email, no other info, takes 30 seconds) and open a blank or example project.

A blank project will give you the following output:


\documentclass{article}
\usepackage[utf8]{inputenc}

\title{\LaTeX in 3 min}
\date{January 2019}

\begin{document}
\maketitle

\section{Introduction}

\end{document}


You can now start typing text. Wherever you want, but for now, preferably below \section{Introduction} and in between \begin{document} and \end{document}.
The stuff before is the settings which don't interest you just yet. There you can see fields for title and author which \maketitle uses to make a title. This is what you can use to generate a title page later on.

Now type a sentence below \section{Introduction}, then hit space twice. Write another test sentence. Hit space twice and write \subsection{test}.

Now add \tableofcontents below \maketitle. Cool, huh?

\textit{makes text italic}, a similar but different effect is achieved with \emph{which highlights}. Make some \textbf{bold} statements and don't forget the quotes''\newpage will cause a manual pagebreak. Now copy this sentence into your test document.

Add \usepackage{hyperref} below the other \usepackage. Then add \href{http://latex-ninja.com}{\LaTeX{} Ninja} in the text.

With that, I think my 3 minutes are more than over and you are ready to go and do some exploring on your own.

Yours,

the LaTeX Ninja

PS: You might also be interested in the the Visual FAQ, a document showing things you might want to achieve with LaTeX which you can just click and it will redirect you to a TeX-FAQ tutorial where the chosen thing is explained. This is great if you want to get going as quickly as possible and learn as you go. Which you will have to or I won't keep my promise of an intro to LaTeX in 3 minutes 😉

PPS: The goal of this tutorial was not to give the illusion one could learn complete LaTeX in 3 minutes but rather to give you a quick "jumpstart" into LaTeX. In learning new things, people often don't try things out because the initial hurdle is too big. This post, on the opposite, is supposed to get you actively using LaTeX straightaway.

Visual FAQ

# Typesetting Historical Print

In today’s tutorial I will show how to reproduce a beautiful example of historical print using XeLaTeX. The inspiration for this came from my amazement with the Bible de Genève, one of the most beautiful typesetting examples with LaTeX (to be found in the LaTeX beautiful typesetting showcase:  LaTeX showcase). I thought I had to explain how a simple, non-perfect version of something like this can be done. Because, actually, something similar is not that difficult to create if you’re willing to do it less perfectly.

I tagged this post ‘beginner-friendly’ and ‘advanced’ at the same time because, frankly, I wasn’t sure which one was true. This is probably not your ‘3min to LaTeX’ beginner’s tutorial (which can be found [here]) but it looks pretty cool and is not that difficult either.

This post also serves as a teaser because this is only the base, really, for the actual tutorial (to follow soon, hopefully): Going from TEI-XML data to a PDF more or less imitating the historical print. And all that done automatically using an XSLT transformation for the whole glory of 600 pages of Michael Maier’s Symbola Aureae Mensae (1617). I’ll keep you posted, but for now, this is what the LaTeX part of the game looks like.

This is the Overleaf link to my document which you can view or reuse to your own liking.

The tutorial uses XeLaTeX. For now, suffice it to say that XeLaTeX is the way to go if you want to include your own fonts and if typesetting them is really important. I will explain why or why not and when to best use XeLaTeX in another subsequent post.

But I have also included some if-else constructs to check whether you’re compiling with XeLaTeX or just normal pdflatex because if you don’t have XeLaTeX available, the long s will not be displayed and you will get an error for every unicode character not present in the regular pdflatex font. Also, the microtyping, which I use very sparely for the letter spacing. Please be aware that I have not yet gotten to familiarize myself thouroughly with the microtype package or typographical best practises, so if in question – rather take somebody else’s advice on the specificities. But seeing as this tutorial is only meant as a teaser, I am not going to explain every detail anyway.

## First things first

I got my data the Herzog August Bibliothek Wolfenbüttels alchemy portal where they have a full text of Michael Maier’s Symbola Aureae Mensae here. There I accessed the TEI data (a bit difficult to find here ) from which I subsequently extracted the first page of Liber Primus. All the typesetting used was present in the markup in the form of elements. For your information, this is the part of the TEI-XML this is based on (XML is broken and, seemingly, unrepairably so. Please check out the XML in the link from above).



SYMBOLA AVREÆ

MENSÆ DVODECIM NA-

TIONVM.

LIBER PRIMVS.

POſt horribiles minas & grauiſſimas debac-

Quæ cauſa
& occaſio
huius con-
uentus Phi-
loſophici.

chationes, quas Pyrgopolynices in Che-
miam Virginem, orphanam, & ab om-
nibus derelictam, iam pridem effuderat
(proclamans illam ſpuriam, meretri-
tem, mendacem, mendicam, inhoneſtam, imò o-
mnium ſceleſtiſſimam, ſacrilegam, relegandam
aut morte peſſima delendam) hæc præ dolore animi
impatiens Comitia indixit omnibus, quotquot ſeſe Do-
minam agnoſcerent, præſertim Senioribvs, qui ef-
frenatæ illius inſaniæ reſponderent, ſeſeq́; pro virili caſtam
& intactam defenderent. Conuentuitaque habito ex
præcipuis noſtri Orbis nationibus, duodecim in-
primis comparuerunt, ſingulæ in ſuas Tribvs
d

To sum it all up, we largely have 4 elements to account for:

A head element which uses a bigger fontsize, spacing, italic and bold. More generally, we will do hard-coded linebreaks so it will be easier to maintain the page layout of the original without having to micro-adjust the LaTeX. Then, we have the highlights, indicating where we need to adjust font styles, weights, variants like caps and also, spacing between letters and also to some degree, between words, to maintain the balance.

Ah, and of course, don’t forget to LaTeX-ify the ampersands! (XMLs & entity ( & has to be changed to LaTeX’s \& )

## Setting up the document

In the code examples to follow, I only pasted the things I explain in here. For the full document see the Overleaf link. I suspect, however, that I included some packages which wouldn’t be needed. So probably don’t take this as an example from which to learn good LaTeX style… Here goes:


\documentclass[paper=a6,11pt]{scrbook}

\usepackage{iftex}

%---------------------------- font settings
\usepackage[utf8]{inputenc}
\usepackage[english,latin.classic]{babel}

\usepackage[T1]{fontenc}

\usepackage{lmodern}
\usepackage{ebgaramond}
\usepackage{lettrine}



First, I decided to use the scrbook documentclass with a6 paper and and 11pt font, so I didn’t have to do too much rescaling from the historical book to a4 for this quick tutorial. The iftex package allows me to check if the user is using XeLaTeX or pdflatex like I explained in the intro. The next improtant step is the ebgaramond font which provides the beautiful historical font style ( Georg Duffners EB Garamond). This font is the reason we primarily need XeLaTeX for. It the PDF also turns out nicely with pdflatex but is more beautiful in detail if using XeLaTeX.  Also, I wanted to include this to show to DH people how you can include unicode characters which aren’t readily found in other fonts but might be needed for setting historical print.


\usepackage[protrusion=false,final,letterspace=-100]{microtype}
\newcommand{\longs}{\ifXeTeX ſ\else s\fi}

\input Zallman.fd



This piece is where the microtype package comes in. I researched this just enough to achieve the effect shown in the example. I am by no means an expert on this and hope I’m not teaching you something hugely incorrect. The settings here are an approximation to get as close as possible to the historical example by just eyeballing it. If this were done more exactly, you probably wouldn’t need to hard-code the linebreaks like I did. But I thought it was easier and safe with the knowledge in mind that I intend to automate this and am not willing to check for every single one of the 600+ pages of the historical print if the output is correct.

Also, below this I defined the \spacedtext and \longs commands where I check how LaTeX is being compiled. If XeLaTeX is used, the spaced text will be done differently from the pdflatex option because it will throw errors otherwise. The \longs command is something you might want to create for every unusual unicode character in another document. Using pdflatex the long s unicode character, for example (the most frequent among others) will be undefined, thus throwing an error and simply not displaying that s. This is why I want it replaced with our ‘normal s’ if using pdflatex, so I don’t end up with half of the characters missing and having to check manually for missing characters. For this one page example also, this saves you a lot of work with Maier’s text.

Lastly, the \input Zallman.fd imports the initials.

\phantom{ }

\begin{figure}[H]
\begin{tikzpicture}[fill opacity=0.5]
\hspace*{-0.5cm}\includegraphics[width=1.15\textwidth]{decoration-vector.png}
\end{tikzpicture}
\end{figure}



## The heading and some unusual line breaking

So this is where the actual document starts. I use \phantom{ } to get some spacing at the top (yes, I am one for dirty solutions). Then I add a picture of the decorative element at the top of the original print. This was done using that part of the facsimile (from the same source at HAB Wolfenbüttel, indicated above). I did some image manipulation and vectorized it. Then I place it as a tikzpicture with a 50% opacity. Notice the meaninful   naming as decoration-vector.png. 😀


\Centering
{\bfseries \textsc{{\Huge SYMBOLA AVREÆ} \linebreak {\Large MENSÆ DVODECIM NA-}\linebreak {\large TIONVM.}}}

{\large\textit{LIBER PRIMVS.}}

\medskip



Here comes the header. It is centered using ragged2e s \Centering, then I switch to boldface for the upper part of the heading, use small caps and select different sizes for the different lines. Notice how they are separated by \linebreak, not the \\ I would usually use to force linebreak. Try replacing all ‘linebreak’s with ‘newline’ and see how the inter-word spacing doesn’t work anymore. The different options for producing forced linebreaks have some subtle differences (see also the Overleaf tutorial here ).

\\, \newline and \hfill \break give more or less similar results for most use cases. Note however that \\ is redefined by some commands (like \centering) to achieve the desired behaviour whereas \newline won’t (resulting in undesired results, see explanation here ).

Usually, you don’t want to use \linebreak as it is considered somewhat of a ‘last resort command’ which usually produces ugly unwanted results (see Stackoverflow ). In our case however, ironically, this is exactly what we want: It will ensure that we get an even right margin by saying ‘break the line here and make the line end at the right margin’. This is totally what we want in this case. Usually, it probably wouldn’t be needed, but as mentioned above, I did not micro-correct all the word spacing options, etc. But we still want the result to look as much as the historical print as possible, so the ‘last resort command’ does the trick here.

## The typesetting of the main text area

This is our last snippet here, explaining the rest of the principles at work in our mini-example of Michael Maier’s monumental Symbola Aureae Menase. If we wanted to typeset the whole book, we would need some more settings, of course, as he also has some more textual and typographical elements going on in these 600 pages of alchemical historiography. But let’s nor worry about that just yet:


\justify
\fontsize{9.5pt}{11pt}\selectfont

\renewcommand{\LettrineFontHook}{\usefont{U}{Zallman}{xl}{n}\color{red!50!black}}
\lettrine[lines=5,,loversize=-0.05, lraise=.05]{P}{}
\emph{O\longs t horribiles minas \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; graui\longs \longs imas debac-}
\marginnote{\fontsize{6.5pt}{7pt}\selectfont\emph{Quæ cau\longs a} \linebreak \emph{occa\longs io} \linebreak \emph{huius con-} \linebreak \emph{uentus Phi-} \linebreak \emph{lo\longs ophici.} } \linebreak
\emph{chationes, quas Pyrgopolynices in} \spacedtext{Che-} \linebreak \spacedtext{miam} \emph{Virginem, orphanam, \&amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp;amp; ab om- \linebreak nibus derelictam, iam pridem effuderat} \linebreak
(proclamans illam \longs puriam, meretri- \linebreak cem, adulteram, deformem, imbellem, impoten-



I use \justify to get the justification and set the font size manually using \fontsize{9.5pt}{11pt}\selectfont which again, could probably done more elegantly if I had taken the time to properly adjust the page, font and spacing settings. For this quick and dirty solution, however, this works just fine. The command sets the the font size with the first argument and the \baselineskip with the second one. Note that it is usually better to use the symbolic font sizes LaTeX provides (such as \large, see Stackoverflow ). But in this case, we want to be able to hard-code this the way we need it and don’t want LaTeX to exert its magical typesetting powers. Sorry LaTeX.

Usually the smybolic font size commands would guarantee a balance between font size and \baselineskip. Again, the ratio I inserted here is based on eyeballing only. But I think it works quite nicely here.

### The initial

\renewcommand{\LettrineFontHook}{\usefont{U}{Zallman}{xl}{n}\color{red!50!black}}
\lettrine[lines=5,,loversize=-0.05, lraise=.05]{P}{} sets and displays the initial. You probably shouldn’t renew the command inside begin{document}. Well…

Lettrine uses the Zallman initials (see the LaTeX font catalogue initials section (at the bottom)). It sets the color to red!50!black, so it mixes red and black in a 1:1 ratio. Just red was too bright, I found. Note how I added this and there is no color in the original print. The \lettrine command sets the size of the initial to spanning 5 lines, downsizing it by 5% ( loversize=-0.05 ) and also raising it a little bit. Behind the raise is the ‘P’ the actual input the command takes, so the letter to be displayed as an initial.

### The text

There follows some \emphed text to achieve an italic effect (maybe in this case, it would have been better to hard-code it as \textit seeing as the correct font style is also ‘hard-coded’ as the elements of the TEI-XML. Then, also note the frequent use of our \longs command. Already in the first line, this was totally worth the trouble. The \spacedtext{} macro created the spaced small caps using the microtype package which I didn’t explain in detail above. An explanation of this will follow in some subsequent post. For now, content yourself with playing around with it as provided.

That’s basically it, the only thing I didn’t explain yet is the margin note.

### The margin note


\marginnote{\fontsize{6.5pt}{7pt}\selectfont\emph{Quæ cau\longs a} \linebreak \emph{occa\longs io} \linebreak \emph{huius con-} \linebreak \emph{uentus Phi-} \linebreak \emph{lo\longs ophici.} }



This basically creates a margin note. I manually redefines the fontsize like explained above. If we wanted to go beyond this example first page, we would probably include this resizing option as our default into the \marginnote command and also reset it so it always places the note on the respective outer margin of the page (in this example we only have this one note on the right side which is the standard option anyway, if we had a doublepage layout, we might want to reset some options). Note how you can use the \linebreaks inside the marginnote as well. Seeing as we have the information exactly where the lines should be broken from the TEI-XML, we might want to respect that.

So, that’s it for now and here’s what it looks like again.

Cheers!