# Make defined words appear standalone in left margin

I've seen this in textbooks before, so I imagine it's possible. What I would like is for a defined word to show up in the left margin for easy identification when scrolling through a document.

For example, with the following sentence I would like the word "bijection" to appear in the left margin, bolded.

A function $f:A \rightarrow B$ is called a \textbf{bijection} or bijective function if
it is both surjective and injective.


I have just wrapped it in \textbf for now, but this is find-replaceable in my current document.

I imagine this could be done with an indexing package, but haven't found a solution yet. Any help would be appreciated.

• Something along the lines of \newcommand{\keyword}[1]{\marginpar{\textsf{#1}}\textbf{#1}} and the \keyword{bijection} would print the word in the margin in a sans serif and in the text in bold (to be tweaked as you like). See also the CTAN packages for adding marginal notes (or use the memoir class).
– jon
Aug 21, 2014 at 15:04
• This works well, using \reversemarginpar to get it on the left side. I used this approach since it allows stacking if there are multiple "keyword"s on the same line. Aug 21, 2014 at 15:20

## 1 Answer

You can use marginnote package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{marginnote}
\newcommand{\magic}[1]{%
\textbf{#1}\marginnote{#1}
}
\reversemarginpar
\begin{document}
A function $f:A → B$ is called a \magic{bijection} or bijective function if
it is both surjective and injective.
\end{document}


• This works well but I went with the \marginpar approach since it stacked words if more than one appears on a line. Aug 21, 2014 at 15:21