[texhax] Integrating LaTeX and external program with auxiliar file

José Romildo Malaquias j.romildo at gmail.com
Sat Apr 24 14:03:52 CEST 2010


On Sat, Apr 24, 2010 at 12:36:21PM +0200, Philipp Stephani wrote:
> Am 24.04.2010 um 11:46 schrieb José Romildo Malaquias:
> 
> > In order to implement a package for highlighting source code in LaTeX
> > with the help of the external program pygmentize
> > (http://www.pygments.org), I am considering the following procedure:
> > 
> > 1) first compilation of the document: the contents of every ocorrences
> >   of the 'pygments' environment are colected and written to the
> >   auxiliar file \jobname.pygments.
> > 
> > 2) an auxiliar program pygmentex processes the auxiliar file
> >   \jobname.pygments, replacing every snippet of source code by a
> >   highlighted version, using the pygments system, producing a new
> >   auxiliar file \jobname.pygmented.
> > 
> > 3) second compilation of the document: the contents of the 'pygments'
> >   environment, now already hightlighted, are recovered from the
> >   \jobname.pygmented file, and used in the final typesetting of the
> >   document.
> > 
> > I am looking for references on how to implement this procedure in
> > LaTeX. Any help?
> 
> it's already been done, see the minted package

Yes, I know about the minted package. And I have indeed used it. But
minted does not suit all my needs.

For each snippet of source code to be highlighted by pygments, minted
makes an individual call to the pigmentize application.

I am adding a new feature to minted to allow highlighting source code
inline (that is, the snippet is in a running line, not in a paragraph by
itself). With this feature I tend to hightlight many small pieces of
source code. Currently this has the effect of calling pygmentize many
times, making the compilation of the document too long. So I want to
study alternative implementations. The above procedure would call
pygmentex only once. So it would be more efficient.

I do not want to write a new package for that. I would just change
minted. If everything goes well, then I would propose the change to the
author of the minted package.

Romildo


More information about the texhax mailing list