TransWikia.com

Beamer Metropolis Theme clashes with tikz, removes content from tikzpicture

TeX - LaTeX Asked by axelniemeyer on March 12, 2021

Please find below a MWE. (Un-)commenting

usetheme{metropolis}

removes content from the tikzpicture, and I am truly puzzled as to why that is. I am using XeLaTeX to compile. Thanks!

documentclass[xcolor=dvipsnames,aspectratio=149,10pt]{beamer}

usepackage{pgf,tikz,pgfplots,tikz-cd}
pgfplotsset{compat=1.15}
usepackage{mathrsfs}
usetikzlibrary{arrows,intersections, pgfplots.fillbetween}

usetheme{metropolis}

begin{document}
begin{frame}
 begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=5.0cm,y=5.0cm,scale=0.45]
begin{axis}[
x=5.0cm,y=5.0cm,
xmin=-1.0,
xmax=1.0,
ymin=-1.0,
ymax=1.0,
xtick={-0.5,0.0,0.5},
ytick={-0.5,0.0,0.5},
xticklabels={,,},
yticklabels={,,},
line width= 2pt
]
clip(-1.,-1.) rectangle (1.,1.);
draw [line width=1.25pt] (-1,1.)-- (1,-1.);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (-0.4,0.4-0.25)-- (-0.4,0.4+0.25);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (-0.4-0.25,0.4)-- (-0.4+0.25,0.4);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (0.4,-0.4+0.25) -- (0.4,-0.4-0.25);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (0.4+0.25,-0.4) -- (0.4-0.25,-0.4);
end{axis}
end{tikzpicture}
end{frame}

end{document}

With metropolis

Without Metropolis

One Answer

The theme loads a pgfplotsthemetol.sty which sets various pgfplots related things. Beside other it resets the compability level. You could reset it again:

documentclass[xcolor=dvipsnames,aspectratio=149,10pt]{beamer}

usepackage{pgf,tikz,pgfplots,tikz-cd}

usepackage{mathrsfs}
usetikzlibrary{arrows,intersections, pgfplots.fillbetween}

usetheme{metropolis}
AtEndPreamble{pgfplotsset{compat=1.15}}
begin{document}
begin{frame}
abc
 begin{tikzpicture}[line cap=round,line join=round,>=triangle 45,x=5.0cm,y=5.0cm,scale=0.45]
begin{axis}[
x=5.0cm,y=5.0cm,
xmin=-1.0,
xmax=1.0,
ymin=-1.0,
ymax=1.0,
xtick={-0.5,0.0,0.5},
ytick={-0.5,0.0,0.5},
xticklabels={,,},
yticklabels={,,},
line width= 2pt
]
clip(-1.,-1.) rectangle (1.,1.);
draw [line width=1.25pt] (-1,1.)-- (1,-1.);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (-0.4,0.4-0.25)-- (-0.4,0.4+0.25);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (-0.4-0.25,0.4)-- (-0.4+0.25,0.4);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (0.4,-0.4+0.25) -- (0.4,-0.4-0.25);
draw [->,>=stealth,line width=1.pt,dash pattern=on 2pt off 2pt] (0.4+0.25,-0.4) -- (0.4-0.25,-0.4);
end{axis}
end{tikzpicture}
end{frame}

end{document}

With a current LaTeX you could also forbid metropolis to load this style, and to leave your settings alone.

Correct answer by Ulrike Fischer on March 12, 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