Howto Write a Thesis using LaTeX: Custom commands

The tweaks presented in this post are in my opinion the most useful ones. When writing a thesis, there are typically a few expression and words that appear at many many places in across the document. I wrote my thesis about a slime mold called Physarum Polycephalum and I can’t count how often I needed to write this name in my thesis. Lazy as I am, I didn’t want to write this nasty word each time and also I wanted to avoid misspelling of it.

Fortunately, LaTeX gives the opportunity to define commands by yourself. This means, you can define a new command which is inserting a self defined string and use it across your document. To do so, simply write:

\newcommand{\phys}{\textit{Physarum Polycephalum}}

The expression in the first curly braces defines the command name, I called it \phys, and the expression in the second curly braces is defining the command to be executed. Here I want the string Physarum Polycephalum to be printed in italic style. So far so good, but where exactly is the benefit?

At any place in your document where you want to insert Physarum Polycephalum, no matter if it within a text section or a caption of an image, you simple write

 My topic is about \phys{}, which is a slime mold.

Please note the the curly braces after the command are very necessary in order to get LaTeX manage white spaces after the inserted text correctly!

Despite from saving time and reducing misspellings, there is another great benefit of using this technique. It allows you to easily change these word at only one position. Image I finished writing my whole thesis and after that, my Prof tells me that polycephalum should be written in lower case, I am unbelievably thankful that I do NOT need to go through my hundreds of pages and search for positions where I need to replace it. I only need to change it at one simple position!

By the way, one typical command I use in all my documents is

\newcommand{\etal}{\textit{et.~al.}}

Another trick that is somehow related to this topic, turned out to be very useful for me while writing the thesis. I defined three little commands and used them to give nodes to myself in the document:

\newcommand{\note}[1]{\color{red}(#1!)\color{black}}
\newcommand{\missref}{\note{[REF]}}
\newcommand{\todo}[1]{\textcolor{blue}{[Todo: #1]}}

The first command inserts a note for me in red color, so that I cannot miss the note on reviewing the document. The second one is used for indicating that there is a reference missing and that I need to insert it later on. But please, I really recommend to insert references on the fly! Believe me, after weeks or month of writing your thesis, the very last thing you want to do is inserting 100+ references before submitting your thesis. I used the third command to remind myself that there is something left to do. Have a look at the screenshot of the document using these commands, isn’t that really helpful for reviewing?

GlobalCommands

The command of this text part is looking like

Sch\"on \etal{} \missref{} have been scientifically proven that the 
psychological stress during writing your PhD thesis leaves a disorder 
from that you never will retire completely \note{Better double check 
that!}. 
\todo{Search for and include some examples here, maybe a graphic!}
Warning: count(): Parameter must be an array or an object that implements Countable in /customers/5/e/0/torsten-schoen.de/httpd.www/wp-includes/class-wp-comment-query.php on line 399

5 thoughts on “Howto Write a Thesis using LaTeX: Custom commands

  1. Pingback: sHowto write a thesis using LaTeX, Part 3: Tips and Tricks | Torsten SchönTorsten Schön

  2. Pingback: Latex tips | thanhtrungle

  3. For the last commands to leave notes for yourself, you have to add \usepackage{color} in the preamble in the main document thesis.tex.

Leave a Reply

Your email address will not be published. Required fields are marked *