Skip to main content
13 votes

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

Quick and dirty expl3 implementation: First you load the CSV file with \LoadCSV{<label>}{<file>}. This command will open the file and load the contents of the CSV into <label>. The ...
Phelype Oleinik's user avatar
12 votes
Accepted

What's the best way of typing the following 58 equations into LaTeX?

Here's a possible implementation; the delimiters can be changed. \documentclass{article} \usepackage{amsmath,multicol} \usepackage{xparse} \ExplSyntaxOn \NewDocumentCommand{\constraints}{omO{x}} { ...
egreg's user avatar
  • 1.1m
12 votes

What's the best way of typing the following 58 equations into LaTeX?

You can automate the job by exporting the Excel spreadsheet to a comma delimited file (for example subscripts.csv) and reading your data with the readarray package. MWE Assuming that the content of ...
Tonechas's user avatar
  • 976
12 votes

What's the best way of typing the following 58 equations into LaTeX?

Use Excel's CONCAT function. It's probably easiest to do this in Excel, especially if it's a one-time thing. Excel has several text-manipulation functions, and I have often found it a very ...
workerjoe's user avatar
  • 457
10 votes

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

Let us say we have the following code: \documentclass[11pt,a4paper,sans]{moderncv} % moderncv themes \moderncvstyle{classic} % casual, classic, banking, oldstyle and fancy \moderncvcolor{blue} \...
Mensch's user avatar
  • 65.6k
10 votes
Accepted

Populate information from a csv file into a LaTeX document (specifically into the fields/arguments of commands therein)

With readarray (and listofitems included). First, I employ readarray macros \readarraysepchar{\\} \readdef{personalinfo.csv}\myrawdata to take the contents of personalinfo.csv and place it into the ...
Steven B. Segletes's user avatar
9 votes

Suppress ampersand in external text

You can set locally the catcode of & when reading the data. It will not disturb the use of & later, and unlike \detokenize it will not break other commands like non-ascii input in your input: ...
Ulrike Fischer's user avatar
8 votes

Unexpected result from trying to use \ce{} from mhchem package with a command defined by \DTLgetvalue from the datatool package

It seems that \ce requires its argument to be expanded (presumably because \ce parses it) so you need to use \expandafter to ensure the argument is in the correct format: \expandafter\ce\expandafter{\...
Nicola Talbot's user avatar
8 votes
Accepted

How to count the occurence of M and F in a particular column , No. of male and female deaths?

A variant using datatool and some counters. \documentclass[11pt]{report} \usepackage{filecontents} % this just saves the data to a text file \begin{filecontents*}{deathdata.txt} Sl.,Unique ID,Name,...
Torbjørn T.'s user avatar
8 votes
Accepted

Overhanging vertical bars in tabular

The last \\\hline shouldn't be inside the the loop but after it, so that the code of the loop doesn't triggers the creation of a new row: \documentclass{article} \usepackage{datatool} \usepackage{...
Ulrike Fischer's user avatar
7 votes

How to count the occurence of M and F in a particular column , No. of male and female deaths?

Here, if you place your table data in a \def, you can use the created macro \analyze to look for patterns. This macro employs the listofitems package to parse the data in your table, and count the ...
Steven B. Segletes's user avatar
7 votes
Accepted

How to align the last element on the right when using \hfill?

There are two obvious problems with your code. You get errors about both of them. Firstly you mistyped \makeatother as \makeatotherx which causes LaTeX to complain ! Undefined control sequence. l....
moewe's user avatar
  • 178k
6 votes
Accepted

DTLgetvalueforkey works, but DTLfetch doesn't

The datatool user guide mentions the following about \DTLfetch: \DTLfetch{<db name>}{<col1 name>}{<col1 value>}{<col2 name>} This fetches and displays the value for &...
Werner's user avatar
  • 607k
6 votes
Accepted

How can I remove all rows with larger DTLrowi than 10?

It doesn't make sense to remove rows when you're making a table: the removal would be local and wouldn't affect the data base. Just ignore those rows. Also you cannot end a conditional in a different ...
egreg's user avatar
  • 1.1m
6 votes
Accepted

How can this complex command be broken down and explained for someone starting with Tex?

\makeatletter and \makeatother are needed in order to allow using command names with @ in them. There is nothing really special about it. The first idea is to use \NewDocumentCommand{\DTLfetchifnull}{...
egreg's user avatar
  • 1.1m
6 votes

Misplaced noalign with datatool and booktabs

you are hiding the last \ inside the DTLforeach and this separates it from the \bottomrule. That doesn't work. Build the rows outside the tabular: \documentclass{article} \usepackage{booktabs} \...
Ulrike Fischer's user avatar
5 votes

Read cell value from string array and it assign to macro

I propose an altogether different approach, which has the advantage of being “fully expandable”; for example you can even do \MakeUppercase{\Nameone} and it will print ALFRED Here is the code. ...
egreg's user avatar
  • 1.1m
5 votes
Accepted

retrieving substring of `\DTLfetch`

Unfortunately, \DTLfetch is not expandable, but there's a way out: \DTLfetch saves the returned value in \dtlcurrentvalue, so it's just a matter of making this available for processing in \StrRight ...
egreg's user avatar
  • 1.1m
5 votes
Accepted

How to find the smallest number from a given set of numbers?

Maybe like this? \begin{filecontents*}{\jobname.csv} Name, EL-1, EL-2, EL-3, EL-4 Biki, 60, 40, 50, 80 Don Giovanni, 640, 231, 100, 91 \end{filecontents*} \documentclass[...
egreg's user avatar
  • 1.1m
5 votes
Accepted

\MakeUppercase fails to capitalize macro retrieved via \DTLfetch from datatool package

\DTLfetch is not expandable, so it can not work in the argument of \MakeUppercase, even if hidden inside \myvariable. Instead, you can use \DTLgetvalueforkey to assign the value to \myvariable, then \...
Marcel Krüger's user avatar
5 votes

Pass value from newcommand to siunitx

Your \getfirstrowfromcol command is not expandable. I suggest to do it a different way. \begin{filecontents*}{myfile.csv} filename,date,pressure blabla,2018-03-12,66 \end{filecontents*} \...
egreg's user avatar
  • 1.1m
5 votes
Accepted

Creating nice form letters for nontechnical users

First of all, the letter environment requires an argument, namely the address. This is probably the reason why the word Dear or parts of it disappear. Regarding how to hide the machinery for ...
gernot's user avatar
  • 50k
5 votes
Accepted

How to extract the currency symbol?

After running \DTLifcurrency or the internal equivalent \@dtl@checknumerical, the currency symbol is stored in \@dtl@currency, so you can use \documentclass{article} \usepackage{datatool} \...
Marcel Krüger's user avatar
5 votes
Accepted

Why does `datatool` fail when used in a Tikz figure

Things are not that easy with \DTLfetch because this macro is not expandable. But you can make use of the approach used in this nice answer to store the output of \DTLfetch in another macro after ...
Jasper Habicht's user avatar
4 votes
Accepted

Suppress ampersand in external text

Here's a solution that just uses \DTLloadrawdb instead of \DTLloaddb: \documentclass{article} \usepackage{filecontents} \usepackage{datatool} \begin{filecontents*}{test.csv} CVR,CompanyName,...
Nicola Talbot's user avatar
4 votes
Accepted

bold or higlight first row and column of tabe created from csv file

This is using pgfplotstable and a slightly modified version of the code in PGFPlotsTable formatting problems. \documentclass{article} \usepackage{filecontents} \usepackage{adjustbox} % Make csv in ...
Torbjørn T.'s user avatar
4 votes
Accepted

Datatool - Fill Variable (name in first row) with value of second row

(Rewritten answer now the question is clearer.) The problem with \DTLforeach{Test}{\name=name,\value=value} { \newcommand{\name}{\value} } Is that \name is repeatedly redefined on each iteration by ...
Nicola Talbot's user avatar

Only top scored, non community-wiki answers of a minimum length are eligible