0

I use the \pgfplotstableread{} command of the pgfplotstable package and manually type in a table.

\documentclass{article}
\usepackage{pgfplotstable}

\begin{document}

\pgfplotstableread{
  Col1  Col2
  p0    Text0
  p1    Text1%blabla
  p2    Text2
  p3    Text3
}\mytable

\end{document}

There seems to be a bug with comments at the end of rows. With the provided example, I am getting the following error:

Package pgfplots Error: Table '<inline_table>' appears to have too many columns in line 3: Ignoring 'Text2'. PGFPlots found that the number of columns is larger than the previously determined number of columns. Please verify that every cell entry is separated correctly (use braces {} if necessary. Also verify that column names are plain ASCII.). This error is not critical.

I am not sure what's going on but when I remove %blabla, the document compiles just fine. Until now, I thought that comments at the end of lines were "invisible" in Latex.

4
  • Welcome to tex.sx. I'm not a user of pgfplots, but what I think is happening is that the % is suppressing the line ending, which is needed to make a correct column count. Try adding a space before the %. (Just a guess; not tested.) Commented Jan 1 at 22:17
  • 1
    as Barbara wrote you are hiding the newline character. Try p1 Text1^^M%blabla Commented Jan 1 at 22:51
  • It is not true that "comments at the end of lines are invisible". This answer gives a run down of what happens. In particular, during state "M", the end of line character is converted to a space, if encountered. So the comment character % may end up removing a space, if it is not preceded by a space character. // The effect is more pronounced when you are in \obeylines where the end of line character is converted to \par instead of a space. // Your question is about another context where the presence of the end of line character matters. Commented Jan 2 at 3:07
  • Thanks for explaining! Adding a space before the % does not solve the issue but I now understand the issue.
    – babajabba
    Commented Jan 2 at 12:45

1 Answer 1

2

The manual says that [row sep=newline] is fragile, even though it is the default. You can start a line with % and the whole line is ignored.

\documentclass{article}
\usepackage{pgfplotstable}

\begin{document}

\pgfplotstableread[every column/.style={string type},row sep=\\]{
  Col1  Col2\\
  p0    Text0\\
  p1    Text1\\%blable
  p2    Text2\\
  p3    Text3\\
}\mytable

\pgfplotstabletypeset[every column/.style={string type}]{\mytable}

\end{document}

You must log in to answer this question.

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