阴影逐字和脆弱的框架

阴影逐字和脆弱的框架

我有一个beamer类文件,里面有很多frames。几乎所有frames 都需要该选项,[fragile]因为我经常用它\verb| |来说明代码。所以我想全局frame配备 ,[fragile]这样我就不需要手动输入选项了。

另外,我希望里面的所有内容verbatim(或者可能是里面的\texttt,但我更喜欢verbatim)都是灰色的,就像 TeX exchange 现在所做的那样。

这是一个最小的工作示例。您可以修改它来解决问题吗?

\documentclass{beamer}
\begin{document}
\begin{frame}[fragile] % I used [fragile] since \verb in frame yields an error.
\frametitle{fragile frame and shaded verbatim}
\begin{itemize}
\item
I'm using the \verb|beamer| class.
\item
 want to set the \texttt{\colorbox{gray}{frame}} environment to be appended with the option \texttt{\colorbox{gray}{fragile}}.
\item
I want to set the stuff in the \texttt{\colorbox{gray}{verbatim}} command to be shaded just like \TeX exchange does.
\item
An ugly solution : \texttt{\colorbox{gray}{\textbackslash code\_example}}
\end{itemize}
\end{frame}
\end{document}

平均能量损失

答案1

按照建议的方法这里,你应该写:

\documentclass{beamer}

\newenvironment{xframe}[1][]
{\begin{frame}[fragile,environment=xframe,#1]}
{\end{frame}}

\begin{document}
    \begin{xframe}% fragile option no longer required
        \frametitle{fragile frame and shaded verbatim}
        \begin{itemize}
            \item
            I'm using the \verb|beamer| class.
            \item
             want to set the \texttt{\colorbox{gray}{frame}} environment to be appended with the option \texttt{\colorbox{gray}{fragile}}.
            \item
            I want to set the stuff in the \texttt{\colorbox{gray}{verbatim}} command to be shaded just like \TeX exchange does.
            \item
            An ugly solution : \texttt{\colorbox{gray}{\textbackslash code\_example}}
        \end{itemize}
    \end{xframe}
\end{document}

不过,我将这个问题标记为重复。

相关内容