0

I am finishing my thesis in Overleaf and need to add an XML file in the appendix. I use lstlisting package. The problem is that the file contains strings with many characters and does not fit in the page. The option breaklines = true not break large strings, only break lines between words. How can I display the file appropriately?

The code that generates the image below is

\lstset{
language=xml,
tabsize=3,
%frame=lines,
caption= Archivo ejemplocfdv3.xml utilizado para generar los sellos,
label=code:sample,
frame=shadowbox,
rulesepcolor=\color{gray},
xleftmargin=20pt,
framexleftmargin=15pt,
keywordstyle=\color{blue}\bf,
commentstyle=\color{OliveGreen},
stringstyle=\color{red},
numbers=left,
numberstyle=\tiny,
numbersep=5pt,
breaklines=true,
postbreak=\mbox{\textcolor{red}{$\hookrightarrow$}\space},
showstringspaces=false,
basicstyle=\footnotesize,
emph={food,name,price},emphstyle={\color{magenta}}}
\lstinputlisting{ejemplocfdv3.xml}

Example of lstlisting not breaking long strings

  • 1
    Welcome to TeX SX! You might use the \seqsplit command, from the homonymous package. – Bernard Oct 16 at 21:26
  • How you use it with the \lstinputlisting{ejemplocfdv3.xml} command? The only way I see to use the \seqsplit is writing the code inside a \begin{lstlisting} ... \end{lstlisting} but the command \seqsplit can not be execute inside . Also the break line inside it display a white line. – Diego Olvera Oct 17 at 0:45
  • 1
    Take a look at this link: tex.stackexchange.com/questions/140637/… – Alan Xiang Oct 17 at 1:49
  • @AlanXiang the link does not solution my problem. The post states that lstlisting does not break line if the character is a letter. It only break lines when a character of the category other is found (see the line with only a + and / character on the picture above). The link only specifies how to prevent break line with other characters by adding them to the letter category using alsoletter. The problem is to split long sequence of characters in base 64 alphabet. The user @TakingItCasual address this problem asking for a breakanywhere option in lstlisting. – Diego Olvera Oct 17 at 18:07

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.