I use marginnotes (sometimes inside of mdframed environments) to write at the margin whenever a concept is defined, e.g.:
\documentclass{article}
\usepackage{marginnote,tikz,mdframed}
\usepackage{amsthm}
\newmdtheoremenv[linecolor=black]{definition}{Definition}
\newcommand{\defi}[1]{%
\marginnote{\tiny #1}%
\emph{#1}}
\begin{document}
\begin{definition}
An \defi{apple} is a fruit, a \defi{mirror} is an object
and a \defi{fish} is an animal.
\end{definition}
\end{document}
Alas, I have a problem when two or more things are defined in the same line---in the example, "apple", "mirror" and "fish" overlap in the margin.
I am aware that this is a feature, but wonder whether it would be possible to combine the contents of both calls to marginnote.
(Replacing marginnote by marginpar gives me "Float(s) lost.")
Ideally, in the margin I would read "apple, mirror, fish"
I wonder if it is possible to change marginnote so that
- when a
\marginnote
is reached, its argument is appended to some list (of tokens?) ... ideally, adding some separator such as,
); - when the marginnote is typeset, it resets this list of tokens to nothing
I am also aware of the advanced sidenotes features of memoir, but I have to stick with article.
As a last resort, if this is not possible, I am considering the following:
- every time
\defi
is called it appends to a comma-separated list of definitions; - using something like everypage to then call a tikzpicture to overlay the list on the margin of the document and reset the list contents
Edit: @TeXnician pointed out a similar question at Margin note automatic concatenation, however David's answer there has the side effect of adding the notes inside the mdframed box. (And I did not manage to run Tobi's answer, but I'm guessing I might run into the same Float(s) lost problem.)