5

I try to get line-wrapping to work with \mintinline, like so:

\documentclass[11pt]{report}
\usepackage{minted}

\setmintedinline{
                bgcolor=lightgray,
                }

\begin{document}

\mintinline[breaklines, bgcolor=lightgray]{java}{test test test test test test test test test test test test test test test test test test test test test test test}

\end{document}

I also tried setting

  • \setmintedinline{breaklines}
  • \newmintinline{java}{breaklines}

But the code won't wrap. I read here (github) and here (docu), that \mintinline should allow for breaklines-option.

Also this

\usepackage{minted}
\makeatletter
\renewcommand{\minted@inputpyg}{%
  \expandafter\let\expandafter\minted@PYGstyle%
    \csname PYG\minted@get@opt{style}{default}\endcsname
  \VerbatimPygments{\PYG}{\minted@PYGstyle}%
  \ifthenelse{\boolean{minted@isinline}}%
   {\ifthenelse{\equal{\minted@get@opt{breaklines}{false}}{true}}%
    {\let\FV@BeginVBox\relax
     \let\FV@EndVBox\relax
     \def\FV@BProcessLine##1{%
       \FancyVerbFormatLine{%
         \FV@BreakByTokenAnywhereHook
         \FancyVerbFormatText{\FancyVerbBreakStart##1\FancyVerbBreakStop}}}%
     \minted@inputpyg@inline}%
    {\minted@inputpyg@inline}}%
   {\minted@inputpyg@block}%
}
\makeatother

was suggested by Geoffrey Poore (gpoore) as a workaround for \mintinline to allow breakafter-option on github.

I tried it, but it didn't work for me. Maybe breaklines dosn't work in the first place.

How can I check the version of minted and whats the current version?

I checked Pygments instelled version, it's 2.2.0. Seems to be the current version.

Any ideas, why the lines won't wrap?

8
  • The only supported option for breaklines with mintinline is breakbytoken[anywhere], not breakafter.
    – TeXnician
    Commented Mar 13, 2018 at 9:53
  • @TeXnician Here github.com/gpoore/minted/issues/31#issuecomment-361010857 gpoore claims to have the workaround posted in the question Commented Mar 13, 2018 at 10:07
  • In my experiment, breaklines works; also breakafter=. or breakanywhere. Of course, the line must fit in the case of breakafter=., which could be a problem with a monospaced font.
    – egreg
    Commented Mar 13, 2018 at 11:46
  • @egreg are you using \mintinline? Because I can get it to work with \begin{minted}, but that's not the question. Maybe I have some wrong setting or I miss something. Commented Mar 13, 2018 at 12:00
  • @ArchLinuxTux Can you tell what version of minted you are running?
    – egreg
    Commented Mar 13, 2018 at 12:54

2 Answers 2

8

It seems like this has been fixed in the minted package. Using the options breaklines and breakafter causes a line break for the source code.

\mintinline[breaklines, breakafter=_]{python}{very_long_class_name}
1
  • I don't think so. OP's problem still persists. Tested with minted 2023/12/18 v2.9 and fvextra 2023/11/28 v1.6.1. Your example works because it does not use bgcolor=... like OP wanted.
    – Socowi
    Commented Apr 8 at 9:17
3

2018/03/16

This is a well known problem, which is documented (search for bgcolor) (bug report):

bgcolor only works with \begin{minted}, but not with \mintinline. If used with \mintinline, breaklines doesn't work.

Regarding the code, that should allow for breakafter with \mintinline:

It doesn't work, because its "such a long string of text with only a single possible hyphenation point". The solution is to add this code (possibly without the \begingroup):

\begingroup
\setlength{\rightskip}{0pt plus 1 fil}
<paragraph with \mintedinline that won't normally break>
\endgroup

You must log in to answer this question.

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