LaTeX:从cvs行中获取变量

问题描述 投票:0回答:1

我想在tex文件中快速换出不同的值-到目前为止,对于批量打印,我正在使用多个.tex文件并换出标题中的\input examplefile.tex

examplefile.tex:

\newcommand\CombineValue1{\Cat1Val1 \\ \Cat1Val2}
\newcommand\CombineValue2{\Cat3Val1 ~ \Cat1Val3}


\newcommand\Cat1Val1{Somevalue}
\newcommand\Cat1Val2{Somevalue b}
\newcommand\Cat2Val1{Somevalue c}
\newcommand\Cat3Val1{Morevalues}
....

和我的主文件中

\input example.txt

Display my Var \Cat1Val1
...

效果很好,但我不喜欢使用多个很难更新的.tex文件。我想使用csv并从特定行中获取值,例如:

% Should be the name written in column 1; like a 'key = values' table/dict.
% The numeric value of the row would be fine for a start as well
% Defined in header
\userow{my.csv}{keyname of the row} 

%and then used in the document like:
\InsertColum{2} to get the value in the 2nd colum of the specific row from my.csv
csv import latex
1个回答
0
投票

您可以将变量设置为使用datatool可读的CSV。然后,您可以定义一个宏(如下面的datatool),该宏根据某些输入读取一个值。

\printval

enter image description here

虽然LaTeX不是数据库工具,但是即使对于大型文档,这种方法也足够灵活。

© www.soinside.com 2019 - 2024. All rights reserved.