TransWikia.com

tikz-plot label and ref in beamer inside only overlay

TeX - LaTeX Asked by Mr.EU on August 14, 2021

MWE:

documentclass{beamer}

usepackage{pgfplots, pgfplotstable,stackengine}

begin{document}
begin{frame}{Frame Title}
only<1>{}
only<2>{

begin{tikzpicture}
  begin{axis}
    addplot+ coordinates {
      (1, 9) (2, 6) (3, 1) (4, 4)
    }; label{important}
  end{axis}
end{tikzpicture}

ref{important}% does NOT work
}
end{frame}

begin{frame}{Frame Title}
begin{tikzpicture}
  begin{axis}
    addplot+ coordinates {
      (1, 9) (2, 6) (3, 1) (4, 4)
    }; label{importantw}
  end{axis}
end{tikzpicture}

ref{importantw}% working

end{frame}

end{document}

ref{importantw} shows the symbol as expected, but ref{important} does not work as it is inside only (at least in my use case). How to solve this?

If I use onslide<2> it messes up everything in my original work: Slide 2 appears perfect, but data of slide 2 overlaps with all other slides 1,3.

One Answer

in beamer page 84:

label<⟨overlay specification⟩>{⟨label name⟩}

If the ⟨overlay specification⟩ is present, the label is only inserted on the specified slide. Inserting a label on more than one slide will cause a ‘multiple labels’ warning. However, if no overlay specification is present, the specification is automatically set to just ‘1’ and the label is thus inserted only on the first slide. This is typically the desired behavior since it does not really matter on which slide the label is inserted, except if you use an only command and except if you wish to use that label as a hyperjump target. Then you need to specify a slide.

Labels can be used as target of hyperjumps. A convenient way of labelling a frame is to use the label=⟨name⟩ option of the frame environment. However, this will cause the whole frame to be kept in memory till the end of the compilation, which may pose a problem.

Note: label<2>{important}

edit file:

documentclass{beamer}

usepackage{pgfplots, pgfplotstable,stackengine}

begin{document}
begin{frame}{Frame Title}
only<1>{}
only<2>{%
begin{tikzpicture}
  begin{axis}
    addplot+ coordinates {
      (1, 9) (2, 6) (3, 1) (4, 4)
    }; label<2>{important}
  end{axis}
end{tikzpicture}

ref{important}% does NOT work
}
end{frame}

begin{frame}{Frame Title}
begin{tikzpicture}
  begin{axis}
    addplot+ coordinates {
      (1, 9) (2, 6) (3, 1) (4, 4)
    }; label{importantw}
  end{axis}
end{tikzpicture}

ref{importantw}% working

end{frame}

end{document}

Correct answer by M.Ahmadi on August 14, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP