Display character % with minted

How can I display the % character with minted without it being considered a comment? If I write \minted{%} the rest of the line is considered a comment, and if I write \minted{\%} minted displays both characters: \% Thanks.

If I use \mintinline[style=bw]{c}{%} it is displayed well. However if I use the command that I defined: \newcommand{\mintbw}[1]{\mintinline[style=bw]{c}{#1}} and write \mintbw{%} the % character is considered a comment.

Problem solved! Thanks.

• The % character is supposed to turn the rest of the line into comments (in a number of languages), right? Maybe you can provide a larger example, to make it more clear what you mean? May 6, 2016 at 16:23
• Writing \minted{...} is wrong to begin with. May 6, 2016 at 16:29
• See also tex.stackexchange.com/q/635870/80949 for an answer on the inline command. Mar 3 at 16:51

Just use the minted environment, not the \minted command, which is 'possible', but will not provide what is requested.

Of course, the correct language must be specified, e.g. TeX or php (if I am remembering correctly), where % is a comment character.

\documentclass{article}

\usepackage{minted}

\begin{document}
\begin{minted}{tex}
% This is a TeX comment but is not disregarded because it's inside

\documentclass{article}

\usepackage{minted}

\begin{document}
Dont use  in \LaTeXe!  % It's weird!
\end{document}
\end{minted}
\end{document}