LaTex Macros for Technical Writing

LaTex Macros for Technical Writing

Writing a technical paper or thesis can be hard. But, it shouldn’t be harder than it needs to.

The typesetting system LaTex has become the de-facto standard for writing technical content, especially for those manuscripts which require an army of mathematical notation, variables, and operators.

Here, I like to offer another helpful trick to make your writing more consistent by using macros. Instead of typing out the equations directly, e.g., F = m a, it might be more informative to type the semantics \force = \mass \acceleration. To make this work, the macros need to be defined in the document preamble:

\newcommand{\force}[0]{F}
\newcommand{\mass}[0]{m}
\newcommand{\acceleration}[0]{a}

This approach has several important advantages:

  • Variable names and notation are independent of meaning
  • Variable names can be easily changed later when a name collision occurs
  • Consistent formatting of operators, e.g., bold for matrices
  • Variables and operators are easily searchable in the document
  • Enforces interpreting mindset

Naturally, these macros can be nested to create more highlevel expressions, e.g., \force = \mass \timeDerivative{ \speed }. The additional definitions are:

\usepackage{physics}
\newcommand{\speed}[0]{v}
\newcommand{\time}[0]{t}
\newcommand{\timeDerivative}[1]{\dv{#1}{\time}}

Besides newcommand, there are a few other helpful types of macros:

  • DeclareMathOperator for operator notations like min, max or sign
  • DeclarePairedDelimiter for any delimiter operators like brackets, norms or rounding

All these can be stored away into a .sty file and reused for your next manuscript. By this, you develop over time a set of useful notations and variable conventions and reach the level of consistency you require for your few-hundred-page thesis. A complete example of latex file with notation macros can be downloaded here:

NotationExample.tex

NotationMacros.sty

At first, this might look like extra work, but once you’re at the end of the writing, you will highly appreciate the added flexibility. Happy writing!

Professor of Sound in VR

My research interests include the virtual- and psychoacoustics, physical modeling and the design of virtual worlds.