2

I have a table produced by pgfplotstable. I want to force two headers to wrap on two lines but I can't get it working.

This is in my script:

\documentclass{article}

% Set the values for the biblography
\usepackage[
    isbn=false,
    url=false,
    doi=false,
    eprint=false,
]{biblatex}

% For tables
\usepackage{pgfplotstable}
\usepackage{booktabs}
\usepackage{array}
\usepackage{caption}

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

\pgfplotstableset{
    font={\small},
    empty cells with={--}, %  replace empty cells with ’--’
    every head row/.style={before row=\toprule,after row=\midrule},
    every last row/.style={after row=\bottomrule}
}

\newcolumntype{C}[1]{>{\centering\let\newline\\\arraybackslash\hspace{0pt}}m{#1}}

%Set column width (This is my fix...)
\setlength{\tabcolsep}{3.5pt}

% Create command for paragraph style (new line after)
\newcommand{\myparagraph}[1]{\paragraph{#1}\mbox{}\\}

\begin{document}


\myparagraph{paragraph}
Blalalala

% Add table
\begin{table}
\caption{My table}
\centering
\pgfplotstabletypeset[
    columns/City/.style={string type},
    columns/Wrap it/.style={column type=|C},
    col sep=comma]{table.csv},
\end{table}


\end{document}

I got the error Paragraph ended before \NC@find was complete. before the \end{table} line.

This is my table.csv

City,Wrap it
London,12
Paris,12
Rome,323

I want the header "Wrap it" to be on two lines, so to reduce the width of only the second column.

  • 1
    Can you make a MWE with a few lines of data? It's not clear from what you have described. – percusse Aug 13 '13 at 8:27
  • Sorry what's a MWE? – Francesco Aug 13 '13 at 8:44
  • Oops,sorry. That's a minimal working example that starts with \documentclass{...} all the way to \end{document} that replicates the issue. Here is more info about MWE – percusse Aug 13 '13 at 9:00
  • Well, thank you for taking care of my misfortunes... – Francesco Aug 13 '13 at 9:18
3

You need to either remove the argument from the column declaration or use C{2.5em}. Then your example works without any problems.

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

\newcolumntype{C}{>{\centering\arraybackslash}m{2.5em}}

\pgfplotstableset{
    font={\small},
    empty cells with={--}, %  replace empty cells with ’--’
    every head row/.style={before row=\toprule,after row=\midrule},
    every last row/.style={after row=\bottomrule}
}

\begin{document}

\begin{table}
\caption{My table}
\centering
\pgfplotstabletypeset[
    columns/City/.style={string type},
    columns/Wrap it/.style={column type=|C},
    col sep=comma]{
    City,Wrap it
    London,12
    Paris,12
    Rome,323
},
\end{table}

\end{document}

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.