9

There is an overleaf template for pythonTEX. I change it's document class into beamer and then I find a strange error with the following code:

\begin{frame}{Example}
\begin{minted}{latex}
\py{2+2}
\end{minted}
\end{frame}

error information:

Runaway argument?
 \py {2+2} \end {minted} 
Paragraph ended before \FV@BeginScanning was complete.
<to be read again> 
                   \par 
l.44 \end{frame}

A simple change can make it work well:

\begin{frame}[fragile]
\frametitle{Example}
\begin{minted}{latex}
\py{2+2}
\end{minted}
\end{frame}

Why can't I set the frame title directly?

5
  • 3
    Welcome to TeX.SX! You need a fragile frame for all verbatim environments and minted is one of them.
    – TeXnician
    Jan 1, 2018 at 8:57
  • @TeXnician, so it's an usual situation?
    – Bettertomo
    Jan 1, 2018 at 8:59
  • 1
    Yes. It is far from being strange, but it is by design. A fragile frame is needed as there is special handling concerning the content (which is not needed for normal frames). minted is one of the verbatim environments (=basically any code environment) which requires this special treatment.
    – TeXnician
    Jan 1, 2018 at 9:03
  • @Bettertomo You can still set the framtitle directly, you just have to combine it with the fragile option, e.g. \begin{frame}[fragile]{title} test \end{frame} Jan 1, 2018 at 12:09
  • @TeXnician would you like to write an answer? Jan 1, 2018 at 12:10

1 Answer 1

14

minted is one of the many verbatim environments you will find when using source code in LaTeX. Those verbatim environments need special treatment (the fragile option) by design which is usually not needed for "simple things", e.g. itemize etc.

Hence it is also by design that you need to tell LaTeX to handle your frame specially by using the option. You do not need to set the frametitle using another command, \begin{frame}[fragile]{Title} will suffice.

0

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.