3

How can I import all the elements of a csv file along with corresponding eps files? Basically I have 3 columns, NSC, Name, Structure. I was able to import text using csvsimple package and I think I have figured out how to import an image of the structure. I wrote the macro into the csv file directly. For example I entered: {\tikz \node[inner sep=0pt] at (0,0) {\includegraphics[width=.4\textwidth]{chemstruc4.png}};}. The result is shown below, however I have too much white padding and there are mysterious quotation marks. How can remove the quotes, center the content and make the fitment/alignment tighter? Thanks.

enter image description here

\documentclass{standalone}

\usepackage{csvsimple}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tikz}

\begin{document}
\csvreader[head to column 
names,tabular=m{0.2\linewidth}m{0.3\linewidth}m{0.5\linewidth},table 
head=\toprule\bfseries NSC & \bfseries Name & \bfseries strucPath 
\\\midrule,table foot=\bottomrule]%
{pseudoDF.csv}{}%
{\pseudoNSC & \pseudoName & \strucPath}     

\end{document}

1 Answer 1

4

It is difficult to give answers to all questions without an MWE csv file, but I try.

  • The padding is defined by your tabular definition. If m{0.2\linewidth} is made smaller or replaced by l, there is not so much padding.

  • Table columns with fixed width can be centered by adding >{\centering\arraybackslash}

  • I do not get quotation marks. Maybe, the not-shown csv file of yours contains special signs (possibly from some UTF8 encoding?) or the contents are not comma separated.

I made up an MWE:

\documentclass{standalone}
\usepackage{csvsimple}
\usepackage{array}
\usepackage{booktabs}
\usepackage{tikz}
\usepackage{graphicx}

\begin{filecontents*}{pseudoDF.csv}
pseudoNSC,pseudoName,strucPath
NSC25348,cLmWrXslh,{\tikz\node[inner sep=0pt] at (0,0) {\includegraphics[width=\linewidth]{example-image-a}};}
NSC07145,tMkSERCJs,{\tikz \shadedraw [shading=ball] (0,0) circle (.5cm);}
NSC31876,erBaDLxPN,{\includegraphics[width=\linewidth]{example-image-b}}
\end{filecontents*}

\begin{document}

\csvreader[head to column names,
  tabular=ll>{\centering\arraybackslash}m{0.4\linewidth},
  table head=\toprule\bfseries NSC & \bfseries Name & \bfseries strucPath \\\midrule,
  table foot=\bottomrule]%
{pseudoDF.csv}{}%
{\pseudoNSC & \pseudoName & \strucPath}

\end{document}

The output is:

enter image description here

1
  • That's great! I'm not sure why I have quotation marks around my images but you don't, even though I double checked my syntax for those lines in the csv file. However, when I remove at (0,0) the quotation marks disappear! I apologise for not providing a better MWE. Thank you so much for the help! Commented Mar 19, 2018 at 13:35

You must log in to answer this question.

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