# Cheat Sheets and Study Summaries

This is a quite long post about cheatsheets and also about effective studying. When you need a cheatsheet, chances are you’re trying to learn something (or use something or not yet very familiar with). Because if you already were and experiened expert, you wouldn’t need a cheatsheet, right?

First, I only wanted to share this cheatsheet template I made and explain why I did what I did. I ended up explaining the concept of the “survival summary” for effective studying and exam preparation, rant about what I think people do wrong when making cheatsheets and why I think the theory of effective learning should ultimately reflect in your cheatsheets. By the way, I hardly ever stick to my own rules when making cheatsheets… 😉

If you only care about the cheatsheet, please just scroll down and go get the template or skip to the section on the ‘design principles’ for my template 😉 . Everything else is a (prolonged) explanation of what I did and why I did it on a more theoretical level but I think (hope?) it might be a beneficial read 😉

## Cheatsheet philosophy

### Space

If you google how to create a cheatsheet, people will recommend you redefine all the section headings etc. as to remove as much unnecessary space as possible. But space is what gives you overview, it’s what guides your eves. If you remove it, you will lose a tremendous amout of time looking for information and not finding it straightaway. It would make more sense to actually reflect what you’re doing and try to save space by reducing unnecessary contents.

### Content

But apart from squeezing too much info on cheatsheets per page, another problem is the content itself. I checked out some cheatsheets to research this post and obviously with LaTeX-based cheatsheet templates, many take LaTeX itself as the subject. With what I found, the results often contain pretty superfluous information. That is to say that, for example, in many cases, almost the whole first page is made up of information with a way too short half-life. The starting out info will become obsolete once you’ve used LaTeX 3 times. Do you really want to add that to your cheatsheet? Maybe you could leave it out or create another resource (a getting started manual) or just reduce it to a bare minimum with a small font size.

### Cramming in more

If you have to, downsize the font size but don’t get rid of the spacing. Of course that’s going to save you time and allow you to cram in as much information as possible. But is that really the most effective thing to do? Don’t you want the cheatsheet in the first place to reduce the complexity of the topic? If you’re going to just copy it in from any source, you might as well not make a summary but always use the internet so you can find the information you need quickly. Thus, wouldn’t getting rid of all the structuring elements amount to the opposite result of what you intially wanted?

A good cheatsheet (or study summary, which is probably more accurate), in my opinion, will contain shockingly little information but all the information included will be highly relevant. Also, instead of listing all the possible commands, why not mention or introduce them, while explaining something actionable? You could group your cheatsheet not into types of commands but into topics or problems one might want solved. An actionable and task-oriented cheatsheet is more effective than a reference style one.

## The “survival summary”

When I write about cheatsheets, I can’t help but mix it up with the concept of the “survival summary” somehow. I got to know the concept in Krengel 2012 (see references) where he writes about how to study best. I am aware they’re not the same but thought you might be interested to learn about them anyway. In his book, after demonstrating effecitve note-taking (very visual and structured), Krengel explains his concept of the “survival summary” where you condensate all the material to be learned in one single page, in a late stage of studying for an exam when you already have the overview (also this method forces you to get yourself an overview…).

The idea behind this is that you can’t remember one hundred pages. But you can sure as hell remember one. So make sure everything which is absolutely necessary (what you need “to survive”) is on this page and act like your survival depended on it. Only add key concepts, not detail facts. Except maybe one or two indispensable, central ones which help to make it more visual. Using examples is always good as it induces some kind of “storytelling” which is good for memory.

Of course, if your exam consists in knowing detail facts by heart, this is just a good guideline for your memory. This summary is not meant to replace everything else. It just serves as the “memory hook” where you can localize your detailed knowledge. But I will exclusively reveal here that I have passed many exams by just knowing this most important info and having prepared a really good “survival summary” (without studying anything else before). You can definitely get by like this because the survival summary is basically the definition of a “pass grade”, embodied in an object in the form of a piece of paper. It contains all the info you need to succeed. Of course, you’ll really need to know its contents well, but if the summary is visual enough, it will be quite easy to remember. Hardly anyone will have problems remembering just one page if they really try.

## Note taking and ‘reducing’ information to the most imporant bits

Reducing is probably not the right word. It’s more like condensing lots of bla into the info behind it. Once you start doing this that the bla-to-info ratio is quite scary. In most kinds of schooling, there is tons of bla and, usually, very little info. So reduce complexity, introduce clarity and overview. Be visual. Focus on the bigger picture. Unnecessary detail will only cloud your mind. Don’t try to remember everything. It’s a recipe for disaster and, if anything, will ensure you remember nothing at all.

This overview, this summary is your security. Think of it as insurance. If done well, it will ensure you pass the exam. If you aim higher, it will be a sound base to ground your details on and give you a sense of security which will make you more confident. You can remember one single page, right? This page contains everything you need to pass, so what could really go wrong?

I personally started even taking my lecture notes like “survival summaries” rightaway, to save even more time. You end up with 10-12 survival summaries which you can reduce into the final study summary just before the exam. This will save you lots of time. So rather than just mindlessly noting down everything the professor says, only note down important stuff or information which is likely difficult to find outside of the lecture notes. If the information is on Wikipedia, only write down the keyword. Or make a glossary rightaway where you put all the ‘difficult words’ and their definitions.

These words alone often can go as a survival summary. If you know what they all mean and the concepts they’re related to, you already have the gist of what’s going on. When in class, always make three columns on your paper.

1. Left column: Leave empty to fill in the summary / keyword / heading of the current topic.
2. Middle column: Your actual notes.
3. Right column:  Anything you need to remember, be it historical dates in history, vocabulary in a language class or a glossary of difficult words.

In the middle column, highlight the important words as you write, so you don’t have to re-read everything to remember what paragraphs were about. You need this info to fill in the topic heading in the left column. The left and right columns are the prep work for your study summary. When preparing for the final summary, cut out everything repeating itself or not strictly necessary. Sum it all up in one final survival summary.

## Reduction and reflection >  mindless note-taking

Dare to only note the most important stuff. Most people want to note down everything because it makes them feel safe. Leaving things out, they fear to end up not understanding their notes anymore. This is not an issue if you take good notes and give thought to how you write things down. Often you don’t need to write a whole sentence to unambiguously understand the content. Or, if you have the keyword and the context, it takes 5 seconds to look it up on the internet should you really not remember what it meant. It is way more time-consuming to have to work through extensive notes. That’s why lots of people fail exams despite lots of work taking excessive notes. Every single word you note down you will have to work through again. Do yourself a favour and note down only what’s actually important.

Not noting down everything is beneficial for many reasons:

1. It’s the first stage of reduction of the material, if done right.
2. Taking good notes makes creating summaries so much faster.
3. Having condensed visual notes from the last lessons allows you to have the overview and keep you from noting down things multiple times.
4. If you never take more than one page of notes per lesson, reviewing the content before the next lesson will be really easy. You can learn things straightaway rather than waiting until the exam. Learn things as they come up! This advice from Steve Pavlina is probably the best studying advice ever.
5. Not writing complete sentences, using visual boxes with no more than 3-5 concepts per block, you actively make the information easy to grasp for your brain. Also, you find things more quickly.

### 8. Learn material the very first time it’s presented.

One of the biggest time wasters in school is having to relearn something you didn’t learn properly the first time. When students say they’re studying, most of the time they’re making up for a previous failure to learn the material.

In software development it’s well known that bugs should be fixed as soon as possible after they’re introduced. Waiting to fix a bug near the end of a project can take 50x as much effort as it would take to fix the bug the first time it was noticed. Failing to learn what you’re supposedly taught each day is a serious bug. Don’t try to pile new material on top of an unstable foundation, since it will take even more time to rebuild it later.

If you don’t understand something you were taught in class today, treat it as a bug that must be fixed ASAP. Do not put it off. Do not pile new material on top of it. If you don’t understand a word, a concept, or a lesson, then drop everything and do whatever it takes to learn it before you continue on. Ask questions in class, get a fellow student to explain it to you, read and re-read the textbook, and/or visit the professor during office hours, but learn it no matter what.

10 Tips for College Students, Steve Pavlina

Once you’re not new anymore at university and know your way around, you will quickly know where the lecturer has gotten his or her information on. (Hint: it’s probably somewhere in the literature list you never cared to notice). This is why my survival summaries and notes only contain insights or information so condensed you wouldn’t find them anywhere else. If your summary is supposed to be a go-to resource alongside the omniscience of Google, it has to be really good and give you access to information Google (or the library) couldn’t give you.

If it can be looked up quickly, is a detail and not extremly central to the point, don’t bother writing it down. You won’t be able to read your own handwriting in a few weeks anyway. If you type your notes on a computer and have decent typing skills, chances are you’ll procude so much text you’ll never be able to go through when studying.

I used to be quite religious about lecture notes and summaries. I wanted to make perfect notes, grasp all the information, constantly improve my note-taking skills until I realized the true art of good summaries lies in leaving things out.

Good notes glow with simplicity. If you’re notes are digital (written in LaTeX like my cheatsheets of course), use \href{http://link.com}{Name} to hide reference links in the texts. This will stop ugly links from ruining the overview but calm your fear of “forgetting or leaving out important information”.

Of course, since you’re not the one teaching the class, you can never quite know exactly what is most important, or completely unimportanty respectively, to the teacher. This is why, perfectly simplicistic survival summaries will remain a theoretical ideal you can never fully achieve. But that’s not a reason not to try. Don’t think this is the lazy way out either. It is actually quite hard, challenging work and requires a very good overview about the subject in question. I have created many bad survival summaries because I didn’t bother take enough time to understand the material at hand. These bad summaries will not get you very far.

Ideally there should be no need to study outside of class, at least in the sense of relearning material you didn’t learn the first time. You can review old material to refresh your memory, but you shouldn’t have to devote a minute of your time to learning something that was taught a month or two earlier.

[…]

During each semester ask yourself this question: Am I ready to be tested right now on everything that has been taught up to this point? If your answer is ever “no,” then you know you’re falling behind, and you need to catch up immediately. Ideally you should be able to answer “yes” to this question at least once a week for every subject.

[…] Put in the effort to learn your material well enough to get As in all your classes. It will pay off. Much of the material you learn will build on earlier material. If you get As in your freshman courses, you’ll be well prepared to pile on new material in your sophomore year. But if you get Cs that first year, you’re already going into your second year with an unstable foundation, making it that much harder to bring your grades up and really master the material. Make straight As your goal every semester. In the long run, it’s much easier. I found that C students tended to work a lot harder than I did, especially in their junior and senior years, because they were always playing catch up. Despite my packed schedule, it wasn’t stressful for me because I kept on top of every subject. Consequently, I had plenty of time for fun while other students experienced lots of stress because they constantly felt unprepared.

Steve Pavlina, Do it now

## How to know if a summary is good?

How do you know the summary is good? Well, you’ll never be able to guarantee. But usually, you’ll have a good feeling about it. If it doesn’t contain all the topics, for example, that’s a good indicator of a bad one. Or, when you went into a lot of detail in subject one and left out subject two because you spent all your energy on subject one, this is a classical example of the “unbalanced survival summary”. This happens, but shouldn’t. Thankfully, seeing as these summaries are quite visual, it will be quite apparent to you.

A summary or part of summary with tons of detail also mostly is an indicator you should deepen your knowledge about the subject first. A lot of detail usually means you lack the general understanding of the bigger picture and are very unfamiliar with the topic. See my comments about how an advanced person’s cheatsheet is not the same thing as beginner’s intro. This is exactly what I’m talking about here. A beginner will add detail which is necessary only for the very limited amount of time you’re a beginner. It might even be very relevant then. But it will turn to completely irrelevant once you’ve moved on to advanced user. An advanced user will add very little detail unless there is a good reason for it. The result will visibly be more balanced, topic-oriented, containin key concepts and an overview of the bigger picture.

You will learn a lot trying to condense information into a survival summary like this. In fact, this had turned out to be the most effective study strategy for me as you’re not complelely passive in this kind of revision.

So make sure to:

• use the methods of chunking (2-4 chunks) or storytelling (I mostly use chunking only though)
• Garbage In, Garbage Out –> if you don’t do some serious “editing” with your learning materials, this is what you’ll get…
• Condensate: “zoom out”
• Reduce: get rid of anything redundant or trivial
• get visual
• Facts versus skills: Operationalize

## What is a cheat sheet? Theory and practice

### What it should be

A memory aid which stores information you might need quick access to and need fairly frequently but not frequently enough so you would recall it without the cheatsheet.

#### What it shouldn’t be A crib

The thing you used in school to cheat (ok, yes I did too. I fact, quite masterfully so^^). I used to have these really full cribs which contained EVERYTHING and I printed them out, using the 16 pages or 32 pages on one page mode. Used to work pretty well.

#### A beginner’s guide

Beginner’s guides are totally legitimate but please, if you want both a cheatsheet and a beginner’s guide, make sure to create two different documents.

The problem is: A beginner’s guide includes tons of information you totally do need when starting out. But once you’ve successfully gotten started, most of this information is 100% obsolete. You’ll either never need it again (because it was one time information, like how to install something) or you will have it memorized by heart because you use it too frequently. The information contained in the beginner’s guide can intersect with the one still relevant later on, but in part, certainly will be obsolete once you’re not a beginner anymore. And, believe it or not, once you actually get started, you will reach advanced status fairly quickly. So make sure to keep those documents seperate. Just take the time to make one sheet with basic info and another one with info which might still pass as “basic” but will remain at least somewhat relevant to an advanced user.

#### A lexicon or a reference

I see this with LaTeX cheatsheets a lot. People cram in all the information there is. Including a minimal working example of a LaTeX document. Please, people, you will need this information exactly once. If you’re using an editor which provides some setup support (like Overleaf or even TeXmaker etc.) you will never use this information again. Unless you’re one of those hardcore people who don’t use IDEs. And even then, you probaly won’t need it more than three times until you have memorized it.

#### The command graveyard

Or, instead of the minimal working example, they add in all the symbols you can possibly use in LaTeX. Even if you use LaTeX for math purposes, there is no way you’ll ever need all those symbols. Some you will need fairly frequently, some you won’t need at all. And, if you have some basic familiarity with the greek alphabet, you will know the names of the letters. And can just write them as commands. No need to print the whole alphabet, right? If you don’t know the Greek alphabet and need it regularly, learn it please?

Like I will elaborate in the “design” section below, every detail which is in the slightest bit  unnecessary will ruin the overview and undermine the purpose of your cheatsheet (quick access to relevant info).

If the overview is so poor and you’re faster Google-ing your wanted information, what the hell do you need a cheatsheet for? Unless you have no internet, of course. So when preparing a cheatsheet, don’t go thorugh all the beginner’s tutorials and add everything they have (unless you want to make a beginner’s guide, but if you do so, please do so explicitly).

Look for information which fits the criteria below:

1. If you feel you absolutely need to add in some basic function, don’t waste a lot of space for it. Or demonstrate the basic thing while demonstrating something more advanced or rare.
2. Don’t add things you might ever only need once, like infrequent symbols.
3. Don’t add startup info unless you’ll need it more than once. Also, make this a “detail on demand” (see design principles below) if you feel you absolutely can’t go without it.
4. Also, just generally avoid adding “extensive lists”. If your cheatsheet is supposed to be a memory aid, keep in mind that the brain can only process so many chunks at a time (3-5). Accordingly, one block of information should not include more than 3-5 elements at a time.
5. Cut out anything unnecessary. Summarize, cut and shorten radically. Keep to the absolute minimum. Make it zen. Simplify. Really take the time to do this, it will maximize your benefits.
6. Good cheatsheet design takes up a lot of time. But once the cheatsheet is done, it will be useful to you for a long time.
7. Don’t just sit down and create a cheat sheet. A really good cheatsheet will need some design first. Brainstorm, see what information you want to include. Note down everything you feel you need, then shorten radically and find creative ways to make it more to the point.
8. This creative process is what we might call editing. There is this quote: The first draft of everything is bullshit. What it means is that most people stop before the actual work starts and that’s why their results are bad. Outputs only get really good if you sit down to edit them and make them better, design them carefully, etc. When writing a paper, for example, putting the info on paper is only half of the work. Internal editing, peer review, etc. will make the final result take about twice as long as the inital step of “writing the paper”. Most seminar papers are bad because students just stop after they have sloppily collected and written down the information. The papers end up lacking detail in research but also lacking grammatical corrections, reformulating to make the outline and the sentences more clear, etc. The same goes for anything you produce.
9. A good cheatsheet is something you might want to use for a long time or even share with others so they can profit from it too. If you make a good summary for studying, you can use this as a memory aid or refresher long after the exam. If, and only if, you did it well to begin with. Or imagine you want to take an advanced class. A good cheatsheet will make sure you master the basics, and if you don’t, have them at the ready whenever you need them. Or, when preparing for an exam, the extra time might seem a waste of time – but, on the plus side, you’ll be way further along in your studying if you have taken the time to make a high quality cheatsheet, and you also have a good point to start should you happen to fail the exam. Whoops.

## Basic design principles

Data vizualization 101 also applies to effective learning and, thankfully, the most important principle can be summed up in one single sentence:

Overview first, zoom in, detail on demand. (Shneiderman’s Mantra)

1. Overview first: means big headings about the subject of every block.
2. Zoom in: you go from the “hook” which is the heading to the actual information, i.e. details (in this case).
3. Detail on demand: this works well in responsive applications but how to implement this on an analogous piece of paper, you ask?

When I prepared class summary sheets for studying (and I used to be very religious and peculiar about this, believe me. In fact, I probably still am.), I made big headings (stage 1: overview first), then added the info below (stage 2: zoom in) and added details in such a small font size that you had to physically get close to the paper to be able to read it. As I wrote this by hand, the writing became almost impossible to read. And that was the brilliant part of it.

The point is, we mostly are so afraid to leave some less than important piece of information out, because we feel like we’re going to miss out (or something, I can’t even really explain why). We’re afraid this information is a crucial detail when mostly, you’ll never need it again. Also, by noting down all the information, we are lured into the false security of thinking we have it noted down anyway, so it’s not so important we actually memorize it.

While this is not exactly the goal of learning, it also makes us end up with pages and pages of notes which we will never get through when studying for the exam. Also, working like this, we will never ever actually have an overview what the class was about and since teachers mostly fail to mention which ones were the most important contents, we will probably remember the least important detail only. Congratulations.

The cheatsheet is not a universal reference and not the place where you “write down everything”. You only write down that which is important and choosing what is important always means you’ll have to discard certain items. The study cheatsheet does not need to include everything, that’s what books, Google or your notes are for. The cheatsheet sums up the most important stuff in an overview.

I don’t always follow my own advice, of course, and tend to want to include every little detail. But once the summary is done and I acutally use it, I always regret including too much detail, especially the absolute basics. I find the best way here is to include them but

a) keep it small and

b) include it combined with some other less important information you kind of want to include but wouldn’t be important enough otherwise.

I sometimes write my summaries while a class still goes on: I reserve a spot on the (analogous) paper for every session. My university classes are usually 12 to 14 sessions. This is more tricky, of course, since something which seemed new and important at the beginning might be obvious and unnecessary once you’re deeper into the topic. Avoid reserving too much space for the basics as they are likely to end up not being important anymore. Or write your cheatsheet in LaTeX (of course 😉 ). You’ll be able to modify it in the way that makes the most sense once the class is over, there is nothing more to be added and you’re doing revisions. So these are the key principles:

2. Boxes ( don’t add more than 3-5 chunks)
3. White space: Unlike many other cheatsheets, don’t use every inch available to you. Don’t cram in every detail. Space it out, it will greatly benefit the overview (and thus, your learning).
4. If you absolutely can’t go without some detail, make it so small you’re almost unable to read it. Force yourself to have to remember it. Don’t count on the fact that it’s all there and all available at one click.

## The Cheatsheet – Template and explanation

The \mycommand command for displaying commands and their explanations uses \detokenize to display code. It functions as explained here . However, some problems remain, like you can’t use \maketitle or comments (%) in the command.

Also, don’t forget you can’t add any styling to the command part of \mycommand. This should be obvious but I catch myself trying to insert commands and wondering that they’re just displayed as text all the time. 😉 It usually takes me a few seconds before I realized this is a feature I actually knowlingly configured to work as such.

The subboxes are done using tcbraster (indicating the number of columns). There would be an option to indicate rows as well, but I couldn’t see why I would need that and if one ever should, one could just use 2 mulitboxes (works just fine, if you ask me…).

## Playing around: Cheatsheet to beamer

After I created a cheatsheet using this template, I had the idea that I could ‘generate’ presentation slides from it. This was quite easy. I opened a beamer template and pasted the document body of the cheatsheet into it, replacing all the \begin{textbox} with \begin{frame}[allowframebreaks] and the \end{textbox} with \end{frame}.

This seemed like a quick and easy way to create slides from the cheatsheet. It turned out, however, that tcblisting has some issues with enumerate or itemize environments in the beamer documentclass. The co-presence of those two in one document will stop the whole thing from compiling due to a bug in the beamer class, apparently. It took me very long to find out why exactly, believe me.

Also, the resulting slides are not, like, suuuuper beautiful, if you know what I mean. The automatic framebreaks are not great but, at least, will give you working slides instantly, even if your boxes were very full (which probably they shouldn’t be in the first place…). The slides are nothing special, but they work as long as you never have code examples and lists in the same document. Or you’d have to rearrange your code exmaples from tcblisting to lstlistings. I do quite prefer tcblistings to be honest. And, in the concrete case, if you care to know, I had been late preparing my class which was supposed to happen in a few hours time, so I decided my students didn’t need the code on beamer 😉

So, that’s it for now.

So Long, and Thanks for All the Fish

the LaTeX Ninja

# References

1. Martin Krengel, Bestnote. Lernerfolg verdoppeln, Prüfungsangst halbieren. Berlin 2012.
2. 10 Tips for College Students, Steve Pavlina
3. Steve Pavlina, Do it now

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

€3.00

# The Simple Academic Resumé. A play in 3 acts

Dear all,

you might already know the Simple Academic Resumé/CV from Twitter or GitHub. It is available as a template on Overleaf now, so I wanted to take this occasion to formally introduce it to you again. It also has a new third style which you might not be familiar with yet.

I don’t know if if love the name. Thinking back now, I might have called it something else but since has already been out there on Github quite a while, I didn’t want to change it anymore. My second thoughts now stem from the fact that I would like to make a template which really deserves the title ‘academic’. This one was named academic only because I published it the day after the Hipster CV and  somebody on Twitter noted that they would think it very bad style to use such a template in a academic context. That’s why I got inspired to make a more simple template and called this one ‘academic’. But there’s nothing especially academic about it really. 😉

Aaaand the last available option:

Well, I hope you enjoy it anyway.

Best,

the Ninja

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

€3.00

# New CV Template: All black hipster

Pretending I did not have any more pressing matters at hand, I used my day off today to create new Hipster CV theme based on my current absolute favourite: the Developer CV from LaTeX Templates. Surprisingly, this one apparently hasn’t gone viral yet. Which I totally don’t get. It has inspired the allblack version of hipstercv. But I actually think it’s so good that it will lend inspiration for another CV template even. So stay tuned for that.

Try it out directly here on Overleaf 😉

So anyways, here is the Hipster CV and you can now conveniently change between colour themes. There are currently six themes: verylight, allblack, grey, pastel, lighthipster, darkhipster.

Also, I used the opportunity to finally fix the error in the original hipster template pointed out by Peter Flynn (@docum3nt on Twitter). You can find it on the same old the hipstercv-github which now actually has a new shiny preview section in the readme 😉

So, I hope you can use this template. Let me know how you like it or whether I should add something different.

Best,

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

€3.00

Dear all,

just quickly sharing another CV template. This time a bit less colourful to complement yesterday’s Hipster CV.

So, hope you like it. You can find the code on the GitHub 😉

Best,

the Ninja

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

€3.00

# 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 as a template. 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