4

I am trying to plot a Tikz figure on a Beamer slide but receive the following error:

! Package pgfplots Error: Could not read table file '" x y 0.8 0.8 1. 0.8 1. 1. 0.8 1. 0.9 0.8 1. 0.9 0.9 1. 0.8 0.9 0.9 0.9 "'. In case you intended to provide inline data: maybe TeX screwed up your end-of-lines? Try 'row sep=crcr' and terminate your lines with '\\' (refer to the pgfplotstable manual for details).

Here is the Beamer presentation that generated this error:

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture} \begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
\addplot3[patch,patch refines=0,mesh,black,patch type=biquadratic] table[z expr=x^2*y^2] {
x   y
0.8 0.8
1.  0.8
1.  1.
0.8 1.
0.9 0.8
1.  0.9
0.9 1.
0.8 0.9
0.9 0.9
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

I tried the suggested solution to no avail:

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture} \begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
\addplot3[patch,patch refines=0,mesh,black,patch type=biquadratic,row sep=crcr] table[z expr=x^2*y^2] {
x   y\\
0.8 0.8\\
1.  0.8\\
1.  1.\\
0.8 1.\\
0.9 0.8\\
1.  0.9\\
0.9 1.\\
0.8 0.9\\
0.9 0.9\\
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}

When I put the same tikzpicture into an article class document, the code compiles as expected. Does anybody know what is the cause of this error in Beamer?

2 Answers 2

10

Add the [fragile] option to the frame:

\begin{frame}[fragile]
3
  • Hey @Bibi, I am also facing this error and adding fragile is not solving the issue. Could you please help? Mar 16, 2022 at 8:56
  • You should post a full MWE.
    – Bibi
    May 5, 2022 at 15:11
  • Thank you for getting back @Bibi , but I managed to fix it, I made some other mistake. May 6, 2022 at 10:35
3

Probably, when beamer is scanning the frame environment, it's loosing the line ends and the table structure because the contents are sent back and forth between various macros. The easiest is to read the table outside the frame and use the table name. But alternatively, you can make the column and rows separated with a nontrivial symbol

\documentclass[]{beamer}
\usepackage{pgfplots}
\usepgfplotslibrary{patchplots}
\begin{document}
\begin{frame}
\begin{tikzpicture} 
\begin{axis}[view={40}{40},xmin=0,xmax=1,ymin=0,max=1,zmin=0,zmax=1]
\addplot3[patch,patch refines=0,mesh,black,patch type=biquadratic] 
table[z expr=x^2*y^2,x=x,y=y,col sep=comma,row sep=crcr] {
x,y\\
0.8, 0.8 \\
1. , 0.8 \\
1. , 1.  \\
0.8, 1.  \\
0.9, 0.8 \\
1. , 0.9 \\
0.9, 1.  \\
0.8, 0.9 \\
0.9, 0.9 \\
};
\end{axis}
\end{tikzpicture}
\end{frame}
\end{document}
1
  • Splendid, this solved my problem, after hours of back-and-forth with chatGPT :). However, It worked with just row sep=crcr, col sep didn't worked...
    – MPA95
    Dec 5 at 20:30

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .