使用 LaTeX beamer 划掉整张幻灯片

使用 LaTeX beamer 划掉整张幻灯片

有没有办法在 LaTeX 投影仪的幻灯片顶部画一个巨大的红色十字 (x)?我想讨论一个观点,然后说它绝对是错误的,并通过划掉整页来标记这一点。如果这个十字看起来像手绘的,那就太好了。

答案1

最初我误读了问题并认为十字架应该位于文本下方;现在我明白它必须位于文本上方;在这种情况下,无需使用模板background canvas

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathmorphing,patterns}

\makeatletter

\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=1mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{10pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{8pt}{5pt}}
        }
    }
    \state{final}{}
}

\begin{document}


\begin{frame}

{\Huge\centering This is wrong.\par}
\onslide<2->{\begin{tikzpicture}[remember picture,overlay,decoration=penciline]
\draw[decorate,line width=30pt,red!60!black] 
  (current page.north west) -- (current page.south east);
\draw[decorate,line width=30pt,red!60!black] 
  (current page.north east) -- (current page.center) -- (current page.south west);
\end{tikzpicture}}
\end{frame}

\end{document}

在此处输入图片描述

您可以使用 TikZ 在模板中绘制十字架background canvas

\documentclass{beamer}
\usepackage{tikz}

\begin{document}

\begingroup
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay]
\draw[line width=20pt,red!60!black] 
  (current page.north west) -- (current page.south east);
\draw[line width=20pt,red!60!black] 
  (current page.south west) -- (current page.north east);
\end{tikzpicture}}

\begin{frame}
This is wrong.
\end{frame}
\endgroup

\end{document}

在此处输入图片描述

使用percusses's answer模拟手绘线条即可得到手写效果:

\documentclass{beamer}
\usepackage{tikz}
\usetikzlibrary{calc,decorations.pathmorphing,patterns}

\makeatletter

\pgfdeclaredecoration{penciline}{initial}{
    \state{initial}[width=+\pgfdecoratedinputsegmentremainingdistance,auto corner on length=1mm,]{
        \pgfpathcurveto%
        {% From
            \pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}
                            {\pgfdecorationsegmentamplitude}
        }
        {%  Control 1
        \pgfmathrand
        \pgfpointadd{\pgfqpoint{\pgfdecoratedinputsegmentremainingdistance}{10pt}}
                        {\pgfqpoint{-\pgfdecorationsegmentaspect\pgfdecoratedinputsegmentremainingdistance}%
                                        {\pgfmathresult\pgfdecorationsegmentamplitude}
                        }
        }
        {%TO 
        \pgfpointadd{\pgfpointdecoratedinputsegmentlast}{\pgfpoint{8pt}{5pt}}
        }
    }
    \state{final}{}
}

\begin{document}

\begingroup
\setbeamertemplate{background canvas}{%
\begin{tikzpicture}[remember picture,overlay,decoration=penciline]
\draw[decorate,line width=30pt,red!60!black] 
  (current page.north west) -- (current page.south east);
\draw[decorate,line width=30pt,red!60!black] 
  (current page.north east) -- (current page.center) -- (current page.south west);
\end{tikzpicture}}

\begin{frame}
This is wrong.
\end{frame}
\endgroup

\end{document}

在此处输入图片描述

相关内容