3

I have problems including a gnuplot graph in a beamer slide in which it should be visible at the very end of the slide, without all other elements on the slide.

The problem is, it seems I can't use only with a gnuplottex plot.

What I've tried so far is:

\documentclass{beamer}
\setbeamercovered{transparent}
\usetheme{AnnArbor} %not my actual theme, just for MWE
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{color}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage[subfolder,siunitx,cleanup]{gnuplottex}


\begin{document}


\begin{frame}[fragile]{Zeitschritt}

 Some text...

 \vfill

 \onslide<2-4>{
 \begin{block}{Zeitschritt als Funktion der Drehrate des Propellers}
  \begin{equation}
   fancy equation
  \end{equation}
  \onslide<3-4>{some text to go with it}
 \end{block}
 }

 \onslide<4>{
 \begin{block}{Rampenfunktion}
  \begin{equation}
   even more fancy equation
  \end{equation}
 \end{block} 
 }

\only<5>{
        \begin{gnuplot}[terminal=epslatex,terminaloptions=color]
        set size 0.9,0.8

        min(a,b) = (a < b) ? a : b
        max(a,b) = (a > b) ? a : b

        set yrange[0:6]
        set ylabel 'Timestep $\Delta t$ [\si{\degree\per\second}]'
        set xrange[0:5]
        set xlabel 'Time [\si{\second}]'
        set grid
        set key box right top spacing 1.3 samplen 3 width -5

        set style line 1 lw 3

        f(x)= x<1 ? 5 : 5-4*(sin(min(pi*(x-1)/(2*(4-1)),(pi/2))))**2
        g(x)= x<1 ? 5 : max(-1.33*x+6.33,1)

        plot f(x) ls 1 lc 2 t 'Rampenfunktion $\Delta t = 2...4$',\
        g(x) lc 1 t 'Lineare Rampenfunktion';

      \end{gnuplot}
      }

 \end{frame}
 \end{document}

If you comment out the \only<5>{ part, it works when compiling with pdflatex --shell-escape.

If you don't, LaTeX will tell you:

 Paragraph ended before \verbatim@ was complete.

It seems, the only command turns off the fragile option for the frame, or simply ignores it, so I can't do a gnuplot plot here.

Any ideas on that?

2
  • Please help us help you and add a minimal working example (MWE) that illustrates your problem. Reproducing the problem and finding out what the issue is will be much easier when we see compilable code, starting with \documentclass{...} and ending with \end{document}.
    – jarauh
    Nov 25, 2015 at 15:22
  • my MWE should be compilable as it is. The part with the gnuplot plot is to be inserted somewhere in the frame. I don't really get your point, if you insert the gnuplot part, it throws the error. I'll rebuild it a bit, so it shows my problems in a better way.
    – Knigge46
    Nov 26, 2015 at 13:19

2 Answers 2

2

Sounds like onlyenv could be your friend.

\documentclass{beamer}
\setbeamercovered{transparent}
\usetheme{AnnArbor} %not my actual theme, just for MWE
\usepackage[latin1]{inputenc}
\usepackage[ngerman]{babel}
\usepackage{color}
\usepackage{graphicx}
\usepackage{siunitx}
\usepackage[subfolder,siunitx,cleanup]{gnuplottex}


\begin{document}


    \begin{frame}[fragile]{Zeitschritt}

        Some text...

        \vfill

\begin{onlyenv}<1-4>



        \onslide<2-4>{
            \begin{block}{Zeitschritt als Funktion der Drehrate des Propellers}
                \begin{equation}
                fancy equation
                \end{equation}
                \onslide<3-4>{some text to go with it}
            \end{block}
        }

        \onslide<4>{
            \begin{block}{Rampenfunktion}
                \begin{equation}
                even more fancy equation
                \end{equation}
            \end{block} 
        }

\end{onlyenv}

\begin{onlyenv}<5>
            \begin{gnuplot}[terminal=epslatex,terminaloptions=color]
                set size 0.9,0.8

                min(a,b) = (a < b) ? a : b
                max(a,b) = (a > b) ? a : b

                set yrange[0:6]
                set ylabel 'Timestep $\Delta t$ [\si{\degree\per\second}]'
                set xrange[0:5]
                set xlabel 'Time [\si{\second}]'
                set grid
                set key box right top spacing 1.3 samplen 3 width -5

                set style line 1 lw 3

                f(x)= x<1 ? 5 : 5-4*(sin(min(pi*(x-1)/(2*(4-1)),(pi/2))))**2
                g(x)= x<1 ? 5 : max(-1.33*x+6.33,1)

                plot f(x) ls 1 lc 2 t 'Rampenfunktion $\Delta t = 2...4$',\
                g(x) lc 1 t 'Lineare Rampenfunktion';

            \end{gnuplot}
        \end{onlyenv}

\end{frame}
\end{document}

enter image description here

1

While I don't know what the problem is precisely, the following seems to work: Replace \only<5>{...} by \onslide+<5> (without { and }):

\onslide+<5>

    \begin{gnuplot}[terminal=epslatex,terminaloptions=color]
    set size 0.9,0.8

    min(a,b) = (a < b) ? a : b
    max(a,b) = (a > b) ? a : b

    set yrange[0:6]
    set ylabel 'Timestep $\Delta t$ [\si{\degree\per\second}]'
    set xrange[0:5]
    set xlabel 'Time [\si{\second}]'
    set grid
    set key box right top spacing 1.3 samplen 3 width -5

    set style line 1 lw 3

    f(x)= x<1 ? 5 : 5-4*(sin(min(pi*(x-1)/(2*(4-1)),(pi/2))))**2
    g(x)= x<1 ? 5 : max(-1.33*x+6.33,1)

    plot f(x) ls 1 lc 2 t 'Rampenfunktion $\Delta t = 2...4$',\
    g(x) lc 1 t 'Lineare Rampenfunktion';

  \end{gnuplot}

The '+' makes sure that the plot is invisible, and not transparent. (Transparency does not really look good, though, since transparency basically only works with text, so part of the graph will always be fully visible.)

2
  • This is exactly the reason why I want to use only, because the graph should replace the former content of the slide and should not be visible before <5>
    – Knigge46
    Nov 27, 2015 at 11:57
  • The '+' makes it invisible instead of transparent. By the way, if the graph should replace the former content, why don't you just start a new slide? Also, you need to replace the other \onslides by \onlys, otherwise the text to be replaced does not vanish.
    – jarauh
    Nov 27, 2015 at 14:40

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.