在 Beamer 中使用 tikz 半逐字記錄

在 Beamer 中使用 tikz 半逐字記錄

我正在使用 semiverbatimwith tikzin beamer。我的以下 MWE 拋出錯誤:

! tikz 包錯誤:抱歉,某些包重新定義了數學模式美元符號的含義。這與 tikz 及其 calc 庫不相容,並可能導致不可恢復的錯誤。

有什麼想法可以解決這個問題。提前致謝。

\documentclass{beamer}

\usepackage{csed}

\usepackage{tikz}
\usetikzlibrary{shapes}

\newif\ifshowanimation
% The slides with animations take a long time to process.
% They are omitted in handout mode.
\showanimationfalse

\newenvironment<>{exercise}{\begin{block}#1{Exercise}}{\end{block}}

\newenvironment<>{notes}{\begin{alertblock}#1{Notes}}{\end{alertblock}}

\newcommand*{\menu}[1]{\textbf{#1}}
\newcommand*{\menuitem}[1]{\,$\to$\,\textbf{#1}}

\definecolor{highlight1}{named}{yellow}
\definecolor{highlight2}{named}{pink}
\definecolor{highlight3}{named}{green}
\definecolor{highlight4}{named}{orange}
\definecolor{Red}{named}{red}
\definecolor{Blue}{named}{blue}

\pgfdeclareimage[width=0.95\textwidth]{backdrop}{images/background.jpg}
\pgfdeclareimage[width=1mm]{pointer}{images/pointer.png}
\pgfdeclareimage[width=0.18\textwidth]{startmenu}{images/startMenu.jpg}
\pgfdeclareimage[width=0.34\textwidth]{programsmenu}{images/programsMenu.jpg}
\pgfdeclareimage[width=0.495\textwidth]{submenu}{images/subMenu.jpg}
\pgfdeclareimage[width=0.608\textwidth]{latexmenu}{images/latexMenu.jpg}
\pgfdeclareimage[width=0.591\textwidth]{latexmenu2}{images/latexMenu2.png}
\pgfdeclareimage[width=0.591\textwidth]{cmd1}{images/cmd1.jpg}
\pgfdeclareimage[width=0.591\textwidth]{cmd2}{images/cmd2.jpg}
\foreach \x in {1,...,46}
{
  \pgfdeclareimage[width=0.84\textwidth]{tmkwin\x}{images/tmkwin-\x.jpg}
}
\pgfdeclareimage[width=0.75\textwidth]{saveAs1}{images/tex-28.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs2}{images/tex-30.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs3}{images/tex-32.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs4}{images/tex-35.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs5}{images/tex-36.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs6}{images/tex-37.jpg}


\begin{document}

\begin{frame}[fragile]
  \frametitle{A Simple Document}

\begin{example}
    \begin{semiverbatim}
        \textcolor<2>{Red}{\cs{documentclass}\annote<5-7>[offset=0.5in,voffset=1cm,pos=br,bg=highlight2]{[a4paper,12pt]}{Class options}\annote<4-7>[pos=br,bg=highlight1]{\marg{article}}{The class name.}}
        \vspace{-2\baselineskip}\alt<7>{\colorbox{highlight4}{\rmfamily Preamble}}{\strut}
        \textcolor<2>{Red}{\cs{begin}\marg{document}}
        \textcolor<3>{Blue}{\% This is a comment}
        \annote<6-7>[pos=cr,bg=highlight3,offset=0.4in]{\begin{tabular}{@{}l}
        This is   a simple\\
        document\cs{footnote}\marg{with a footnote}.\\
        \\
        This is a new paragraph.
        \end{tabular}}{The document.}
        \textcolor<2>{Red}{\cs{end}\marg{document}}
    \end{semiverbatim}
\end{example}

\end{frame}


\end{document}

已編輯


csed可以從這裡

答案1

這篇評論太長了。

該錯誤訊息由通常在 ) 上找到的\tikz@ensure@dollar@catcode文件中的定義觸發;一種解決方法是使用停用錯誤訊息tikz.code.tex.../tex/generic/pgf/frontendlayer/tikz/tikz.code.tex

\makeatletter
\global\let\tikz@ensure@dollar@catcode=\relax
\makeatother

這可能會在文件的其他地方產生不必要的結果,但至少對於您的範例程式碼,它給出了所需的結果:

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{shapes}
\usepackage{csed}

\makeatletter
\global\let\tikz@ensure@dollar@catcode=\relax
\makeatother

\newif\ifshowanimation
% The slides with animations take a long time to process.
% They are omitted in handout mode.
%\showanimationfalse

\newenvironment<>{exercise}{\begin{block}#1{Exercise}}{\end{block}}

\newenvironment<>{notes}{\begin{alertblock}#1{Notes}}{\end{alertblock}}

\newcommand*{\menu}[1]{\textbf{#1}}
\newcommand*{\menuitem}[1]{\,$\to$\,\textbf{#1}}

\definecolor{highlight1}{named}{yellow}
\definecolor{highlight2}{named}{pink}
\definecolor{highlight3}{named}{green}
\definecolor{highlight4}{named}{orange}
\definecolor{Red}{named}{red}
\definecolor{Blue}{named}{blue}

\pgfdeclareimage[width=0.95\textwidth]{backdrop}{images/background.jpg}
\pgfdeclareimage[width=1mm]{pointer}{images/pointer.png}
\pgfdeclareimage[width=0.18\textwidth]{startmenu}{images/startMenu.jpg}
\pgfdeclareimage[width=0.34\textwidth]{programsmenu}{images/programsMenu.jpg}
\pgfdeclareimage[width=0.495\textwidth]{submenu}{images/subMenu.jpg}
\pgfdeclareimage[width=0.608\textwidth]{latexmenu}{images/latexMenu.jpg}
\pgfdeclareimage[width=0.591\textwidth]{latexmenu2}{images/latexMenu2.png}
\pgfdeclareimage[width=0.591\textwidth]{cmd1}{images/cmd1.jpg}
\pgfdeclareimage[width=0.591\textwidth]{cmd2}{images/cmd2.jpg}
\foreach \x in {1,...,46}
{
  \pgfdeclareimage[width=0.84\textwidth]{tmkwin\x}{images/tmkwin-\x.jpg}
}
\pgfdeclareimage[width=0.75\textwidth]{saveAs1}{images/tex-28.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs2}{images/tex-30.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs3}{images/tex-32.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs4}{images/tex-35.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs5}{images/tex-36.jpg}
\pgfdeclareimage[width=0.75\textwidth]{saveAs6}{images/tex-37.jpg}


\begin{document}

\begin{frame}
  \frametitle{A Simple Document}

\begin{example}
    \begin{semiverbatim}
        \textcolor<2>{Red}{\cs{documentclass}\annote<5-7>[offset=0.5in,voffset=1cm,pos=br,bg=highlight2]{[a4paper,12pt]}{Class options}\annote<4-7>[pos=br,bg=highlight1]{\marg{article}}{The class name.}}

        \vspace{-2\baselineskip}\alt<7>{\colorbox{highlight4}{\rmfamily Preamble}}{\strut}

        \textcolor<2>{Red}{\cs{begin}\marg{document}}

        \textcolor<3>{Blue}{\% This is a comment}

        \annote<6-7>[pos=cr,bg=highlight3,offset=0.4in]{\begin{tabular}{@{}l}
        This is   a simple\\
        document\cs{footnote}\marg{with a footnote}.\\
        \\
        This is a new paragraph.
        \end{tabular}}{The document.}

        \textcolor<2>{Red}{\cs{end}\marg{document}}
    \end{semiverbatim}
\end{example}

\end{frame}


\end{document}

在此輸入影像描述

正如我之前所說,這具有長評論的狀態,而不是答案,因為它僅禁用錯誤訊息。

相關內容