[Tex/LaTex] Display character % with minted

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.

Best Answer

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}

enter image description here