# Tag Info

22

Nothing much bad happens if you specify more columns than you use, so if you use {|*{50}{l|}} and no row has more than 3 entries latex doesn't use the extra col spec and just makes a 3 column table.

18

You can use pgfplotstable for this. If you load the array package, you can set the option dec sep align for pgfplotstabletypeset to get the alignment at the decimal point. Padding the numbers with zeros can be accomplished by setting fixed zerofill, the number of decimals can be set using precision, either for all columns or for individual columns by using ...

14

The usual answer here is the pgfplots package, which is based on TikZ. Note that it does not do pie charts, as these are considered misleading by many people. (There is some discussion of this issue in the TikZ manual.) (Note: As mathematicians use 'graphs' for something entirely different, the usual way to refer to data display in a graphical form is as a ...

13

My datatool skills are limited, so the following solution uses TeX primitives and PGFs mathematical engine and also its \pgfutil@in@ macro/conditional. Interaction Line 99: Minimum ratio a Cardinal needs to get elected as Pope. \pgfmathparse{2/3*\the\value{sumVotes}} Line 70: Number of Cardinals that will be marked if no one has reached the limit. As ...

12

Assuming that the first row is the name of the columns, then you simply need to load the database via \DTLloaddb{myDB}{MyData.csv} where the file MyData.csv contains the contents as shown above, and the you can use the internal function \DTLdisplaydb{myDB} to print it as a table. This table is very wide so I used the geometry package to extend the width of ...

10

The problem lies with the trailing spaces in your CSV currency values. Because of them, the numbers are treated as strings and the internal conversion from currency to decimal that takes place fails. So with the following CSV: a,"$100,090.06","$107,578.03",0.129565278 b,"$267,697.13","$72,463.54",0.087442318 c,"$761,314.81","$192,210.83",0.231820008 some ...

10

TeX's registers can be addressed either by name or by number. To keep a track of the numbers allocated to names, it is necessary to have an allocation routine, which \newcount provides an interface for. Thus when you do \newcount\foo you define \foo to mean \count<number>, and mark <number> as 'taken'. If you subsequently do ...

9

Joseph has explained the reason why the problem arises. Here's a possible workaround. I define a set of macros that set up two pools of token registers and count registers, from which to choose new ones when \DTLdbnewdb is called and that are reinserted in the pool when \DTLdeletedb is issued. One can increase the size of the pool, with the following macros ...

9

\DTLforeach visits the rows one after another. Therefore the row order of the data base matters: \DTLforeach*[\DTLisSubString{#2}{\RowID}]{#1}{% % #2 = list of rowIDs In the following solution I have put the data extraction in a for loop that iterates over the given row IDs. There are many for loops, e.g. LaTeX's \@for. I am using \comma@parse from ...

9

(La)TeX tabulars do not require a predefined number for the rows. For the columns, however, this is required in the general setup. You can combine column specifications that are similar though using a *{<num>}{<col spec>} specification. This would repeat <col spec> a total of <num> times. Therefore, defining \begin{tabular}{ | ...

9

When using \DTLforeach with \hline it's generally better to use the following schematic structure which puts the \\ and the \hline at the beginning of each non-initial row instead of at the end of each row. \DTLforeach{<database>}{<assignments>}{% \DTLiffirstrow{}{\\\hline} rest of table with no final \\ } For your second problem, there may ...

8

There's no problem to do this with the datatool package and siunitx as well. Here's your example done in that way: \documentclass{article} \usepackage{datatool} \usepackage{siunitx} \usepackage{booktabs} % for nicer tables \usepackage{caption} % improve caption spacing (among other things) \usepackage{bm} \renewcommand*\dtldisplaystarttab{\toprule} ...

8

I've just uploaded v2.13 to CTAN. It will probably take a day or so to propagate through the mirrors and distros, but once it's available you can use the code below. The best solution is to only define the database once (before the loop) and clear it each time round the loop. This means that you're not constantly allocating new registers. The new version ...

8

When using the babel package with the french option, semicolons (and colons, exclamation marks and question marks) are made active so the spacing around these punctuation symbols can be corrected for the French style of putting space before and after the symbol: "Normal" spacing: French spacing: If you use the semicolon as the field separator in your ...

8

The example below defines some commands that allow you to add entries to multiple databases. You can then use the example command \xgls instead of \gls and it will index the entries for each of the databases. So if pdf is in the glossary, acronym and index database, \xgls{pdf} will add a location to each database, whereas if html is only in the acronym and ...

7

datatool already loads fp which provides \FPround{<out>}{<in>}{<num>}, rounding <in> to <num> decimal places and stores it in <out>. datatool mirrors this with \DTLround (and/or \DTLtrunc if you wish to truncate rather than round): \documentclass{article} \usepackage{datatool,filecontents}% ...

7

\csname is a useful construct for defining a "dynamic" macro name based on some input, but when you're using the same basic structure in different places, you have to make sure the constructed macro names really match up. For instance, comparing this \expandafter\gdef\csname\Dir Color\endcsname{\ExpandedDirColor}% with that ...

7

Here's a possible solution: \documentclass{article} \usepackage{eso-pic} \usepackage{fancyhdr} \usepackage{blindtext} % just for the example \usepackage[headsep=3cm,top=5cm]{geometry} \usepackage{datatool} % create sample csv file \begin{filecontents*}{test.csv} Id,myauthor,mydate,myaddress 1,Sebastian,12.12.2012,XYZ road,XYZ city 2,Rose,12.12.2013,XYZ ...

7

You can first of all use a macro to hold the name of the .csv file in abc.tex: \documentclass{article} \usepackage{datatool} \begin{document} ... \DTLloaddb[noheader,keys={Temperature,Time,T2G}]{data}{\csvname.csv} ... \end{document} Then you can call xelatex from the command line by saying xelatex -jobname=abc-pqr '\def\csvname{pqr}\input{abc}' ...

7

You can set the starting angle of the first segment by the setting start=90. The value is 0 by default. \DTLpiechart{variable=\quantity,outerlabel=\name,start=90,radius=1.8cm,outerratio=1.1}{institute}{% \name=Name,\quantity=Quantity} I have made some other changes too in the settings so that the chart looks more good. \documentclass{beamer} ...

7

Maybe you want to give LuaLaTeX a try. It's very easy to write a script to read external files and format LaTeX commands. It is good practice to write the lua functions in a separate file with the extension .lua. For this MWE I use the filecontents environment instead to provide an extra file for the lua script and the datafile. Here is an other example for ...

7

Not sure about the datatool usage, but if you just want to process a comma separated list I think that package is a lot more powerful than you need. The following plain TeX produces \$ tex ll5 This is TeX, Version 3.1415926 (Web2C 2010) (./ll5.tex [ABC, DEF, ABC, MMM, MMM, JHM] -> [ABC,DEF,MMM,JHM] [ABC] -> [ABC] [] -> [] [xx, yyy, xx, yyy, sss] ...

6

The \foreach loops execute their code in a group for each step, so they are useless when something must be changed "globally", as is the case for your databases. Here's a way using the patch proposed by Werner; but I used a different command to patch, in order not to change the functionality of \DTLgetlocation: \documentclass{article} ...

6

the problem is the etextools package, that contains many names that can easily lead to clashes, like discussed here: Re: The package 'etextools' is not compatible with biblatex

6

\documentclass{article} \usepackage{datatool} \usepackage{filecontents} \begin{filecontents*}{\jobname.csv} 1,a 2,a 2,a 2,a 3,a 3,a 4,a 4,a 4,a 4,a 5,a 5,a 6,a 6,a 7,a \end{filecontents*} \DTLloaddb[noheader,keys={num}]{raw}{\jobname.csv} \DTLnewdb{hist} \newcounter{numcnt} % fill table "hist" \newcommand*{\SaveRow}{% \ifnum\value{numcnt}>0 % ...

6

Place the \caption{abc} command in the heading ended by \endfirsthead and use a \caption[]{...} in the repeated heading. the [] form suppresses the writing to the toc file. (See the longtable documentation). As @lockstep noted datatool hides this longtable feature, so you need to unhide it:-) \begin{filecontents*}{dt4.csv} 40,120,40 40,90,60 35,180,20 ...

6

Here's a way with expl3 and Heiko Oberdiek's catchfile: \documentclass{article} \usepackage[T1]{fontenc} % for the underscore \usepackage{catchfile} \usepackage{xparse} \ExplSyntaxOn \cs_set_eq:NN \egreg_catchfiledef:nnn \CatchFileDef \cs_generate_variant:Nn \egreg_catchfiledef:nnn { c } \cs_generate_variant:Nn \seq_set_split:Nnn { Nnv } ...

6

Both datatool and pgfplotstable can do similar things, but datatool is designed as a more general tool and therefore can in principle do more things (e.g. form letters and the like). So if your requirements are simply pretty printing tables directly from CSV files I might prefer pgfplotstables since it is especially designed for that, and if you are ...

6

You can get the \"a version by redefining \IeC: \documentclass{article} \usepackage[utf8]{inputenc} \usepackage{datatool} \begin{document} \DTLnewdb{table} \DTLnewrow{table} \DTLnewdbentry{table}{name}{aouäöü} \DTLdisplaydb{table} \def\IeC#1{#1} \DTLsavedb{table}{export.csv} \end{document} For real UTF8 you could try something like this: Complete (!) ...

6

\documentclass[a4paper]{article} \usepackage{datatool} \begin{document} \DTLsetseparator{;} \DTLloaddb[noheader,keys={id,item}]{test_db}{test.csv} \begin{table}[htbp] \count2=\DTLrowcount{test_db} \count4 = \count2 \divide\count4 by 2 \count2=\count4 \advance\count2 by 1 \caption{Two database rows per tabular row} \centering ...

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