matze / mtheme

A modern LaTeX Beamer theme
6.44k stars 845 forks source link

`pgfplotsthemetol` puts `\pgfplotsset{compat=1.9}` at end of preamble, overriding other settings #397

Open jasperhabicht opened 11 months ago

jasperhabicht commented 11 months ago

The metropolis theme loads the pgfplotsthemetol package which essentially sets \AtEndPreamble{ \pgfplotsset{compat=1.9} } and thereby overrides other settings of the PGF key compat.

The problem is that compat=1.9 is relatively old and therefore some functions are not activated such as using axis coordinates inside the axis environment when using standard TikZ commands such as \draw or \fill without the need to prexis the coordinates with axis cs:.

A solution to this is to set \AtEndPreamble{ \pgfplotsset{compat=1.18} } instead of \pgfplotsset{compat=1.18} in the preamble, but it is not obvious to the user why they should do that.

Consider the following MWE:

\documentclass{beamer}
\usetheme{metropolis}

\usepackage{pgfplots}
\pgfplotsset{compat=1.18}

%\AtEndPreamble{
%    \pgfplotsset{compat=1.18}
%}

\begin{document}
    \begin{frame}
        \begin{tikzpicture}
            \begin{axis}
                \addplot coordinates {(0,0) (1,1)};
                \fill[red] (0.5,0.5) circle[radius=2pt];
            \end{axis}
        \end{tikzpicture}
    \end{frame}
\end{document}

Uncommenting %\AtEndPreamble{ \pgfplotsset{compat=1.18} } fixes the problem and the red circle is placed in the middle of the plot instead of somewhere at the origin.

A simple solution would be to just avoid setting compat via the pgfplotsthemetol package.