csvsimple respect dollar not working

It's certainly a bug, a workaround could be to deactivate the $ sign before the table and reactivate it after.

\documentclass[12pt,letterpaper,landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in,bottom=1in,top=1in]{geometry}
\usepackage{csvsimple}

% this code is only to create BOM.csv, you don't need it:
\usepackage{filecontents}
\begin{filecontents*}{BOM.csv}
Qty|PartDescription|ManufacturerPartNum|Reference|UnitPriceAtOneKUnits
5|Part 1|Option|Z1,Z2,Z3| $0.003
1|Part 2|Option|D1,D2,D3,D4| $0.004
2|Part 3|Option|U1,U2,U3,U4| $0.008
\end{filecontents*}


\begin{document}
Before the table \$ works as usual $a+b$
\catcode`\$=12% deactivate $ sign
\begin{table}[h]
    \begin{tabular}{c|l|l|l|r}%
        \bfseries Qty & \bfseries Part Description & \bfseries Manufacturer Part \# & \bfseries Reference & \bfseries Unit Price At 1K Units
        \csvreader[
        head to column names,separator=pipe]{BOM.csv}{}%
        {\\\hline\Qty & \PartDescription & \ManufacturerPartNum & \Reference & \UnitPriceAtOneKUnits}%
    \end{tabular}
\end{table}
\catcode`\$=3% reactivate $ sign

After the table \$ works as usual $a+b$
\end{document}

enter image description here


Actually, respect dollar also sets the \catcode of $ to 12 at the begin of \csvreader. But this setting gets lost from one cell of the table to the next, because cell contents are inside a TeX group.

Therefore, $ has to be deactivated before the table starts. CarLaTeX showed one way to do it.

The other way is to use the built-in tabular functions from csvsimple:

\documentclass[12pt,letterpaper,landscape]{article}
\usepackage[utf8]{inputenc}
\usepackage[margin=1in,bottom=1in,top=1in]{geometry}
\usepackage{csvsimple}
\begin{document}
  \begin{table}[h]
    \csvreader[respect dollar,head to column names,separator=pipe,
      tabular={c|l|l|l|r},
      table head={\bfseries Qty & \bfseries Part Description & \bfseries Manufacturer Part \# & \bfseries Reference & \bfseries Unit Price At 1K Units\\\hline},
      late after line=\\\hline,
      late after last line=,
    ]{BOM.csv}{}%
    {\Qty & \PartDescription & \ManufacturerPartNum & \Reference & \UnitPriceAtOneKUnits}%
  \end{table}
\end{document}

Here, respect dollar works for the whole table and not for the first line only.

Tags:

Csvsimple