Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
add comment

1 Answer 1

up vote 1 down vote accepted

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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