Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

I am trying to put a tikz overlay picture - A nice, thick red 'X' over a word - On the frame title of a Beamer frame. However, the overlay tikz picture in the frame does not recognize the nodes given in the title.

For example, I try:

\newcommand{\crd}[1]{\tikz[overlay, remember picture, baseline=.5ex]\coordinate (#1);}
\begin{frame}
  \frametitle{Some \crd{p}Crossthis\crd{q} Title}
  \begin{tikzpicture}[overlay, remember picture]
    \draw[red, thick] (p) -- (q);
  \end{tikzpicture}
\end{frame}

And I get:

ERROR: Package pgf Error: No shape named q is known.

How can I put an overlay on the title?

share|improve this question
    
Do you also get "No shape named p is known"? If not, it would be very strange that one coordinate was there but the other wasn't. –  Andrew Stacey Oct 4 '11 at 11:37
    
@Andrew: When I run the OP's MWE I do get a warning about p first. –  Matthew Leingang Oct 4 '11 at 11:45
add comment

1 Answer

up vote 7 down vote accepted

Beamer evaluates a frame's contents in a nonstandard way. The frame's body is evaluated before the frame's title.

Here is an adaptation of your MWE that puts the effect in the title and demonstrates the order of evaluation:

\documentclass{beamer}
\usepackage{tikz}
\usepackage{lipsum}
\begin{document}

\newcounter{n}

\newcommand{\crd}[1]{\tikz[overlay, remember picture, baseline=.5ex]\coordinate (#1);}
\begin{frame}{%
    \stepcounter{n}($n=\then$)% 
    Some \crd{p}Crossthis\crd{q} Title%
    \begin{tikzpicture}[overlay, remember picture]
            \draw[red, thick] (p) -- (q);
    \end{tikzpicture}%
}
\stepcounter{n}($n=\then$)% 
\lipsum[1]
\end{frame}

\end{document}

sample code output

You have to run this twice to get the underline effect.

share|improve this answer
1  
Presumably, Mr Tables wants "CrossThis" crossed out, in which case baseline=-.5ex would be better. (Yes, I know this was wrong in the original question ...) –  Andrew Stacey Oct 4 '11 at 12:00
    
@Andrew: Yes, I presume the same. Maybe I can tweak it later. –  Matthew Leingang Oct 4 '11 at 17:34
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.