# Own command for \mintinline cannot handle hash character

I'm using the following command to create my own version of \mintinline:

\newcommand{\inline}[1]{{\mintinline[fontsize=\normalsize]{text}{#1}}}


This works except when I'm using the hash character. For instance:

\inline{Class#method()}


Which gets rendered with two hashes (i.e. Class##method()). When I replace my own command with \mintinline[fontsize=\normalsize]{text}{…}, everything is fine.

What am I doing wrong in my \newcommand definition?

• as with most "verbatim" commands, you cannot include in another command using standard definition forms. – David Carlisle Oct 1 '17 at 11:17

Just avoid absorbing the text beforehand:

\documentclass{article}
\usepackage{minted}

\newcommand{\inline}{\mintinline[fontsize=\normalsize]{text}}

\begin{document}

Text \inline{Class#method()} text

\end{document}


However, the preferred method is with \newmintinline, so the defined command can take options in the standard way.

\documentclass{article}
\usepackage{minted}

\newmintinline[inline]{text}{fontsize=\normalsize}

\begin{document}

Text \inline{Class#method()} text

Text \inline[fontsize=\small]{Class#method()} text

\end{document}