# Breaking long lines using latex with minted and pygments

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:

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?

-

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).

-
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! :-(

-

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.

\usepackage{minted}
\usepackage{dingbat}

\begin{document}

\begin{minted}[breaklines, breaksymbolleft=\carriagereturn]{xml}
<?xml version="1.0"?>