| March 26, 2011 10:15 pm

Though it’s not really related to my work, one of my side interests is is the workflow of writers. I’m fascinated by where ideas come from, the tools we use to corral them, and how great thinkers create. While a portion of that interest derives from a practical desire to emulate their techniques, I’m also very curious about the underlying ecosystem of success, creativity, and innovation.

As I’ve traipsed across the ideas landscape and meandered the moors of their implementation, there is one lesson that rears its head over and over: great success – whether intellectual or commercial – turns on the hinges of small details. Steve Jobs and his iPhone, for example, weren’t successful because iPhone was new and innovative – in most meanings of the word, it wasn’t – but because it superbly implemented a core set of powerful features. It, in effect, got all of the important things right.

While I can (and will actually, it’s part of the promotional plan for the book) write a whole blog post on this idea, I wanted to talk briefly about one example in a Lifehack post. (This is mostly because I stumbled across it the other day and have found it to be brilliantly useful.) Specifically:

What is the best way to structure margin notes and comments in a book or report?

After such a lofty lead up, you might find yourself asking, “What the hell?! Who cares about how margin notes are structured in books and reports?!”

The short answer to that question is, “I do, and anyone who cares about letters and ideas should as well.”

I could spend pages and thousands of words talking about why typography/page layout matter. (Actually, I have. Not the point, though). But let me boil it down to the most important point: the design and typography of a report is the first thing a reader interacts with. It is, in effect, the user interface for your ideas.

For that reason, it needs to be highly accessible. It needs to enable a reader to figure out where she is and how to get to where she wants to be. A poor typographical design obfuscates beautiful words. Beautiful typography makes them dance and sing. I’d even go so far as to say that many good books have been destroyed by poor design and mediocre ones saved by it.

Margin notes and their layout matter (as a component of book design), a lot.

Ragged Marginalia

There are many different ways that notes (both margin and foot) can be structured, and what effects they might have on the text. But I don’t really want to get into that here. Better to simply highlight one of my favorite layouts: that of margin notes that are typeset with a ragged outer margin against a flush block of text.

It’s a beautiful and highly functional way to contain the errata of a manuscript. Below are a couple of example layouts from Robert Bringhurst’s “The Elements of Typographic Style” and the “Philosophy of Typography” by Steven Acres.

The Elements of Typographic Style - Marginal Notes

The Elements of Typographic Style - Marginal Captions

But while it may be beautiful and functional, it isn’t the easiest layout to use. Trying to typeset margin notes in Word is impossible. It simply cannot be done. (Or not by any sane person, at any rate.) And while it can be accomplished using InDesign/Scribus, it’s a pain of epic proportions. You quite literally have to adjust each note by hand.

This might lead you to think that it is outside the ken of mere mortals. But, have faith! It’s actually pretty easy to accomplish with LyX, LaTeX, and the memoir class. Here’s how it works.

memoir Implementation

The memoir class, by Peter Wilson, may be the Great Start of Africa of LaTeX document classes. In the right hands, it can be used to typeset nearly any type of book imaginable. And it turns out, that with a little bit of trickery, you can use its \marginpar and sidecaption environments to automatically incorporate ragged marginalia into your books and reports.


First, this is how you set up ragged margin paragraphs:

{\marginpar{\raggedright #1}}
{\marginpar{\raggedleft #1}}

The code creates a new command called \ragmarpar, which is used to typeset your ragged margin notes. You can just add it to the preamble of your LaTeX (or LyX document) and then start to write. It just works.

This is how you would add a new ragged margin paragraph:

\ragmarpar{One of the great secrets to working productively is linking different tasks together in an automated fashion. This is referred to as a workflow. When harnessed properly a workflow can shave minutes, or even hours, off a particular job.}

Note: For those who’d like to know how the code works, here’s the breakdown. The first line creates a new counter called pl. As the document is typeset, the document processor then looks at this counter to determine whether your notes should be typeset ragged right or ragged left. For even pages, they are typeset ragged right. For odd pages, ragged right.


A similar technique can be used to typeset figures in the margin, through the use of the sidecaption environment. First, here’s the code that needs to be added to your preamble.


Note: Like the \ragmarpar command, this code makes use of the counter pl to track which page the document is on. If an even page, the captions are typset ragged left. For odd pages, ragged right.

Like the previous command, once you’ve added the code to your preamble, it will just work. Here’s a simple example of the sidecaption environment at work.

\begin{sidecaption}{Caption Text}

LyX Insets

Both work from within LyX, as well. If you’re a LaTeX purist, you can just use TeX code. If, however, you would like to use custom insets, add this code to the local layout of your document.

Note: Once you’ve pasted in the code (Document Settings > Local Layout for users of LyX 2.0), you’ll need to save your document and then reload it. (Meaning you close it and then open it again.)

InsetLayout Custom:Margin_Paragraph
LyXType                    custom
Labelstring                ragmarpar
Decoration                classic
Color                collapsable
Size                Small
MultiPar                true
LatexName                ragmarpar
LatexType                command

This will create a custom margin paragraph inset that can be used for \ragmarpar. It’s available from the Insert > Custom menu. Just insert a new inset and type away.

This block will enable a sidecaption style.

Style Side_Caption
Category                Special_Commands
Margin                    Static
LatexType                Environment
LatexName                sidecaption
NextNoIndent                1
TopSep                    0.5
ParSep                    0.5
BottomSep                0.5
Align                    Block
AlignPossible            Block, Left, Right, Center
LabelType                No_Label
HTMLTag                    sidecaption
HTMLItem                p
RequiredArgs                1

The use of the sidecaption style is a little more involved. To enable it, first insert a new figure float. Then, within the figure float, change the style from “Standard” to “Side Caption.” Finally, to add the caption text, click on the “Short Title” inset available in the “Insert” menu. (Even though it says “Short Title” it actually means “optional argument.”) Then, type your figure caption into the optional argument inset.

When finished, just compile your draft in the traditional manner, and voila!


6 Responses to “LaTeX Hack: Ragged Page Marginalia with the memoir class”

jre wrote a comment on November 29, 2011

I kind of like “Great Start of Africa.” I followed the link expecting something about early hominids and the Rift Valley, and found diamonds instead.

Thomas wrote a comment on December 21, 2011

No need for memoir–margin notes and captions are built into the tufte-book Latex class.

Rob Oakes wrote a comment on December 21, 2011

I would generally agree, since I love the Tufte classes for nearly all of my class handouts; but, the Tufte classes aren’t a good fit for all types of documents. In those cases, it can be really handy to use another class, such as memoir. That’s when this little hack has been useful for me, at least.

Thomas wrote a comment on December 21, 2011

Classicthesis is another good one for margin notes.

P. K. Andersen wrote a comment on July 2, 2012

The book shown in the color photos is indeed very attractive.

Question: How might one use the memoir class to place the margin notes and captions always in the left margin?

Larry Tate wrote a comment on October 5, 2014

Can you provide the complete preamble for the beautiful Memoir layout with the margin paragraphs above?

Care to comment?