2

I realise similar questions have been asked before, but no solution worked for me so far.


Consider this document:

\documentclass{beamer}

\usepackage{minted}

\begin{document}

\begin{frame}[fragile]
\only<2>{
\begin{minted}{agda}
test
\end{minted}
}
\end{frame}

\end{document}

It gives the following error:

! FancyVerb Error:
  Extraneous input ` test \end {minted} ' between \begin{minted}[<key=value>] a
nd line end
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}

l.5 }

This input will be discarded. Hit <return> to continue.

)
Runaway argument?
! File ended while scanning use of \FancyVerbGetLine.
<inserted text> 
                \par 
l.13 \end{frame}

I suspect you have forgotten a `}', causing me
to read past where you wanted me to stop.
I'll try to recover; but if the error is serious,
you'd better type `E' or `X' now and fix your file.

! FancyVerb Error:
  Couldn't find `\end{minted}' to end a verbatim environment on input line 5.
.
\FV@Error ... {FancyVerb Error:
\space \space #1
}

l.13 \end{frame}

Probably you mistyped the environment name or included an extraneous 
space, or are using an improperly defined verbatim environment. 
Hit return and I will try to terminate this job.


[...]

Things are pretty mixed up, but I think the worst is over.

(That last line was beautiful, I needed to include it.)

What's the matter? How do I fix it? Note that \mintinline works fine.

  • Can you try \begin{frame}[fragile] \begin{onlyenv}<2> \begin{minted}{agda} test \end{minted} \end{onlyenv} \end{frame}? (I don't have the necessary programs for minted) – user36296 May 24 '17 at 15:37
  • @samcarter, that works! Thanks! You're welcome to post your comment as an answer, and I'll accept it. – Turion May 24 '17 at 15:40
  • @ Turion Done :) – user36296 May 24 '17 at 15:44
8

The problem with using \only{...} is, that you cannot have such fragile content as argument for a macro (see e.g. https://tex.stackexchange.com/a/30006/36296 for more explanation).

Luckily you can use the onlyenv environment instead:

\documentclass{beamer}

\usepackage{minted}

\begin{document}

\begin{frame}[fragile]
\begin{onlyenv}<2>
\begin{minted}{agda}
test
\end{minted}
\end{onlyenv}
\end{frame}

\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.