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

Typesetting Code in LaTeX

Since I recently pulled a few all-nighters to prepare code slides to teach my students R and they were less than enthusiastic, I thought I’d use the opportunity to at least write up a post on how to display code in LaTeX for you guys. It focuses on displaying the code for teaching, writing tutorials and so on. So the integration of code in beamer will be dominant, or at least the example on which I demonstrate things. Of course, you can also use the tips to just display it in a ‘normal’ document.

When I thought about it, I realized there are actually so many ways of displaying code using LaTeX packages. So I’ll start with the most basic and then go on to the more advanced ones 😉  You can find the example document here on Overleaf. It uses the beautiful metropolis beamer theme, which is worth looking into as well.

The \texttt{} command

This one isn’t a verbatim way to express code, but it will change the font to typewriter, so it ‘looks like code’. However, in these short bits of code, you will have to use escape sequences for reserved characters. Furthermore, it (shockingly!) is not natively included in beamer, so you have to add it yourself in the preamble if you want it (as demonstrated in the template). How can one write about code without over-using \texttt{}?

I make massive use of \texttt{} when ‘talking’ about code or, you know, writing explanatory text sequences. It is especially useful for bits of code where there is no excessive (or none at all) use of escape sequences. Then it is a really handy way to quickly typeset code. Once you have lots of reserved characters, you might be better of just using this next one.

The verbatim environment

This one really is a staple and pretty failsafe, but also doesn’t have code highlighting which you might want in most cases, apart from very short bits of code where highlighting isn’t important.

You can use verbatim as an environment for multiple lines of code which appear like a quote as a separate block in your text. In other cases, where you just want \texttt{} but without having to escape reserved characters, you might want to use the \verb|some code| command. You can use any characters as delimiters to denote beginng and end of code. To be more precise, a quote from the Overleaf site: “Any character, except letters and *, can be used as delimiter. ” So it can also be \verb+test+. The idea is that you can choose one which you will not need inside the code, as not to ‘confuse’ the enviroment.

A note about code in beamer

When you use code in beamer, make sure to always use the fragile option for the frames in question. This is necessary due to the way how beamer handles verbatim, apparently.

Also, beamer and code can generally can wreck quite some havoc. I have had problems with lots of KnitR where it would stop working for no reason, then the exact same code would work again later, etc. And there are lots of conflicts and bugs you need to know about. So if you run into problems here, don’t blame yourself. It might easily be beamer which is ‘responsible’ for some of the problems.

The lstlisting package

You can just use the lstlisting environment without configuring anything but then again, it will not have code highlighting which is kind of the point in typesetting code (most times at least).

However, I find that without setting your own colours for the listings, it still looks quite boring with the black and white hightlighting (bold vs. non-bold). You can configure it any way you like, can even define yourself which elements are to be hightlighted and how. But it is quite a lot of work if there isn’t something you like out of the box. I personally prefer minted and especially tcblisting – that is minted with tcolorbox (as far as I know, even though it’s called listing). It has these cute little boxes. I like boxes.

Using KnitR

When using knitr to run R in LaTeX, don’t forget to change the file extension from .tex to .Rtex so LaTeX gets a heads up that you want to use KnitR. Otherwise you’ll end up with jumbled code and might spend hours trying to find the mistake, since it isn’t actually in your code. (Just so you know, I speak from experience here 😉 It’s just so easy to forget to do this. Basically happens to me all the time…)

You can use KnitR out of the box on Overleaf. Note, however, that they might not have all the packages you might want. But if, like me, you just want to display code to teach coding, you can eval=FALSE the results (which will be error messages due to lacking packages) and let the students run the code themselves. Since my elaborated fancy didactical plan was not to share the code as a file but rather have them type it themselves from the presentations, to increase the learning effect. Disclaimer: It did not work out the way I had hoped it would 😉

The minted package

If you like fancy, minted probably is for you. It’s kind of like lstlisting but with more beautiful colours and preset options. Give it a try. It’s probably the go-to solution.

Minted and tcblistings

tcblistings use minted and tcolorbox to create highlighted code listings in cute boxes. For me, that’s just too good to be true 😉 Note, however, that Beamer, tcblisting and enumitem are not compatible with each other. There is a bug I haven’t yet found a way around. So you can’t use customized enumerates oder itemize in the same presentation as these code listings! Sad, but true. But maybe there is a not-all-that-inconveniant way for you to keep presentation and code parts in separate sets of slides anyway. Here, it’s on you to get creative 😉

Generally, with the beamer package, there are actually quite a few things which don’t work once you want to use some less common features. So in case you encounter a bug and really can’t see how it’s your fault, web search if it’s a common error or known bug. Maybe there will be a way around it, maybe there won’t.

A workaround for this specific case would be to use beamer with lstlisting.

Wrapup

So, I hope this helped you and provided you with  an overview of possible ways of typesetting code in LaTeX, with a focus on presentations.

Best, the Ninja

Resources

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

€3.00

LaTeX for PhD students

Today, I decided to finally publish some thoughts on why I think PhD students can profit from using LaTeX. In this post, I try to avoid common not-all-that-creative reasons and point you to some aspects you might not yet have thought about like the fact that your PhD thesis will yield two PDF outputs with (more or less) the same content but very distinct different formatting requirements. Enter LaTeX.

1 PhD = 2 (!) print outputs, i.e. thesis print and printed book publication

Typesetting your PhD in LaTeX is a good idea because of the citation management, for formulars and for images. You probably already know that. But another aspect a lot of people tend to forget while writing their PhD thesis is that a thesis will usually result in two different output PDFs with different typesetting needs: The thesis to be handed in at your university and the print publication which follows. But these two usually have some important differences in requirements. Like a thesis print will probably be a4 or letter paper, a font size of 12pt, etc. A print publication almost always has a smaller paper size and thus, a smaller font size. In my case, this was: paperwidth=170mm, paperheight=240mm and 11pt. Where as a4paper is 210:270, as far as I remember. If you take this into account beforehand, you can save yourself a lot of work and trouble. Also, it’s not like you will suddenly have tons of free time in the time after the PhD writing, probably the opposite. You don’t want to make that even harder by placing another unnecessary burden on yourself.

Already here, LaTeX really pays of. Just change two settings. That’s basically less than 10 characters (!) in your main.tex. If you don’t have to make other changes, that is. Well, you get what I mean. Whereas in MS Word, this can be a lot of effort since quotes probably have a different text size and unless you use the “Standard” predefined templates which you can then change, this can take you a while. Also, it probably often happens to people who don’t reflect on the typesetting while writing (which, after all, will occur long after the writing, so we don’t yet give it a lot of thought) that you don’t consistently use those templates and thus, will have to change or at least check everything manually. With LaTeX, you don’t. Isn’t this enough of a point for LaTeX already? But behold, we have more.

Typesetting concerns like orphans and widow lines

Another thing for producing nice typesetting: A (respectable) publisher will usually ask you to take care of orphans and widow lines. In a 300 page MS Word document, you will probably end up having to do this all manually which usually entails all sorts of horrible consequences you hadn’t even dreamt about this far. While this problem cannot be fully automated in LaTeX, you have the possibility of adding this simple statement to your preamble:

\setlength{\emergencystretch}{.25em} % avoid line overflow
\clubpenalty10000\widowpenalty10000\displaywidowpenalty=10000% avoid widow lines and orphans

This, supposing that you have included all the languages you use with \usepackage[ngerman,english]{babel} (for example, last one is the one active), will avoid most line overflows.

A problem that you, admittedly don’t have in MS Word but do have in LaTeX. But more important is the following line. There, we add to the internal ‘penalties’ which LaTeX has, thus preventing orphans and widow lines quite effectively. Maybe you’ll still have to correct one or two things. But one or two things in the whole document, speaking of a document wihch basically handles itself, is not that much of a big deal. In MS Word, calculate to sit down for a few hours. Thus, yet another plus for LaTeX: less grey hair and more time for work-life-balance. Isn’t it amazing?

Another plus: Relative and absolute positioning

It’s always better to use relative positioning and values and also, leave litterally everything up to LaTeX. Thank me later. For some info on relative and absolute sizing, consult the upcoming post LaTeX for Archaeologists: Typeset your PhD catalogue in LaTeX post.

The (lack of) comment function: A workaround

A possible down-side for LaTeX is that advisors often like to use the comment function in MS Word to correct and comment your work in progress. This, I personally have solved by converting it to MS Word using Pandoc and then uploading it to GoogleDocs for my advisor to make corrections. These have to be put back into the original by hand, of course. But you need to proof-read multiple times anyway, so I reckon it doesn’t make much of a difference. It’s a wee bit inconveniant, is all.

But… LaTeX is scary?! On common concerns

If the prospect of first “having to learn complicated LaTeX” sacres you, you might want to check my article on The power of simplicity, or: Why LaTeX needn’t be scarily complicated. If you think LaTeX will slow you down, you might want to check my post on typing fast in LaTeX. But then again, when writing highly qualitative work (like your dissertation should be), it might even be better if your writing slows you down a little. Pause to reflect!

Transition to LaTeX and get a life. A manifesto

“Well, at some point, LaTeX really had more features than Word but nowadays, I don’t see why you should bother using it anymore.” That’s a typical counter-argument, a justification why people don’t use LaTeX and don’t see why it’s worth the effort to learn it and finally make the transition. To this, I want to say: Well, can it do this? Hint: no. I rather suggest you don’t even try. Well at least, don’t hold me accountable if you should try and fail.

If you don’t see why using LaTeX would benefit you, maybe you just haven’t heard the facts yet? And well, probably you aren’t an archaeologist with 1 million images in a 500-page PhD thesis. If you are, don’t commit suicide just yet. There are other ways than Word. If your thesis document won’t even open anymore, don’t despair. Just convert it to LaTeX! And, thank me later.

Citation styles

LaTeX offers citation support. It’s basically a lot like Citavi or Zotero, only less complicated. Not that I have a lot experience with those, I do admit it. But the principle is the same. LaTeX and Bibtex seem complicated at first. But you’re most certainly just so conditioned and accustomed to MS Word workflows that you don’t remember anything else. And what we don’t know, we fear. But you need not fear, LaTeX is here for you.

Yes, LaTeX will throw warnings and errors. It’s not a big deal, really.

People are put off by the fact that you can get warnings or fatal compilation errors. Well yeah, it’s inconvienent to have to debug your own bullshit but well, sorry to have to break it to you, that’s life. Would you rather have a program that doesn’t complain there is a mistake, subsequently hide the problem from you entirely but just stop working for inexplicable reasons and you have no way of escaping? Wait, yes, maybe you do. It’s called MS Word.

You’re not a qualified typesetter

LaTeX is an art. It’s supposed to be an art. Typesetting is an art. And if you haven’t learned to be a typesetter, you probably are not and thus, should not act as a professional typesetter. But MS Word, one hell of a program (and I mean this litterally), makes you believe that you are or you could. It even suggests you should. Hint: You shouldn’t. And in your heart, you really know that’s true.

How to transition from an existing MS Word document or LaTeX-ify your workflow

1. Migrate your document. (Oxgarage, Pandoc, you name it. Read how to do this in my post on who to quit MS Word).
2. Continue writing in Word and transform your stuff to LaTeX before adding the images and thus, killing Word for good. Why the hell would anyone want to continue using MS Word? But hey, my opinion isn’t the truth. It’s just my opinion. Do what works for you. If it contains LaTeX, all the better. The LaTeX Noob uses this workflow and it seeems to work for her. Kind of like a “the best of the two worlds” compromise. You get the parts where MS Word is conveniant (letting your advisor use the comment function, etc.), but the typesetting and image handeling is done in LaTeX.
3.  Just write it in LaTeX. It’s just a question of getting used to it. Using it exclusively will give you just that. Even though I had been using LaTeX for years, transitioning completely made me quite a bit better still. I now also write quick notes in LaTeX without batting an eyelash. Sometimes I still use a GoogleDoc to write things down that are just meant for note-taking, not for creating PDF output.

I will follow up with a post on citation styles and how to import your Citavi to BibTeX, etc. Until then, consider looking up some of my already existing posts which might be of interest, like Jumpstarting: Learn LaTeX in 3 minutes  or A Humanities’ seminar paper with LaTeX – in 10 minutes or How to quit MS Word for good.

Best,

Further resources

The not-so-short intro, also available in German. Tobias Oetiker, Hubert Partl, Irene Hyna & Elisabeth Schlegl: The Not So Short Introduction to LATEX 2ε. Or LATEX 2ε in 139 minutes. Version 6.2, February 28, 2018

https://www.latex-tutorial.com/tutorials/

https://learnxinyminutes.com/docs/latex/

https://en.wikibooks.org/wiki/LaTeX

A Survival Guide for a PhD: http://karpathy.github.io/2016/09/07/phd/

https://www.quora.com/I-wrote-my-PhD-dissertation-in-LaTeX-but-my-advisor-told-me-it-needs-to-be-in-a-format-other-than-PDF-to-send-to-my-committee-members-He-says-it-is-too-difficult-to-make-comments-or-corrections-on-PDF-What-is-the-best-format-for-a-dissertation Quote: “And I’ll even print out the occasional paper and use a red pen. ” yep, good idea. I thought that was actually very sensible advice 😉

https://tex.stackexchange.com/questions/1756/why-should-i-use-latex

https://www.overleaf.com/project/5c42fa03a343e77a02003def (The Scientific Paper: A Template with Tips for Working with LaTeX)

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

Hipster CV – A Template

Dear all,

sorry you haven’t been hearing from me so much lately. It’s been quite busy. To make it up to you, I wanted to share my hipster CV template on this occasion 😉 I will probably explain it later and also probably modify it in a way that it’s easiert to use for a beginner. If you want to use it and but don’t feel comfortable with how the template works, just check where the text you are looking to replace is in the main.tex and replace it with your content. That way, you should get away with fairly limited LaTeX skills and still be able to use the template if you want it.

It is available on the newly created LaTeX Ninja Github! The template is not exactly the same as shown in the Teaser: LaTeX Resumé Template Preview.

So you can look forward to more versions which will be kind of the same style. But I now have so many different elements that I could fill at least 10 different CV templates. Since I didn’t want to fall victim to my own perfectionism, I dedided to share the template now even though it could probably be better. It also doesn’t really comply with my own standards regarding good code, etc. 😉 Well, you can’t always have it all.

It is, however, more of a Saturday afternoon fun thing I did. I won’t give any recommendations as to whether it will be considered as appropriate in your field of work to actually use this CV 😉

Also, I hope I am allowed to have the Jack Sparrow images in the example. I am not so sure about it however. Come visit me in prison if this should go wrong 😉

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

€3.00