3

I seem unable to use columns defined with dcolumn with datatool. For example if my table is

table1.csv
events,100,10

\usepackage{dcolumn}                                                                                                                                                                                              
\usepackage{datatool}

\DTLloaddb[noheader,keys={events,num,err}]{table1}{table1}

\newcolumntype{d}{D{,}{\pm}{-1}} 

\begin{table}[h]
\begin{tabular}{l d}%                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                        
    {\bf Events} & {Number with Error} %                                                                                                                                                               
    \DTLforeach*{table1}{%                                                                                                                                                                                      
      \events=events,\num=num,\err=err}{%                                                                                                                       
      \\                                                                                                                                                                                                          
      \events & \num , \err}%                                                                                                                                                                                                                                                                                                                                    
  \end{tabular}                                                                                                                                                                                                   
\end{table}                                     

If datatool was working with dcolumn, I'd expect a plus-or-minus sign between 100 and 10 when printed, but it returns a comma, "100 , 10"

Does anyone have any suggestions? I'd like to use datatool to automate a lot of the table making but I also really like the formatting afforded by dcolumn.

1 Answer 1

3

Your posted code wasn't complete, but when I filled in what I assumed were the missing bits, I do see a plus/minus sign?

\documentclass{article}
\usepackage{dcolumn}                                                                                                                                                                                              
\usepackage{datatool}

\DTLloaddb[noheader,keys={events,num,err}]{table1}{table1.csv}

\newcolumntype{d}{D{,}{\pm}{-1}} 

\begin{document}

\begin{table}[h]
\begin{tabular}{l d}% 
    {\bf Events} &\multicolumn{1}{c}{Number with Error}
    \DTLforeach*{table1}{%
      \events=events,\num=num,\err=err}{%
      \\
      \events & \num , \err}%
  \end{tabular}
\end{table}                                     

\end{document}
1
  • You're right, sorry about that. In fact I found the error when I looked for the difference in what I posted and what I was running over. My table1.csv actually looked like: events,$100$,$10$ (not: events,100,10). When I remove the $s from the numbers in the csv file, it works fine. Thanks much!
    – Eric
    Jan 30, 2012 at 13:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .