0

I am using pgfplotstabletypeset for multiple tables in a project, this code imports the data correctly. However, the first column of the head row always gets these odd letter combination and I am not able to change the style of the first column. The following code is used:

    %first making some test .csv%
    \begin{filecontents*}{scientists.csv}
    name,surname,age
    Albert,Einstein,133
    Marie,Curie,145
    Thomas,Edison,165
    \end{filecontents*}
    %end of test file

This .csv file is used by pfgplotstable to type set the table


    %my code
    \documentclass{customized_book}
    \usepackage{pgfplotstable}
    \usepackage{booktabs}
    \begin{document}
    \begin{table}
        \centering
        \pgfplotstabletypeset[col sep=comma, string type,
            every head row/.style={before row=\toprule, after row=\midrule},
            every last row/.style={after row=\bottomrule},
            columns/name/.style={column type=r}
            ]{scientists.csv}
    \end{table}
    \end{document}

The document class a customized version of the book.cls and provided as template by my university. The class currently loads the following packages:

\RequirePackage[T1]{fontenc}                        % T1 font encoding for PDFs
\RequirePackage{lmodern}                                % extended font definition
\RequirePackage{amsmath,amssymb,amsthm} % most important math stuff
\RequirePackage{a4wide}                                 % make better use of A4 paper
\RequirePackage{fancyhdr}                               % custom headers and footers
\RequirePackage{fncychap}                               % custom chapter titles
\RequirePackage{graphicx}                               % graphics
\RequirePackage{color}                                  % color
\RequirePackage{booktabs}                               % extra tabular commands
\RequirePackage[format=plain]{caption}  % improved caption format
\RequirePackage{nomencl}                                % cool nomenclature listing
\RequirePackage{makeidx}                                % create your index
\RequirePackage[printonlyused]{acronym}
\RequirePackage{ifthen}                                 % if-then commands (used in maketitle)
\RequirePackage{eso-pic}                                % picture in back/forground (used in cover)
\RequirePackage{relsize}                                % \textlarger, \textsmaller etc
\RequirePackage{enumitem}                               % enables removal of itemseparation
\RequirePackage{subcaption}
\RequirePackage{tabularx}                               % textwrapping in tables
\RequirePackage{comment}
\RequirePackage{hyperref}                               % add url to bibliography
\RequirePackage{rotating}
\RequirePackage{tikz}
\RequirePackage{array}
\RequirePackage{booktabs}
\RequirePackage{multirow}
\RequirePackage{adjustbox}
\RequirePackage{pgfplotstable}
\RequirePackage{chngpage}
\RequirePackage{hyperref}
\RequirePackage{csvsimple}
\RequirePackage{colortbl}

The compilation returns the following table:

The compiled table

As can be seen, the first column has not been aligned to the right and there are some funky symbols added to the first column of the first row. These symbols remain, even if I completely clear this cell in the csv. What could this be? Given that the problem repeats for every single table that I use \pgfplotstabletypeset for, I think it is not a syntax error, but some funky combo of packages that misses the correct start of the .csv file.

2
  • Welcome! What is \documentclass{customized_book}?
    – user194703
    Jan 24, 2020 at 23:02
  • Hi, there is a standard class that is called "book". This class has been customized to suit faculty requirements on layout. I refer to it as "customized_book" here.
    – LFSvenne
    Jan 26, 2020 at 16:35

2 Answers 2

2

Welcome! Your document has unfortunately a number of issues,

  • \begin{document} before \usepackage{pgfplotstable},
  • presumably \usepackage{booktabs} is missing (unless it gets loaded by \documentclass{customized_book}, how would one know),
  • two \documentclass commands
  • missing \end{table}

Fixing these issues one gets

\begin{filecontents*}{scientists.csv}
name,surname,age
Albert,Einstein,133
Marie,Curie,145
Thomas,Edison,165
\end{filecontents*}
\documentclass{article}
\usepackage{booktabs}
\usepackage{pgfplotstable}
\begin{document}
\begin{table}
    \centering
    \pgfplotstabletypeset[col sep=comma, string type,
        every head row/.style={before row=\toprule, after row=\midrule},
        every last row/.style={after row=\bottomrule},
        columns/name/.style={column type=r}
        ]{scientists.csv}
\end{table}
\end{document}

enter image description here

As you can see, once you fix the issues, the alignment works.

5
  • It looks like I have been sloppy in typing a simplified variant of the code for the question. The real code uses a class, where all packages are loaded, when I introduce your changes it still turns out as the image in the oringinal question. I added the packages that are loaded in the class
    – LFSvenne
    Jan 26, 2020 at 16:38
  • I have not been able to solve the problem though
    – LFSvenne
    Jan 30, 2020 at 10:59
  • @LFSvenne You really do not provide a complete information (as far as I can see) and I have done all that I can to solve your problem given the information. Also, please allow me to remark that the choice of packages loaded by the class is not as good as it could be. For instance, one should not load \RequirePackage{color}, tikz loads xcolor which supersedes color.
    – user194703
    Jan 30, 2020 at 14:53
  • It was indeed inclomplete. The csv file was not writen in tex, but by excel. Since the original file I used would be too much useless info. (see anwer below), tnx for your comments
    – LFSvenne
    Feb 6, 2020 at 10:06
  • @LFSvenne Well, I do not have a crystal ball.
    – user194703
    Feb 6, 2020 at 15:15
-1

The .csv file used by the script was exported from excel in UTF-8 coding. Using an other coding option in excel for csv export (during save of the file) made a new csv file. The new file was loaded by \pgfplotstabletypeset. It now displays the content of the cell first cell and the first column is accessible.

You must log in to answer this question.

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