Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Break lines in \mintedinline #340

Closed
amine-aboufirass opened this issue Sep 2, 2022 · 2 comments
Closed

Break lines in \mintedinline #340

amine-aboufirass opened this issue Sep 2, 2022 · 2 comments

Comments

@amine-aboufirass
Copy link

Warning, I'm crossposting from the LaTeX SE

I have come to a point where I really need a way to have LaTeX automatically break lines formatted as inline listings. I'm using the package minted. Here's a minimal working example:

\documentclass{article}

\usepackage{minted}
\usepackage{xcolor}
\usepackage{fontspec}

\definecolor{bg}{rgb}{0.85, 0.85, 0.85}
\setmintedinline{bgcolor=bg}
\setmonofont{Courier New}
\begin{document}
    Hello world
    
    \mintinline{text}{aVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongString}
    
    \Verb[breaklines, breakanywhere]{aVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongStringaVeryLongString}
\end{document}

When compiling with latexmk -lualatex -shell-escape test.tex, the result is as follows:

enter image description here

According to the docs for minted, breaklines and breakanywhere are not available for \mintinline. I'm not sure about breakbytoken, but I'd be open to using it if it could potentially fix my problem.

There are two main issues logged in the minted repository that attempt to address this problem:

I read through both issues and it seems that the only viable workaround for now is to use \Verb instead of \mintinline. However there are a couple of problems with \Verb as far as I can tell:

  • You cannot set a language (Python, C++) the same way you can with \mintinline
  • You cannot set a bgcolor, which I like to have to clearly distinguish inline code from surrounding text.

There has got to be a way to achieve this using \mintinline? Any suggestions or ideas?

@amine-aboufirass
Copy link
Author

I got an answer on SE:

https://tex.stackexchange.com/questions/655908/breaking-lines-resulting-from-mintinline-or-verb/656034#656034

How easy would it be to implement the code proposed by Mico to this package?

gpoore added a commit that referenced this issue Sep 7, 2022
@gpoore
Copy link
Owner

gpoore commented Sep 7, 2022

I'm working on a complete reimplementation of \mintinline that will support all features from fvextra's \Verb, including line breaking. An initial version is now on GitHub. You can download the new minted.sty and put it in the same directory as your document to experiment with it. The documentation and some other features still have to be updated before a new version is released and uploaded to CTAN.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants