2

I currently have:

\documentclass{article}  
\usepackage{filecontents}
\usepackage{filecontents}    
\usepackage{pgfplots}  
\usepackage{pgfplotstable}    
\begin{filecontents*}{rawdata.txt}    
trial   water   massi   massf   tempi   tempf  
1   50.00   101.86  101.42  22.3    29.6    
2   50.00   101.41  100.79  22.5    26.4  
3   50.00   100.80  100.19  22.3    29.9  
4   50.00   100.18  99.58   22.7    28.0  
5   50.00   99.58   98.96   22.6    27.3  
\end{filecontents*}      
\begin{document}  
\pgfplotstabletypeset[    
 columns/trial/.style={column name={Trial}},  
  columns/water/.style={column name={Water volume \\ (mL \pm 0.02 mL)},   zerofill},   
 columns/massi/.style={column name=Initial burner mass, zerofill},    
  columns/massf/.style={column name=Final burner mass},  
  columns/tempi/.style={column name=Initial temp},  
  columns/tempf/.style={column name=Final temp,precision=1,zerofill},  
]{rawdata.txt}  
\end{document}  

This doesn't work and moves it under Trial, which I don't want. How do I make multi-line headings using this configuration?

  • I'm sorry about that, I just learned that you need 2 spaces to register a new line. Hopefully, this will make it easier to understand my problem. Thanks! – ttn729 Nov 11 '18 at 3:19
  • There seems to be a \begin{document} missing and \pm needs to be in math mode. Assuming you do not want to use siunitx, you might just wrap it in $ signs. And then I do not understand the question. – user121799 Nov 11 '18 at 3:27
  • (mL ±0.02mL) is under Trial when it should be under water volume, and the other column names seem to have shifted left, leaving the last column without a heading. This happens when I use \\ to create a new line to make the heading span across 2 lines. – ttn729 Nov 11 '18 at 3:40
2

You may use \makecell for that.

\documentclass{article}  
\usepackage{filecontents}  
\usepackage{makecell}
\usepackage{siunitx}
\usepackage{pgfplots}  
\usepackage{pgfplotstable}    
\begin{filecontents*}{rawdata.txt}    
trial   water   massi   massf   tempi   tempf  
1   50.00   101.86  101.42  22.3    29.6    
2   50.00   101.41  100.79  22.5    26.4  
3   50.00   100.80  100.19  22.3    29.9  
4   50.00   100.18  99.58   22.7    28.0  
5   50.00   99.58   98.96   22.6    27.3  
\end{filecontents*}    
\begin{document}
\pgfplotstabletypeset[    
 columns/trial/.style={column name={Trial}},  
  columns/water/.style={column name={\makecell[b]{
  Water volume \\ ($\si{\milli\liter}\pm 0.02\si{\milli\liter}$)
}},   zerofill},   
 columns/massi/.style={column name=Initial burner mass, zerofill},    
  columns/massf/.style={column name=Final burner mass},  
  columns/tempi/.style={column name=Initial temp},  
  columns/tempf/.style={column name=Final temp,precision=1,zerofill},  
]{rawdata.txt}  
\end{document}  

enter image description here

And with \makecell[t]{...

enter image description here

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.