Introduction to Margin Notes
In academic writing, textbooks, and technical documentation, you often need to provide supplementary information without interrupting the flow of the main text. This is where margin notes and side notes come in.
Unlike footnotes, which appear at the bottom of the page, margin notes are placed in the white space to the left or right of the main text block. They are perfect for:
- Editorial comments and "To-Do" items.
- Defining key terms.
- Adding historical context or "fun facts."
- Placing small figures or citations (common in the "Tufte" style of book design).
In this guide, we will explore the built-in LaTeX commands for margin notes and look at powerful packages that give you more control over their appearance and behavior.
1. The Basic \marginpar Command
LaTeX includes a built-in command for margin notes called \marginpar. It is simple to use and does not require any extra packages.
Basic Syntax
To create a margin note, simply place the command where you want the note to be anchored:
\marginpar{This is a note in the margin.}How it Behaves
- One-sided documents: Notes appear in the right margin by default.
- Two-sided documents: Notes appear in the "outer" margin (right side on odd pages, left side on even pages).
- Alignment: If you want different text depending on which side the note lands, you can use the optional argument:
\marginpar[left-side text]{right-side text}.
Example: Standard Usage
\documentclass{article}
\usepackage[utf8]{inputenc}
\begin{document}
The theory of relativity, developed by Albert Einstein,
transformed our understanding of space and time.
\marginpar{\raggedright \small Einstein published the Special Theory in 1905.}
This work introduced the famous equation $E=mc^2$.
\end{document}Note: By default, margin notes are justified. Because margins are narrow, this often results in ugly spacing. Using
\raggedrightor\raggedleftinside the note (as seen above) usually looks much better.
2. Setting Up Your Layout with geometry
Before you start adding many margin notes, you must ensure your page has enough space for them. If your margins are too narrow, your notes will be cut off at the edge of the paper.
The geometry package is the best way to handle this. You can specifically allocate space for the "marginpar width."
\usepackage[
top=2cm,
bottom=2cm,
left=3cm,
right=5cm, % Large right margin for notes
marginparwidth=4cm, % Width of the note box
marginparsep=0.5cm % Gap between text and note
]{geometry}3. Using the marginnote Package
The standard \marginpar command is a "float," meaning LaTeX tries to find the best place for it so it doesn't overlap with other notes. However, this means it cannot be used inside certain environments like frames, equations, or lists.
The marginnote package provides a more robust alternative that places the note exactly where you call it.
Why use marginnote?
- It works inside math mode and complex environments.
- It allows for more precise vertical positioning using an optional offset.
Example: Using marginnote
\usepackage{marginnote}
\begin{document}
Here is a complex sentence that requires a note
exactly at this point.\marginnote{Fixed note.}
% Moving a note 1cm down manually
This note is shifted.\marginnote[voffset=1cm]{Lowered note.}
\end{document}4. Advanced Side Notes with the sidenotes Package
For professional-looking documents (like the famous Tufte-Latex style), you might want more than just text. You might want side-figures, side-tables, or side-citations. The sidenotes package is designed for this purpose.
Side Figures
Instead of a giant image breaking up your text, you can place a small thumbnail in the margin.
\usepackage{sidenotes}
\usepackage{graphicx}
\begin{document}
The Golden Ratio is found often in nature.
\begin{sidecaption}{An illustration of the Nautilus shell.}[fig:shell]
\includegraphics[width=\marginparwidth]{nautilus.jpg}
\end{sidecaption}
\end{document}Key Features of sidenotes:
\sidenote{}: Similar to a footnote, but places the text in the margin with a superscript number in the main text.sidefigureandsidetable: Environments that wrap your content into the margin space.
5. Customizing Styles and Appearance
To make your margin notes stand out (or blend in), you should create a custom command. This ensures consistency throughout your document.
Example: Colored and Italicized Notes
Add this to your preamble to create a "Teacher's Comment" style note:
\usepackage{xcolor}
\usepackage{marginnote}
% Define a custom command
\newcommand{\teacher}[1]{%
\marginnote{\itshape\small\color{blue}#1}%
}
\begin{document}
The student wrote a very long paragraph here.
\teacher{Please shorten this section for clarity.}
\end{document}6. Best Practices and Common Pitfalls
Best Practices
- Keep it Brief: Margins are small. If your note is longer than a few sentences, consider using a traditional footnote.
- Font Size: Always use
\smallor\footnotesizefor margin notes to distinguish them from the body text. - Alignment: Use
\raggedright(or\RaggedRightfrom theragged2epackage) to prevent awkward hyphenation in narrow columns.
Common Pitfalls to Avoid
- Overlapping Notes: If you place two
\marginparcommands too close together, they may overlap. If this happens, you may need to manually adjust their vertical position or use themarginfixpackage to help LaTeX manage the spacing automatically. - Margin Depth: If a margin note is called near the bottom of a page, it might "bleed" off the bottom edge. Check your page breaks carefully.
- Reverse Margins: If you want notes on the "wrong" side (e.g., the left margin in a one-sided document), use the command
\reversemarginpar. To switch back, use\normalmarginpar.
Pro Tip: If you are using margin notes for proofreading, the
todonotespackage is incredibly helpful. It uses margin notes to show "To-Do" items and can even draw lines connecting the note to the specific word in the text.
