TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Since Acrobat obviously isn't able to convert XML to PDF from command line, I'm trying to achieve it using LaTeX.

I found the minted package doing a quite good (and simple) job since it uses pygments to do the formatting and then puts back the formatted text into my document.

The package is working fine except when it comes to long lines in the input XML document that I'm trying to convert to PDF: the generated XML content in the PDF exceeds the right border of the document: screenshot

Finally, to put in a question:
Is there any way that I can tell pygments which page width to use for the output (and possibly keep a nice indent when it has to break a line, just like the Internet Explorer does when displaying XML files)?

Yes, I could use the listings package instead, but with that one, AFAIK I have to define the keywords to get a reasonable highlighting for the XML content, right?

share|improve this question
up vote 11 down vote accepted

minted can’t do that and since I have no idea how this line-breaking feature is implemented in listings there are no plans a the moment to add the feature. Sorry. :-(

My advice: for your situation, switch to listings (or break the lines manually).

share|improve this answer
Thanks for the clear statement. I think, I'll go for manual line breaking. Seems less work to me than configuring the listings package for my needs... – eckes Feb 8 '11 at 6:34
minted now has a breaklines feature. – Camil Staps Apr 22 '15 at 19:38

There seems to be no option for pygments to provide a line width. I would assume that it doesn't handles such thing by itself. If it can be done then only in its latex format driver.

Note that minted/pygments using fancyvrb to display the text while keeping \ the macro character. Unfortunately fancyvrb can't break lines itself. The listings package can do that, but doesn't support \ as single escape character! :-(

share|improve this answer

minted provides such break by breaksymbol = =\small\carriagereturn. This breaksymbol defines the symbol to break. So you can use this symbol where ever you want a break. For example, we use carriage return. You can adjust your XML strings by putting a carriage return the place you want a break.



\begin{minted}[breaklines, breaksymbolleft=\carriagereturn]{xml}
<?xml version="1.0"?>
<project name="Package tcolorbox" default="documentation" basedir=".">
Apache Ant build file (http://ant.apache.org/)
share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.