Transpose table if column was created by `create on use`

I am trying to transpose a table where one column was created using create on use however the second row of the transposed table doesn’t show up, the vertical separation bars are missing and also the math mode is ignored for the $x$ in the transposed table. Here is my example:

documentclass{article}
usepackage{booktabs}
usepackage{pgfplotstable}
begin{document}

pgfplotstableread{
x  
1  
2  
3  
4  
5  
6  
7  
8  
}mytable

pgfplotstableset{
  create on use/y/.style={
    create col/expr={thisrow{x}^2}
  }
}

pgfplotstabletranspose[string type,
    colnames from=x,
    input colnames to=x
]mytablenew{mytable}


Original table:

begin{center}
pgfplotstabletypeset[
columns={x,y},
columns/x/.style={column name=$x$},%
columns/y/.style={column name=$y$},%
]{mytable}
end{center}


vspace*{1ex}

Transposed table:

begin{center}
pgfplotstabletypeset[
    %rows={x,y}, %doesn't work
    every head row/.style={
        after row=midrule
      },
      every column/.style={column type={l|}},
      every last column/.style={column type={l}},
      row/x/.style={row name=$x$},
      row/y/.style={row name=$y$}
    string type]{mytablenew}
  end{center}

end{document}

enter image description here

How can I make this work?

Leave a Reply

Your email address will not be published. Required fields are marked *