Graphics, Figures & TablesPlace a Verbatim environment within a Figure, i.e. label it?

Information and discussion about graphics, figures & tables in LaTeX documents.
Post Reply
mssm
Posts: 4
Joined: Thu Aug 19, 2010 7:46 pm

Place a Verbatim environment within a Figure, i.e. label it?

Post by mssm »

I would like to place a Verbatim environment as provided by the fancyvrb package into a figure environment, so that I can add a label to the Verbatim and reference it later.
Is this at all possible?

Code: Select all

\begin{figure}
\begin{Verbatim}[frame=single,numbers=left,label={Sample input},commandchars=\\\{\}]
Some code \label{line_label}
\end{Verbatim}
\label{verbatim_label}
\end{figure}
As of now, this piece of code does not do anything.

Recommended reading 2024:

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

NEW: TikZ book now 40% off at Amazon.com for a short time.

gmedina
Posts: 2313
Joined: Wed Jul 11, 2007 11:45 pm

Place a Verbatim environment within a Figure, i.e. label it?

Post by gmedina »

The code you posted doesn't generate a string for cross-reference because inside the floating environments the string is generated by the \caption command.

Anyway, your request seems a little odd to me: your verbatim code doesn't get any numbering so what's the point of cross-referencing it?
1,1,2,3,5,8,13,21,34,55,89,144,233,...
Post Reply