[texhax] Treating the verbatim environment much like figures

Alex Scorpan scorpan at gmail.com
Sun Jul 23 22:20:47 CEST 2006


> 1) They don't necessarily appear "inline" but are positioned where  
> LaTeX
> thinks best, just like figures
> 2) I can reference them with a \ref and a \label

Why not simply

	\begin{figure}
	\begin{verbatim}
	Blah
	\end{verbatim}
	\caption{Gaga}
	\label{gugu}
	\end{figure}

As \caption{Gaga} will produce something like

	Figure 55. Gaga

you should also add to your preamble

	\renewcommand\figurename{Code chunk}

and then \caption{Gaga} will produce

	Code chunk 55. Gaga

If you plan on having a list of code chunks (like a table of  
contents), introduced with
	
	\listoffigures

then, at the outset, that one will be be titled "List of Figures";   
you need to add to your preamble

	\renewcommand\listfigurename{List of little Code chunks}

and then \listofigures will produce a listing of all code chunks,  
with the new title.


If you have actual figures in your document, you could highjack  
tables in a similar manner.  If you need both actual figures and  
actual tables, then... well, maybe you don't.

Alex


More information about the texhax mailing list