2

The example below is a slightly modified version of the answer in this thread. I want to condition the circles on whether or not I'm running in desktop or presentation mode. How would I define the counters aCirc and bCirc so that in desktop mode no circles appear? In presentation mode I can kill off one or other circles by setting the appropriate counter to 0. But for some reason, that doesn't work for desktop mode.

\documentclass{beamer}

\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}

\newcounter{nodemarkers}
\newcommand<>\circletext[1]{%
    \tikz[overlay,remember picture]
    \node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
    #1%
    \tikz[overlay,remember picture]
    \node (marker-\arabic{nodemarkers}-b) at (0,0){};%
    \tikz[overlay,remember picture,inner sep=2pt]
    \node#2[draw,ellipse,fit=(marker-\arabic{nodemarkers}-a.center) (marker-\arabic{nodemarkers}-b.center)] {};%
    \stepcounter{nodemarkers}%
}

\newcounter{aCirc}
\newcounter{bCirc}
\setcounter{aCirc}{2}
\setcounter{bCirc}{3}

\begin{document}

    \begin{frame}[<+->]
        \frametitle{test}

        \begin{tabular}{|ccccccc|}
            \hline
            \circletext<\theaCirc>{AAAAA}&
            B&
            C&
            \circletext<\thebCirc>{BB}&
            A&
            B&
            C\\
            \hline
        \end{tabular}
    \end{frame}

\end{document}
Leo Simon
  • 2,199
  • What do you mean with "desktop"? – samcarter_is_at_topanswers.xyz Oct 02 '17 at 22:50
  • I'm using either \documentclass[desktop]{beamer} or documentclass{beamer}. I can get the result I want when I use the latter, but when I add the [desktop] option, I can't selectively pick my circles. – Leo Simon Oct 03 '17 at 02:03
  • You can use \@ifclasswith{beamer}{desktop}{}{} to test the documentclass option: \makeatletter \@ifclasswith{beamer}{desktop}{ Define \circletext for desktop mode }{ Define \circletext for other mode } \makeatother – Peter Grill Oct 03 '17 at 04:13
  • Out of curiosity: what is this option supposed to do? – samcarter_is_at_topanswers.xyz Oct 03 '17 at 12:04
  • I learned about it from @Mike. It's invaluable. With desktop mode, you create one slide per frame, i.e., all overlays are suppressed, so a presentation with hundreds of slides is reduced to one with a manageable number. This is what one wants for everything except giving actual presentations. – Leo Simon Oct 03 '17 at 16:53

1 Answers1

2

I would suggest you use \@ifclasswith{beamer}{desktop}{}{} to detect the package option and then define a TikZ style:

\makeatletter
    \@ifclasswith{beamer}{desktop}{
        \tikzset{my ellipse style/.style={draw=none}}
    }{
        \tikzset{my ellipse style/.style={draw, ellipse}}
    }
\makeatother

Notes:

  • I am not a beamer expert so not sure why I needed a \RequirePackage{tikz} to have the \tikzset macro availalable

Code:

\RequirePackage{tikz}% Need to get \tikzset for some reason
\documentclass[desktop]{beamer}

\makeatletter
    \@ifclasswith{beamer}{desktop}{
        \tikzset{my ellipse style/.style={draw=none}}
    }{
        \tikzset{my ellipse style/.style={draw, ellipse}}
    }
\makeatother

\newcommand<>\circletext[1]{%
    \tikz[overlay,remember picture]
    \node (marker-\arabic{nodemarkers}-a) at (0,1.5ex) {};%
    #1%
    \tikz[overlay,remember picture]
    \node (marker-\arabic{nodemarkers}-b) at (0,0){};%
    \tikz[overlay,remember picture,inner sep=2pt]
    \node#2[my ellipse style,fit=(marker-\arabic{nodemarkers}-a.center) 
        (marker-\arabic{nodemarkers}-b.center)] {};%
    \stepcounter{nodemarkers}%
}%


\usepackage{tikz}
\usetikzlibrary{fit,shapes.geometric}

\newcounter{nodemarkers}

\newcounter{aCirc}
\newcounter{bCirc}
\setcounter{aCirc}{2}
\setcounter{bCirc}{3}

\begin{document}

    \begin{frame}[<+->]
        \frametitle{test}

        \begin{tabular}{|ccccccc|}
            \hline
            \circletext<\theaCirc>{AAAAA}&
            B&
            C&
            \circletext<\thebCirc>{BB}&
            A&
            B&
            C\\
            \hline
        \end{tabular}
    \end{frame}

\end{document}
Peter Grill
  • 223,288
  • Thanks for this, @PeterGrill. I should have been clearer in my original question. I'm calling the same piece of code repeatedly. In one frame I want just AAAAA circled, in another I want just BB circled. In presentation mode this is easy to accomplish, but in desktop not so easy. Your suggestion turns off circling completely in desktop mode. Is there some way to avoid this? Thanks! – Leo Simon Oct 03 '17 at 15:13
  • @LeoSimon: Just use \@ifclasswith{beamer}{desktop}{}{} to define the appropriate conditionals. I don't fully understand your requirement so am hesitant to change the code. – Peter Grill Oct 04 '17 at 01:55
  • Thanks @PeterGrill. ultimately I didn't use @ifclasswith. Instead I used your \tikzset options, but added an additional argument to the defintion of \circletext, and within that macro, conditioned the choice of your two \tikzset commands on whether or not the new argument was zero. This way I could accomplish in desktop mode exactly the functionality provided in presentation mode. It's clumsy, but works and gives me the flexibility I need – Leo Simon Oct 04 '17 at 09:21