Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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.

share|improve this question
add comment

1 Answer

up vote 3 down vote accepted

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.

share|improve this answer
    
Thank you. That works perfectly well. –  Philip Feb 23 '12 at 10:08
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.