1

Is there a way to get a table created with pgfplotstable inside another tabular environment. I'm trying to get multiple subtables in multiple columns. The following simplified version does not work.

\documentclass[12pt]{report}
\usepackage{tikz}
\usepackage{pgfplotstable}
\begin{document}    

% this works
\begin{tabular}{c}
\begin{tabular}{ccc}
A & B & C\\
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{tabular}
\end{tabular}

% this doesn't work
\begin{tabular}{c}
\pgfplotstabletypeset[%
   col sep=space,
   header=false,
   columns/0/.style={int detect, column name=A},
   columns/1/.style={int detect, column name=B},
   columns/2/.style={int detect, column name=C},
]{%
1 2 3
4 5 6
}
\end{tabular}

\end{document}
0

Welcome to TeX-SE! One thing that does work is to write the table in a savebox and then to use it in the outer table.

\documentclass[12pt]{report}
\usepackage{pgfplotstable}
\newsavebox{\mytab}
\begin{document}    

% this works
\begin{tabular}{c}
\begin{tabular}{ccc}
A & B & C\\
1 & 2 & 3 \\
4 & 5 & 6 \\
\end{tabular}
\end{tabular}

\begin{lrbox}{\mytab}
\pgfplotstabletypeset[%
   col sep=space,
   header=false,
   columns/0/.style={int detect, column name=A},
   columns/1/.style={int detect, column name=B},
   columns/2/.style={int detect, column name=C},
]{%
1 2 3
4 5 6
}
\end{lrbox}
\begin{tabular}{c}
\usebox{\mytab}
\end{tabular}
\end{document}

enter image description here

1
  • Thank you. This work for this problem. After a few days of tinkering, I was able to get it to work inside the environment I needed it in.
    – Tim
    Apr 3 '19 at 16:24

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.