So I was trying to modify the default marginpar command by making the margin text appear in italic. Now the following alone didn't work:


Which to me would seem straight forward. Renew the \marginpar{}command with the same \marginpar{} that is defined by default and expand it by the italic part with the argument. As I mentioned, that didn't work.

This however did work:


So my question is, why is this step necessary to define a command that refers to marginpar and then redefine that alternate command with renewcommand. This process makes no sense to me.

4 Answers 4


To make sense of the way TeX works you have to remember that it is essentially a macro expansion language, your world view that has the notion "with the same \marginpar{}that is defined by default " doesn't correspond to TeX's world view at all.

With the definition you have, given


TeX sees the first token and replaces it by its definition so


TeX then starts processing the stream again, sees the first token is \marginpar so replaces it by its definition


and you are in a never ending loop. If you want to save the old definition, you need to do that explicitly, as you found.


Because what you are doing here is "text replacement", i.e., your definition goes like...

\marginpar{test} -> \marginpar{\textit{test}} -> \marginpar{\textit{\marginpar{\textit{test}}} -> ...

etc. The \let in your second code excerpt saves the definition of \marginpar into \oldmarginpar. Then, the new \marginpar uses the old definition plus your italic command.


It is always best not to rename TeX or LaTeX primitives, try it this way:

\sidepar{test it}

The original posters problem looks solved to me. As a minor addition, the following marginpar variation is working well for me: I'm using marginpars to keep track of notes in-text, to mark things that need more work. To be able to find them, I've added indexing, and optionally disabling their output altogether

% Define new command \marpar to replace  \marginpar.
% usage is identical, \marpar will print the marginpar in fnsize
% (footnotesized) text, which makes the sometimes lengthy comments less
% obtrusive and improves legibility.
% Add indexing of marpars

\newcommand{\marpar}[1]{\marginpar{\fnsize #1}\index{TODO}}

I like to use the opt environment to allow toggling with tags:

\newcommand{\marpar}[1]{\opt{note}{\marginpar{\fnsize #1}\index{TODO}}}

Another way to suppress output of those modified marginpars if the opt environment cannot be used would be to hide the marginpar inside a macro that never gets called.

\newcommand{\marpar}[1] {{\newcommand{\lastunprintedcommand}{\marginpar #1}}}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .