tags:

views:

164

answers:

2

I am trying to use the Texments Latex package on Ubuntu to do syntax highlighting. Texments is a wrapper around Pygments. I installed Texments and followed the steps to add the style file to the path. But when I try to compile the .tex file, I get the error.

!Undefined Control Sequence

and then it prints out a bunch of wierd characters and places the ? prompt. Anybody facing this error? What is the resolution?

If there is any other better way to provide syntax highlighting of source code I would be glad to accept it.

I know there is something called "listings" but frankly, i did not find the colors so good in it.

Thanks,

A: 

Texments uses a special control sequence for pdftex to allow shell escapes, needed to call the pygmentize binary. You need to call it with pdflatex, and you need to pass pdflatex the -shell-escape switch. Cf. the texments documentation.

Charles Stewart
You are referring to pdftex or pdflatex command? I did "pdflatex -shell-escape ants.clj" Is this wrong? This is what I understood from the doc.
ajay
pdflatex: I've edited my answer. pdflatex should be run on the .tex file: if you have external code, you should use the \includecode{filename.ext} to refer to the code. pdflatex will then run pygmentize -on this file, creating a temporary latex file that it will then \input. You shouldn't be running pdflatex on any *.clj files.
Charles Stewart
Oh .. That was my typo ... I did pdflatex -shell-escape on the .tex file only. And that gave me that error.
ajay
Looks like you've got a debugging task. I'd start with looking at the *.out.pyg file that the pygmentize creates (or should do!) when invoked by pdflatex. For a wild guess, weird characters sounds like the -f latex option might be being ignored for some reason, so that you are getting junk passed into pdftex's gentle digestive system... Good luck!
Charles Stewart
A: 

Perhaps you could give minted a try … it basically does the same as texments but has more features and is a little more robust in the face of errors.

Furthermore, as the maintainer of minted I’m always glad of error reports. ;-)

Konrad Rudolph