3

Until yesterday I could regularly use the code reported in this answer to draw a circle right at the intersection of two lines. Today the exact same code has suddenly stopped working. The crash is caused by the option \pgfplotsset{compat=newest}: removing it from the code solves the problem. I do not understand why this is the case. Can somebody help me, please? Please, find hereby the MWE.

\documentclass{beamer}
\usepackage{tikz,pgfplots} 
\pgfplotsset{compat=newest} % <-- This generates the issue
\usetikzlibrary{intersections}

% New command to show and label intersections
\newcommand*{\ShowIntersection}[2]{
    \fill 
    [name intersections={of=#1 and #2, name=i, total=\t}]
    [draw=black,fill=red] 
    \foreach \s in {1,...,\t}{(i-\s) circle (2pt) node (intersection\s) {}};
}

\begin{document}

\begin{frame}
\frametitle{MWE}
\centering

    \begin{tikzpicture}
    \begin{axis}

    \addplot [name path global=f] {-x};
    \addplot [name path global=g] {0};
    \ShowIntersection{f}{g}

    \end{axis}  
    \end{tikzpicture}

\end{frame}

\end{document}
  • 1
    Use compat=newest is not good idea. Better is use number of version of the used pgfplots (temporary the recent is 1.16). – Zarko Feb 07 '20 at 04:18

1 Answers1

5

The issue is not really compat=newest but the fact that you are using a deprecated syntax for the circles. If you switch to the modern syntax circle[radius=2pt], the issue is solved.

\documentclass{beamer}
\usepackage{tikz,pgfplots} 
\pgfplotsset{compat=newest} % <-- This is fine
\usetikzlibrary{intersections}

% New command to show and label intersections
\newcommand*{\ShowIntersection}[2]{
    \fill 
    [name intersections={of=#1 and #2, name=i, total=\t}]
    [draw=black,fill=red] 
    \foreach \s in {1,...,\t}{(i-\s) circle[radius=2pt] node (intersection\s) {}};
}

\begin{document}

\begin{frame}
\frametitle{MWE}
\centering

    \begin{tikzpicture}
    \begin{axis}

    \addplot [name path global=f] {-x};
    \addplot [name path global=g] {0};
    \ShowIntersection{f}{g}

    \end{axis}  
    \end{tikzpicture}

\end{frame}

\end{document}

enter image description here

Of course, you could also use circle shaped nodes.

\documentclass{beamer}
\usepackage{pgfplots} 
\pgfplotsset{compat=newest} % <-- This works fine
\usetikzlibrary{intersections}

% New command to show and label intersections
\newcommand*{\ShowIntersection}[2]{
    \fill 
    [name intersections={of=#1 and #2, name=i, total=\t}]
    \foreach \s in {1,...,\t}{(i-\s) 
    node[circle,inner sep=0pt,minimum size=4pt,draw=black,fill=red] (intersection\s) {}};
}

\begin{document}

\begin{frame}
\frametitle{MWE}
\centering

    \begin{tikzpicture}
    \begin{axis}

    \addplot [name path global=f] {-x};
    \addplot [name path global=g] {0};
    \ShowIntersection{f}{g}

    \end{axis}  
    \end{tikzpicture}

\end{frame}

\end{document}
  • 1
    Code for \newcommand is copied from the TikZ & PGF manual, page 145, where is (still) used old syntax. Hopefully, that new syntax will be introduced in the next new edition of manual. Thank you for the tip! (+1) – Zarko Feb 07 '20 at 07:17
  • @Zarko Thanks! pgf and pgfplots are maintained not by precisely the same folks (even though there is at least one person in common). One can report issues at https://github.com/pgf-tikz/pgf/issues. If you do not want to then I will be happy to report it there. –  Feb 07 '20 at 07:26
  • Please, be so kind and do this. I'm not familiar with github :-( – Zarko Feb 07 '20 at 07:53
  • I guess this was already done :) See https://github.com/pgf-tikz/pgf/issues/826 and https://sourceforge.net/p/pgfplots/bugs/232/ – Stefan Pinnow Feb 07 '20 at 08:01
  • @StefanPinnow Thanks! (I added another issue concerning the manual, please feel free to remove it.) –  Feb 07 '20 at 08:08