3

The content of the file matrix.dat is:

11 12 13 14  
21 22 23 24
31 32 33 34

What I want is a rendering in LaTeX like this:

/ 11 12 13 14 \
| 21 22 23 24 |
\ 31 32 33 34 /

I can load the file with pgfplotstable and render it as pmatrix.

\pgfplotstableread{data/matrix.dat}\mytable
\pgfplotstabletypeset[
  begin table=\begin{pmatrix},
  end table=\end{pmatrix},
  skip coltypes,
  display columns/0/.style={string type},
  write to macro=\mymatrix,
  typeset=false
]{\mytable}
$\mymatrix$

But what I get is:

/  0  1  2  3 \
| 11 12 13 14 |
| 21 22 23 24 |
\ 31 32 33 34 /

I could not find an option in pgfplotstable to skip the head row (and not a data row). In pgfplots there is an option

\addplot file[skip first] {datafile.dat};

What can I do?

There is a related posting dealing with a multicolumn header for pgfplotstable lacking a solution: http://old.nabble.com/pgfplotstable%3A-multicolumn-header-td28329964.html

2

For this, you should use the option header=has colnames when reading the table. This tells pgfplots to assume the first line of the file to contain the header, even if it consists only of numbers.

\documentclass{article}
\usepackage{pgfplotstable}
\usepackage{amsmath}

\begin{filecontents}{matrix.dat}
11 12 13 14  
21 22 23 24
31 32 33 34
\end{filecontents}

\begin{document}

\pgfplotstableread[header=has colnames]{matrix.dat}\mytable
\pgfplotstabletypeset[
  begin table=\begin{pmatrix},
  end table=\end{pmatrix},
  skip coltypes,
  write to macro=\mymatrix,
  typeset=false
]{\mytable}
$\mymatrix$

\end{document}

pmatrix from file

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.