6

Is there a way to draw a huge red cross (x) on top of a slide in LaTeX beamer? I want to discuss a position and then say that it is definitely wrong and mark this by crossing out the whole page. It would be great if this cross looked like drawn by hand.

8

Initially I misread the question and thought that the cross should be below the text; now I see that it has to go on top of the text; in this case, there's no need to use the background canvas template:

\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}

enter image description here

You can use TikZ to draw the cross in the background canvas template:

\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}

enter image description here

Using percusses's answer to Simulating hand-drawn lines you can get the handwritten effect:

\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}

enter image description here

| improve this answer | |
  • Thanks! Is there a way to not let the cross extend to the edges of the slide but let's say span the text area only. I have a header at the top of the slide and the header is not wrong, neither is the footer. – Stefan Müller Apr 17 '13 at 5:46
  • @StefanMüller Sure. You can use appropriate shifts for the coordinates; something like \begin{tikzpicture}[remember picture,overlay,decoration=penciline] \draw[decorate,line width=30pt,red!60!black] ([xshift=30pt,yshift=-30pt]current page.north west) -- ([xshift=-30pt,yshift=30pt]current page.south east); \draw[decorate,line width=30pt,red!60!black] ([xshift=-30pt,yshift=-30pt]current page.north east) -- ([xshift=5pt]current page.center) -- ([xshift=30pt,yshift=30pt]current page.south west); \end{tikzpicture} (adjust the lengths according to your needs). – Gonzalo Medina Apr 17 '13 at 6:04
  • I tried doing this, but the cross is not at the correct location. For example, your first sample document gives me this: i.imgur.com/ZPAkEJ9.png This is on PGF/TikZ 3.0.0. – Cactus Feb 4 '17 at 4:08

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.