Put section numbers in the margins of your LaTeX reports

For the first installment of our LaTeX mini-series, I thought I’d share one neat little trick involving a tweak to the layout of section headers in LaTeX documents: putting the section number counter in the margin.

This will create the illusion of a “hanging” paragraph below each header. Just add this snippet to your preamble:

\makeatletter\def\@seccntformat#1{\llap{\csname the#1\endcsname\quad}}\makeatother

The effect should look something like this:

As a side note: margins are a sore spot for me in my LaTeX career. I appreciate the default margin-width algorithms, which try to maximize readability by restricting the number of characters per line to ~60. But for many practical layout purposes, smaller margins are desirable. Nevertheless,when wider margins are in use, I particularly like to employ this design aspect in order to balance out the distribution of text on the page without impacting the readability of the paragraphs.


LaTeX mini-series coming soon!

In the coming days and weeks, I’ll be sharing more of my favorite tips and tricks to make your LaTeX documents even more functional and beautiful. I hope to focus on aspects of document and macro design and usage, as well as formatting and aesthetic tricks that I like to employ in my own papers. 

Remember, I am not a LaTeX expert! Indeed, most of these tricks have been discovered on internet message boards or in documents shared by others over the years—and many have been modified, tweaked, or re-invented for my own specific use and taste. 

Happy typesetting!