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.

I'm trying to create a new column in a pgfsplotstable which shows the compound growth over the preceding columns. The columns don't have names, and I want to shift the column a little to the right to show that the information it contains isn't part of the main data.

I've got two problems. First the \newcolumntype I've defined below doesn't compile.

Bizarrely the following \newcolumntype{R}[1]{>{\RaggedLeft\hspace{0pt}}p{#1}} compiles just fine..

Secondly and more importantly, I can't figure out how to create on use using column indices.

something like

pgfplotstableset{create on use/cagr/.style={create col/expr={
  \thisrow{[index]{3}}/\thisrow{[index]{0}}}}}

just causes errors. Any help most gratefully appreciated. Thanks

\documentclass{article}
\usepackage{array}
\usepackage{pgfplotstable}

\begin{document}

%\newcolumntype{hl}[1]{>{\hspace{1cm}}p{#1}}
\newcolumntype{x}[1]{>{\hspace{1cm}}p{#1}}


\pgfplotstabletypeset[string type,debug,
column name={},
format=inline,col sep=&,row sep=\\,header=false,ignore chars={\^^M},
columns/3/.style={column type={x{1cm}}]{
1&2&3&4\\
5&6&7&8\\
9&10&11&12\\

}

\end{document}
share|improve this question
    
there is a } missing here: style={column type={x{1cm}}] just before the ]. Also, my version of pgfplots complained that you should put \pgfplotsset{compat=1.7} in the preamble. –  Vivi Nov 5 '12 at 8:20
1  
The correct way to access columns by their index is to use \thisrowno{<index>} instead of \thisrow. –  Jake Nov 5 '12 at 8:34
    
@Vivi thank you. Yet another "doh" moment. @Jake, that is exactly what I needed and not in my pgfplotstable manual. I think I need to download a newer version! ... btw struggling to format the newly created column. columns/cagr/.style={...} doesn't seem to register. Is this me doing something wrong again or is this not how to do it? Thanks –  Tahnoon Pasha Nov 5 '12 at 9:25
    
@Jake not sure you got the notification... –  Vivi Nov 6 '12 at 0:00
1  
@Vivi: Thanks! I didn't get the notification, but I saw the message anyway. I assume Tahnoon is talking about the problem from his other question –  Jake Nov 6 '12 at 7:14

1 Answer 1

up vote 4 down vote accepted

To access columns by their index number, you have to use \thisrowno{<number>}. The macro \thisrow{<name>} can only be used to refer to columns by their name, the [index]<number> syntax doesn't work in this case.

share|improve this answer

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.