Class Notes 2
Class Notes 2
Contents
1 Introduction
2 The \marginpar command
2.1 Reversing placement of margin notes
2.2 Commands affecting margin note typesetting
2.3 Changing the typesetting of margin notes: ragged right and ragged left
2.4 Example
2.5 The mparhack package: fixing the wrong margin
3 An alternative to \marginpar: the marginnote package
3.1 Example
4 Further reading
Introduction
This article explains how to create margin notes, a popular alternative to
footnotes as a device for adding supplementary information to support the main text
of a document. We also have a help page on the todonotes package which provides
alternative solutions to those presented in this article.
where left text will be used if the margin note appears on the left of a document
page and right text if appears on the right. To be more specific, marginal notes
are normally put on the “outside” of the page—although the meaning of “outside”
depends on the document class you are using and whether you have specified the
twoside package option:
\marginparwidth: determines the width of margin notes and thus the length of lines
typeset in the margin note.
\marginparsep: sets the gap (distance) between margin notes and the text of your
document.
\marginparpush: defines the minimum separation (vertical) distance between \
marginpar notes.
Changing the typesetting of margin notes: ragged right and ragged left
By default, the text of a margin note is typeset is a box which produces typeset
lines of width \marginparwidth. This can result in unsightly gaps between typeset
words as the TeX engine tries to find the “best” line breaks. You can use the
commands \raggedright and \raggedleft to alter the typeset style of the text.
Example
Here is an example which uses several \marginpar commands to demonstrate some of
the features listed above. The example also loads the geometry package to create a
small page size and the hyperref package which provides the \url command used to
credit the source of the text (in the footnote).
Page 1:
Page 2:
Example of the \marginpar command
Example
The following example demonstrates the \marginnote command provided by the
marginnote package:
\documentclass{article}
\usepackage[a5paper, total={3in, 6in}]{geometry} % to create a small page
\usepackage{hyperref} % To use the \url command (in the footnote)
\usepackage{marginnote}
\begin{document}
\section{Lorem Ipsum}
\footnote{Source text: Wikipedia
(\url{https://en.wikipedia.org/wiki/Lorem_ipsum})}But I must explain to you how all
this mistaken idea of reprobating pleasure and extolling pain arose. To do so, I
will give you a complete account of the system, and expound the actual teachings of
the great explorer of the truth, the master-builder of human happiness. \
marginnote{This is a margin note shifted 2cm, \textit{down} the page, relative to
the line in which it is typeset.}[2cm] No one rejects, dislikes or avoids pleasure
itself, because it is pleasure, but because those who do not know how to pursue
pleasure rationally encounter consequences that are extremely painful. Nor again is
there anyone who loves or pursues or desires to obtain pain of itself, because it
is pain, but occasionally circumstances occur in which toil and pain can procure
him some great pleasure. \reversemarginpar\marginnote{This is another margin note
but shifted 2cm \textit{up} the page, relative to the line in which it is typeset.
It is also in the left-hand margin.}[-2cm] To take a trivial example, which of us
ever undertakes laborious physical exercise, except to obtain some advantage from
it? But who has any right to find fault with a man who chooses to enjoy a pleasure
that has no annoying consequences, or one who avoids a pain that produces no
resultant pleasure? [33] On the other hand, we denounce with righteous indignation
and dislike men who are so beguiled and demoralized by the charms of pleasure of
the moment, so blinded by desire, that they cannot foresee the pain and trouble
that are bound to ensue; and equal blame belongs to those who fail in their duty
through weakness of will, which is the same as saying through shrinking from toil
and pain. These cases are perfectly simple and easy to distinguish. In a free hour,
when our power of choice is untrammeled and when nothing prevents our being able to
do what we like best, every pleasure is to be welcomed and every pain avoided. But
in certain circumstances and owing to the claims of duty or the obligations of
business it will frequently occur that pleasures have to be repudiated and
annoyances accepted. The wise man therefore always holds in these matters to this
principle of selection: he rejects pleasures to secure other greater pleasures, or
else he endures pains to avoid worse pains.
\end{document}
Open this example in Overleaf
This example produces the following output:
The above example also loads the geometry package to create a small page size and
the hyperref package which provides the \url command used to credit the source of
the text (in the footnote). After importing the marginnote package by writing \
usepackage{marginnote} you can use the \marginnote command as shown by the two
instances in the example text:
The second \marginnote command operates after a \reversemarginpar was used, causing
it to be placed in the left-hand margin of this single-sided document: