1

I read that enabling breaklines in listings will make the included code wrap, but it does not in my case. Maybe something is interfering with this function?

Full code is shown below:

\ifdefined\docdefined
\else
    \documentclass[a4paper,twoside,12pt, openright]{report}
    \input{include_start}
    \begin{document}
\fi

\definecolor{dkgreen}{rgb}{0,0.6,0}
\definecolor{gray}{rgb}{0.5,0.5,0.5}
\definecolor{mauve}{rgb}{0.58,0,0.82}

% START DOCUMENT

\begin{appendices}
\makeatletter

\chapter{GUI Code}
%%%%%%%%%%%%%%%%%    XML
\section{Code XML}

\lstset{language=XML, 
numbers=left, 
frame=single, 
commentstyle=\color{dkgreen}, 
basicstyle={\scriptsize\ttfamily}, 
keywordstyle=\color{blue}, 
%identifierstyle=\color{blue}, 
stringstyle=\color{mauve},
captionpos=t,
showstringspaces=false,
breaklines=true,
breakatwhitespace=true,
tabsize=3,
caption={\protect\filename@parse{\lstname}\protect\filename@base\text{.}\protect\filename@ext},
}

\begin{frame}

\lstinputlisting{C:/Users/hab/SW/GUI/android/AndroidManifest.xml}    

\end{frame}

\end{appendices}

% END DOCUMENT
\ifdefined\docdefined
\else
    \input{include_end}
    \end{document}
\fi
3
  • 1
    Unless we see what AndroidManifest.xml contains, it will be difficult to diagnose the problem.
    – jub0bs
    May 1, 2014 at 7:47
  • Is it really unclear what I am asking here? The title is very specific and full code example is provided with explanation at top. I would appreciate feedback how this is unclear to avoid further unclear questions. May 1, 2014 at 15:26
  • Even though you provide what looks like a MWE, because you don't provide your XML file, 1) your code is not compilable, and 2) we have no way of figuring out what, in that XML file, might prevent line breaking. You managed to answer your own question because you can see what that file contains, but nobody else here can. That's why your question was closed as unclear. In the future, always make your MWE self-contained and compilable (have a look at the filecontents package for writing to external files); you will likely get at leat one satisfactory answer more quickly.
    – jub0bs
    May 1, 2014 at 18:03

1 Answer 1

1

The solution was simple.

I had:

breakatwhitespace=true

which mean it will only break at whitespace. Since some of the XML does not have whitspaces and long strings, it will not wrap!

Solution:

breakatwhitespace=false

It does now wrap even if no whitespace is found.

Not the answer you're looking for? Browse other questions tagged .