0

I'm writing a document using minted. I installed Python, pygmentize, everything works great. But there is a behaviour I don't understand. I want to break the text inside the minted environment at the character '|'. When I try to do it at

\begin{minted}[breaklines, breakafter=|]{python}
some_string = 'SomeTextThat|GoesOnAndOnForSoLong|ThatItCouldNeverFitOnOneLine'
\end{minted}

LaTeX breaks the line right after the second |. But with this piece of code instead

\begin{minted}[breaklines, breakafter=|]{bash}
tail -n 39 $target | awk '{print($NF" "$0)}' | sort -g -t@ -k2 | cut -f2- -d' ' > /tmp/\ /"$NEWFILE" #@15
\end{minted}

it doesn't work, breaking the line after the last space before going out of the box. enter image description here Where do I go wrong?

1

The breakafter and breakbefore options allow specifying break locations in addition to spaces, rather than instead of spaces. You can disable spaces as break locations. One way to do this is to set spaces as visible and then define the space character as an (invisible) non-breaking space. You will probably also want to turn off pre-break symbols in a case like this (breakaftersymbolpre).

\begin{minted}[breaklines, breakafter=|, showspaces, space=~, breakaftersymbolpre={}]{bash}
tail -n 39 $target | awk '{print($NF" "$0)}' | sort -g -t@ -k2 | cut -f2- -d' ' > /tmp/\ /"$NEWFILE" #@15
\end{minted}
  • Thank you for your answer. I tried your workaround but it looks like it doesn't work. I copypasted your comment but it doesn't break after '|'. The line is typeset on a single line going outside the sheet. The 'issue' looks like belongs to 'showspaces': if I take it away it breaks after the spaces but at least it doesn't print on a single line. – Raffaello Cørsini May 29 '18 at 20:25
  • @RaffaelloCørsini You might try updating your packages. If you don't have a relatively recent minted and fvextra, this won't work. – G. Poore May 29 '18 at 20:30
  • You were right, I updated the packages and now the code does what it was supposed to do. Thanks again. – Raffaello Cørsini May 31 '18 at 6:08

Your Answer

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

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