24

I it possible to use minted for inline code and to add a short verb sing for minted? Like \lstMakeShortInline| in listings.sty?

\documentclass{article}

\usepackage{minted}
   \newminted{tex}{}
   \newmint[ltx]{tex}{}

\begin{document}
Normal Text \ltx|\inline \Verb \not \inline|
\begin{texcode}
\Display \verbatim
\end{texcode}
Normal Text %|\not \working|
\end{document}
25

minted supports this since v2.0 (on CTAN since 2015/01/31):

inline code

\documentclass{article}

\usepackage{minted}

\begin{document}
  You can use \mintinline{latex}{\mintinline{latex}{your $code$ goes here}} of
  the minted~2 package to highlight source code inline. If you already use
  \mintinline{latex}{\usepackage{minted}}
\end{document}

It is also possible to add a short verb sign:

from the Dokumentation:

\newmintinline['macro name']{'language'}{'options'}. If a 'macro name' is not specified, then the created macro is called \'language'inline

short inline

  • Thanks that sounds good. Do you know if something like \lstMakeShortInline| is available (or planned) too? – Tobi Dec 5 '13 at 16:23
  • Now I do ... :) – jan-glx Dec 5 '13 at 17:11
  • Thanks but thats not really what I meant. In the above example a short verb would be like X|my $foo = $bar;|X, i.e. only delimited by the pipes … – Tobi Dec 5 '13 at 17:43
  • 4
    @Tobi I intentionally didn’t build this into minted (and neither did Geoffrey, presumably for the same reason) because it’s incredibly bad design in my opinion. LaTeX already has too many “magic” (active) characters, no need to add even more. If anything, users of TeX should disable active characters and math delimiters in general code. – Konrad Rudolph Dec 5 '13 at 18:48
  • @KonradRudolph: Good thought :-) but reducing the number of typed characters is nice too :-) – Tobi Dec 5 '13 at 23:36
9

So far there is no support for inline code since I (mistakenly, in hindsight) deemed this not important.

If I find some time to work on the next release, support for this may be added (and will probably break backwards compatibility). In the meantime, somebody has posted a patch (be sure to read all the comments!) to make the \mint command inline. You may want to play with that.

  • 1
    Thank you. I read it and decided to use listings for inline and mint for displayed code. I accept your answer but I still hope that there is a official solution in a future version :-) – Tobi Feb 25 '12 at 22:43
  • How do I install a patch? Im running OS X 10.6. – Tobi Feb 26 '12 at 0:13
  • Hi Konrad, I also read that Allow inline code thread but that was old stuff and I'm not sure if the solution sketched there still applies. pygments seems also to be stuck in 2008 with version 1.4 – green diod Mar 4 '13 at 18:39

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.