在投影机覆盖层中铸造

在投影机覆盖层中铸造

我意识到以前也曾有人问过类似的问题,但到目前为止还没有解决办法。


考虑这个文档:

\documentclass{beamer}

\usepackage{minted}

\begin{document}

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

\end{document}

它给出了以下错误:

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

(最后一句很美,我需要把它加进去。)

怎么了?我该如何解决?请注意,它\mintinline运行正常。

答案1

使用的问题\only{...}在于,你不能拥有像宏参数这样脆弱的内容(例如https://tex.stackexchange.com/a/30006/36296了解更多解释)。

幸运的是,你可以使用onlyenv环境来代替:

\documentclass{beamer}

\usepackage{minted}

\begin{document}

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

\end{document}

相关内容