[vox-tech] Chapters and links within pdf files

Peter Jay Salzman p at dirac.org
Mon Dec 5 06:45:13 PST 2005


On Mon 05 Dec 05,  8:32 AM, Ken Bloom <kbloom at gmail.com> said:
> Peter Jay Salzman wrote:
> >
> > Along with amsmath, geometry, and fancyvrb, I think hyperref is in my top
> > list of groovy latex packages now.  Thanks!
> 
> ooh! fancyvrb looks cool! (getting my code examples into verbatim mode
> with a single character, and many other features)
> 
> --Ken

Oh, yeah.  Fancyvrb is one of those packages that every time you read a
section of the documentation, you find another feature which makes you
wonder how you could've lived without.

One of my favorite custom designed environments:


\DefineVerbatimEnvironment%
{VerbatimCmdProg}%
{Verbatim}%
{numbers=left, fontsize=\relsize{-2}, frame=single, commandchars=\\\{\}}



   \begin{VerbatimCmdProg}
   \textit{...previous code....}

   int i = 9999;
   while (i--) \{\label{topOfLoop}
      printf("i is \%d\Backslash{n}", i);
      ... lots of code ...
   \}

   \textit{...future code....}\label{until:9}
   \end{VerbatimCmdProg}

   The top of the loop is line~\ref{topOfLoop}


Basically, this environment:

   * places line numbers on the left
   * formats the code in a fontsize 2 lower than the current fontsize
      (really nice for long listings)
   * puts a thin single border around the entire code listing
   * allows me to \label certain lines.   very nice so you can add/delete
      lines from the code, and your reference remain valid.

The only drawback to "commandchars" (which allows labelling lines) is that
you need to escape '\' and '}' and '{'.  But this package is REALLY nice
when when you want create slides for a talk on programming.

Pete

ps- \relsize requires the relsize package.


More information about the vox-tech mailing list