我想在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
您可以将变量设置为使用datatool
可读的CSV。然后,您可以定义一个宏(如下面的datatool
),该宏根据某些输入读取一个值。
\printval
虽然LaTeX不是数据库工具,但是即使对于大型文档,这种方法也足够灵活。