Generalmargin note in tabbing environment

LaTeX specific issues not fitting into one of the other forums of this category.
Post Reply
george
Posts: 3
Joined: Fri Feb 08, 2008 12:40 am

margin note in tabbing environment

Post by george »

Hi -

I need to put a margin note (a file name) next to a code example in my text. I'm currently using the tabbing environment to display my code, and considering switching to the listing package.

If I try to use \marginpar in the tabbing environment I get an error: LaTeX Error: Not in outer par mode.

If I try to put one in a lstlisting environment it just gets printed verbatim.

I've tried putting the \marginpar just before the \begin of the environment, but it ends up aligned with the last line of the preceding paragraph instead of with the first line of the code example.

Any suggestions?

George

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

Learn LaTeX easily with newest books:

The LaTeX Beginner's Guide: 2nd edition and perfect for students writing a thesis

The LaTeX Cookbook: 2nd edition full of practical examples for mathematics, physics, chemistry, and more

LaTeX Graphics with TikZ: the first book about TikZ for perfect drawings in your LaTeX thesis

User avatar
Juanjo
Posts: 657
Joined: Sat Jan 27, 2007 12:46 am

margin note in tabbing environment

Post by Juanjo »

Take a look at page 38 in the manual of the listings package. Try this:

Code: Select all

\begin{lstlisting}[escapechar=!]
First line of code
Second line of code
Third line of code!\marginpar{\footnotesize A marginal note}!
Fourth line of code
Fifth line of code
\end{lstlisting}
george
Posts: 3
Joined: Fri Feb 08, 2008 12:40 am

Re: margin note in tabbing environment

Post by george »

Perfect! Many thanks Juanjo.

George

(Sorry I posted this in the wrong topic. Is there a way to move it to latex >> general instead of latex-community >> general?)
Post Reply