39

I it possible to use minted for inline code and to add a short verb sign 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}

2 Answers 2

59

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

8
  • Thanks that sounds good. Do you know if something like \lstMakeShortInline| is available (or planned) too?
    – Tobi
    Commented Dec 5, 2013 at 16:23
  • Now I do ... :)
    – jan-glx
    Commented Dec 5, 2013 at 17:11
  • 1
    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
    Commented Dec 5, 2013 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. Commented Dec 5, 2013 at 18:48
  • 2
    @user : The X is just a normal text character as in my example. @Tobi wanted to be able surround their code by just | and | instead of \perlinline/ and /. or (using the macro name argument) \p/ and / . (saving two keystrokes for every codeblock)
    – jan-glx
    Commented Oct 11, 2019 at 11:21
14

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.

3
  • 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
    Commented Feb 25, 2012 at 22:43
  • How do I install a patch? Im running OS X 10.6.
    – Tobi
    Commented Feb 26, 2012 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
    Commented Mar 4, 2013 at 18:39

You must log in to answer this question.

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