2

I try to write a longer story. To make the structure more clear I use the command \marginpar. But that is still time consuming when it comes to the point when I need to find a certain passage. That is the reason, why it would be helpful to have some kind of Table of Marginpars.

My question: Is it possible to force the marginpar elements to appear in the ToC and/or even better in a separated Table of Marginpars?

Note: I am aware that an alternative solution could be to define the section command in a way that it is typeset as a marginpar.

lockstep
  • 250,273
Philip
  • 3,415

1 Answers1

3

I picked an example from this TeXblog.org entry on "new lists of..." and added a hint for adding definitions to macros (since I was not in the mood to look for \marginpar definition and rewrite it) from this other TeXblog.net entry on \expandafter

\documentclass{article}
\usepackage{tocloft,blindtext}
\usepackage[english]{babel}
% First we create new list of marginpars with the help of tocloft package:
\newcommand{\listmarginparname}{List of Margin Pars}
\newlistof{marginpar}{lom}{\listmarginparname}
% Then we define a command that increments a counter and writes it in the created list
\newcommand{\mpar}[1]{%
\refstepcounter{marginpar}
\addcontentsline{lom}{marginpar}{#1}}
% Now we have to make \marginpar command to include the counting macro
\newcommand*\origmpar{}
\let\origmpar\marginpar
\renewcommand*\marginpar[1]{\origmpar{#1}\mpar{#1}}
\begin{document}
\listofmarginpar
\section{Two marginpars}
\blindtext \marginpar{First Marginpar Test}
\blindtext \marginpar{Second Marginpar Test}
\section{One marginpar}
\blindtext \marginpar{Third marginpar Test}
\end{document}

and it worked.

henrique
  • 6,616