5

I have a beamer presentation in which a figure takes a bit long to compile. And I do not want to use externalize. Figures in non-beamer documents can be conveniently produced with standalone. However, if one uses the beamer option there, as is explained in the manual, the figure won't get cropped. Here is my MWE:

\documentclass[beamer]{standalone}
\usepackage{pgfplots}
\begin{document}
\begin{frame}[plain]
\begin{tikzpicture}[xscale=-1,yscale=0.5]
\begin{axis}[hide axis,width=8cm,height=4cm,clip=false] 
\addplot[domain=20:300,samples=800,        
colormap={}{ 
            color(2cm)=(red);
            color(16cm)=(blue);
        },
        ultra thick, point meta=x*x,mesh]{sin(pow(x,2)/15)};
\end{axis}
\node at (-0.2,1) {observer};
\node at (7,1) {source};
\end{tikzpicture}
\end{frame}
\end{document}

enter image description here

Is there a way to persuade standalone to crop the document, or is there an alternative that allows one to achieve this.

NOTE: I was told by samcarter that one could achieve this by changing the font. I agree that this would allow me solve the issue in the present example, but I'd would like to have a general solution. (And no externalize.)

6

Using the beamer option normally also sets preview=false,crop=false,varwidth=false. The crop=false key can be reverted by passing it as an additional argument:

\documentclass[beamer,crop]{standalone}
\usepackage{pgfplots}
\usetikzlibrary{ducks}
\begin{document}
\begin{tikzpicture}[xscale=-1,yscale=0.5]
\begin{axis}[hide axis,width=8cm,height=4cm,clip=false] 
\addplot[domain=20:300,samples=800,        
colormap={}{ 
            color(2cm)=(red);
            color(16cm)=(blue);
        },
        ultra thick, point meta=x*x,mesh]{sin(pow(x,2)/15)};
\end{axis}
\node at (-0.4,0) {observer};
\node at (7,1) {source};

\draw (-0.4,0.5) pic [scale=0.4,duck/glasses] {duck};

\begin{scope}[yscale=-0.6,xscale=-0.3,yshift=-100,xshift=40]
\fill[gray] (-2.9466,-0.3003) -- (-3.1837,0.4402) -- (-2.7744,0.5708) -- (-2.7308,0.4348) -- (-1.8176,0.7262) -- (-2.6937,2.5325) -- (-2.4891,2.6173) -- (-1.7766,1.1484) -- (-1.7910,2.8438) -- (-1.5698,2.8326) -- (-1.5560,1.2208) -- (-0.8785,2.6173) -- (-0.6739,2.5325) -- (-1.5011,0.8272) -- (-0.3532,1.1935) -- (-0.3096,1.0574) -- (-0.1147,1.1196) -- (-0.0566,0.9382) -- (-0.2516,0.8760) -- (-0.2032,0.7249) -- (-2.5809,-0.0337) -- (-2.5373,-0.1697) -- (-2.9466,-0.3003) -- cycle;
\end{scope}
\end{tikzpicture}
\end{document}

enter image description here

  • Sooo simple ;-) – user121799 Apr 16 '18 at 22:50
  • samcarter, @marmot: Indeed. Also the =true is optional. Cropping is disabled with beamer option by default. – Martin Scharrer Apr 17 '18 at 5:45
  • @marmot This is a possible application of crop=false by default with beamer – Ignasi Apr 17 '18 at 7:23
  • @marmot Added the missing observer :) – user36296 Apr 17 '18 at 21:37
  • @samcarter Oh, so cute!!!! BTW, yet another message that got swallowed, I just saw this by accident.... – user121799 May 11 '18 at 16:20

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy