我正在尝试编译将 CSV 导入 longtable (ltxtable) 的 latex 代码。该代码在 Windows 中已成功编译,但在 Mac OS X 中却出错。
\documentclass{article}
\usepackage{datatool}
\usepackage{filecontents}
\usepackage{ltxtable}
\begin{document}
%% Read CSV conents
\DTLloaddb[noheader,keys={abbr,desc}]{abbreviations}{abbreviations.csv}
\DTLsort{abbr}{abbreviations}%
%% Write CSV into LaTex file (ltxtable)
\begin{filecontents}{abbreviations.tex}
\begin{longtable}{>{\bfseries}l X}
\DTLforeach{abbreviations}{%
\abbr=abbr,\desc=desc}{%
\\
\abbr& \desc%
}
\end{longtable}
\end{filecontents}
%% Include the LaTex file (ltxtable)
\LTXtable{\textwidth}{abbreviations.tex}
\end{document}
错误:
Runaway argument?
\@nil \let \@dtl@line =\@dtl@trmstr \ifx \@dtl@line \@longempty \else \ETC.
! File ended while scanning use of \@dtl@trim.
CSV 文件有两列,例如:
%% Abbreviations List
FHSS,Frequency Hopping Spread Spectrum
CRLB,"Cram\'{e}r-Rao Lower Bound"
答案1
这可能与操作系统有关并且与LaTeX 对 BOM 感到困惑——Unicode 的字节顺序标记。
删除“标题”%% Abbreviations List
似乎可以解决问题。