1

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? – Marijn May 6 '16 at 16:23
  • 2
    Writing \minted{...} is wrong to begin with. – egreg May 6 '16 at 16:29
5

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

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.