New answers tagged

1

Although an accepted answer is posted, I would also offer the option to use DataTool. I kept the raw \DTLfetch command exposed. it could be encapsulated in its own macro to achieve your objective. \documentclass{article} % datatool does the database work \usepackage{datatool} % the file contents \begin{filecontents*}{values.csv} color, N, n_trees, M red, ...


3

A slightly (more compact) version with expl3: \begin{filecontents*}{\jobname.csv} "N","n","M" 200,100,50 \end{filecontents*} \documentclass{article} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\readcsvfile}{m} {% #1 is the file name \lrnv_readcsvfile:n { #1 } } \NewExpandableDocumentCommand{\getcsvitem}{m} { \prop_item:Nn \...


4

Here's one alternative LaTeX3 property lists to store and retrieve the values. Use \ReadCSVArray{<file name>} to read the .csv file, and then use \ArrayItem{<key>} to retrieve the <value> associated with the key. \ArrayItem is expandable so that if the <value> is numeric, then you can use in numerical expressions in \fpeval (for ...


1

You can set your variables in a CSV that is readable using datatool. Then you can define a macro (like \printval below) that reads a value based on some input. \documentclass{article} \usepackage{datatool} % To make this into a complete, minimal example, create the following files. % In your use-case, you would create these in Excel/outside of LaTeX, most ...


2

Use csvreader for the entire table: \documentclass[12pt]{article} \usepackage{csvsimple} \begin{filecontents*}{csvtest.csv} a,b,c 1,2,3 \end{filecontents*} \begin{document} \csvreader[tabular=|c|c|c|, table head=\hline Col1 & Col2 & Col3 \\\hline, late after line=\\, late after last line=\\\hline]% {csvtest.csv}{a=\a,b=\...


1

With siunitx's S type columns instead of l type columns and \num: \documentclass{standalone} \usepackage{csvsimple} \usepackage{siunitx} \begin{filecontents*}{datax.csv} SAE;Preston large;Preston medium;Preston small;Thornbury large;Thornbury medium;Thornbury small;Watsonia large;Watsonia medium;Watsonia small 0.01;0.999719404401668;0....


Top 50 recent answers are included