3

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.

3
  • 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
    Commented May 6, 2016 at 16:23
  • 2
    Writing \minted{...} is wrong to begin with.
    – egreg
    Commented May 6, 2016 at 16:29
  • 1
    See also tex.stackexchange.com/q/635870/80949 for an answer on the inline command.
    – tigerjack
    Commented Mar 3, 2022 at 16:51

1 Answer 1

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

You must log in to answer this question.

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