在表格中插入逗号时出现问题 - pgfplotstable

在表格中插入逗号时出现问题 - pgfplotstable

我有一张要导入附录的表格。最后一列是源键,每个单元格中有几个源,我想将其列为 a、b、c;d、f、m;等等。但是,问题是 csv 文件中有逗号 - 因此为了防止它们被读作单独的列,我将单元格的信息括在括号中,并尝试将其单独放在逗号周围。这两种方法都有效 - 但在 pdf 中的文本周围留下了奇怪的引号。我在 pgfplotstable 手册和论坛上查找了这个问题,但它似乎主要处理用逗号分隔数字或小数点的数字,而不是文本。 (我从一个 csv 导入了另一个表格,其中文本中也有逗号 - 即引用:姓、名、年份、标题、城市、州:出版商。- 我也希望能够以完整的逗号导入,而不会弄乱格式。)有没有关于如何在最终表格的文本中包含这些逗号而不混淆 LaTex 或产生奇怪的格式的想法?谢谢!

\begin{filecontents*}{SE_example3.csv}
\textbf{Section 1:},,,
Item 1 has a long description,2000-2010,Short description here,"{a, b, c} "
Item 2 also has a long description,1999-2005,This is a longer description and I need     to keep this description long so I can be sure that the table will wrap,"b{,} c{,} d"
Item 3 is short,1995-2006,This is some text.,c 
\hline \textbf{Section 2:},,,
Item 4,1999-2005,This is some more text.,d
Item 5,1995-2006,Text here,e
\end{filecontents*}

\documentclass[12pt, english]{article} 
\usepackage[table]{xcolor}
\definecolor{lightgray}{gray}{0.9}
\usepackage{csvsimple}
\usepackage{longtable}
\usepackage{caption}
\usepackage{setspace}
\usepackage{booktabs}
\usepackage{pgfplotstable}

\usepackage[hmargin=2.54cm, vmargin=2.54cm]{geometry}

\begin{document} 

\pgfkeysifdefined{/pgfplots/table/output empty row/.@cmd}{
% upcoming releases offer this more convenient option:
\pgfplotstableset{
    empty header/.style={
      every head row/.style={output empty row},
    }
}
}

\rowcolors{1}{}{lightgray}
\scriptsize
\pgfplotstabletypeset[
empty header,
header=false,
begin table=\begin{longtable},
every first row/.append style={before row={%
\caption{Description of Policies}%
\label{tab:policies}\\\toprule
\textbf{Policy} &\textbf{Years} &\textbf{Description} &\textbf{Sources} \\ \toprule    
\endfirsthead
%
\multicolumn{4}{l}%
{{\bfseries Description of Policies \thetable\ Continued from previous page}} \\
\toprule 
%
\textbf{Policy} &\textbf{Years} &\textbf{Description} &\textbf{Sources} \\ \toprule      
\endhead
%
\midrule \multicolumn{4}{r}{{Continued on next page}} \\ \bottomrule
\endfoot
%
\midrule
\multicolumn{4}{r}{{Concluded}} \\ \bottomrule
\endlastfoot
}},%
%
end table=\end{longtable},
col sep=comma,
string type,
column type=l,
columns/0/.style={column type=p{6cm}},
columns/1/.style={column type=p{1.3cm}},
columns/2/.style={column type=p{6cm}},
columns/3/.style={column type=p{1cm}},
]{SE_example3.csv}

\end{document} 

例子

编辑:我刚刚意识到 Microsoft Word 正在 {} 周围插入那些“ ”;它们在编辑器中不可见,直到我为了创建 MWE 而将其作为文本文件导入时我才注意到。

相关内容