In editing big documents, I find myself having to refer back to something I’ve written somewhere else. Typically I’m referring to the PDF rather than the raw LaTeX, and I can’t remember the section labels I’ve added. To help me with this, I’ve added this wodge of code into my preamble:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 |
\usepackage{etoolbox} % modify if margins uneven (i.e. in a book) \newcommand{\weeboxL}[1]{\parbox[t]{15mm}{\raggedright\footnotesize#1}} \newcommand{\weeboxR}[1]{\parbox[t]{15mm}{\raggedleft\footnotesize#1}} % this selects which command to use for margin notes \newcommand{\marg}[1]{\marginpar[\weeboxL{#1}]{\weeboxR{#1}}} \newcommand{\todomarg}[1]{\marg{#1}} % comment/remove this stuff to stop doing margin labels! \let\jcflabel\label \renewcommand{\label}[1]{\jcflabel{#1}\marg{#1}} \AtBeginEnvironment{figure}{\renewcommand{\label}[1]{\jcflabel{#1}}} |
This defines a few extra commands for doing margin notes, and then redefines the \label
command to also add a margin note with the name of the label, so it’s right next to where it’s used in the resulting PDF. It’s really handy.
You can also add “To-do” notes yourself, or any kind of comment in the margin, by just using the \marg
command:
1 |
\marg{This is a margin note.} |
Note that this won’t work inside a figure – LaTeX doesn’t know where the margins are inside a figure! Some of the logic in the code above is to ensure that margin notes don’t appear for figure labels.