0

I'm using minted to display inline code in a footnote. For some reason the # symbol is rendered twice o.O This does not happen outside footnotes.

\footnote{bla bla \mintinline{python}{x = 5 # text} and so on}

enter image description here

0

As stated in the first footnote on page 8 of minted documentation,

The command (\mintinline) has been carefully crafted so that in most cases it will function correctly when used inside other commands.1

1 For example, \mintinline works in footnotes! The main exception is when the code contains the percent % or hash # characters, or unmatched curly braces.

The following trick tries to handle #:

\documentclass{article}
\usepackage{minted}

\makeatletter
\let\footnote@orig\footnote
\def\footnote{%
  \begingroup
  \@makeother\#%
  \footnote@i
}
\def\footnote@i#1{%
  \endgroup
  \footnote@orig{#1}%
}
\makeatother

\begin{document}
content\footnote{bla bla \mintinline{python}{x = 5 # text} and so on}
\end{document}

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.