# pdfs with datas from a special column in a table based database (like excel) + pictures

I am quite new in tex, but now I have to:

• compile several pdfs with the same layout (not so important if separated physically in different files or just as pages in one file)
• from 1 column of datas of a table based data base (at the moment an excel sheet with there column: English + German, containing definitions, + picture) (the datas are filled in by somebody else and changing every so and so months)
• and connected with a picture (of what is explained in the text, so both columns with the same picture in the third column)

searching through the questions here I found several solutions working with .csv files, photon and luatex (like: Import data from a spreadsheet into latex and create multiple pdf files for each row in LaTeX ) - all stuff I never heard about ;) but I am willing to lern. And I will work me through those as necessary. The problem is, that I don't now where to start. And furthermore I have the feeling, that the picture will be a problem, as pictures aren't included in the cells in excel, so they won't be read in any way. So probably I have to use a completely different tool for the table at first place. And then there would be a totally different way anyway.

So my questions:

1. which program should be used to generate the table (someone else will do that, so it shouldn't be to complicated or expensive for them, if possible, something easy and common as excel would be great)
2. and then of course how to start bringing it into latex - you don't need to give me an already given answer again, I am willing to read through the already existing questions and answers here, but there are so many and with my limited knowledge about it all it would be great to get a hint which of the given answers to try.
3. and to change the layout of the final pdf in the .tex file should still be possible, but I guess that would work with every solution.

here a sketch how one of the pdfs could look like at the end: example table:

I hope I could make my problems clear. thanks a lot for your help!

## 2 Answers

found a solution using the datatool package. It isn't perfect yet, but probably you have some ideas for improvement?

I have all the pictures in a folder and use

ls /b *.jpeg >pix.csv


to generate a .csv of all the pictures. (working on a Mac)

Then I load that and the column I want to use (before saved as .csv) into my .tex and merge them.

At last I run a tikzpicture for each row to generate the single cards.

\documentclass{standalone}

\usepackage{graphicx}
\usepackage{tikz}
\usepackage{datatool}

\DTLloaddb[
noheader,
keys={name}
]{pix}{pix.csv}

\DTLloaddb[
noheader,
keys={title}
]{text}{text.csv}

\begin{document}

\newcount\rowIdx

\dtlforcolumn{\secondC}{text}{title}%\dtlforcolumn{?cs?}{?db?}{?key?}{?body?}
{
% iterate through each entry in the title' column of the text database
\advance\rowIdx by 1\relax
% get corresponding row of pix database
\dtlgetrow{pix}{\rowIdx}%
% append to current row (this new column is assigned the key title')
\dtlappendentrytocurrentrow{title}{\secondC}%\dtlappendentrytocurrentrow{?key?}{?value?}
% update first database
\dtlrecombine
}

\DTLforeach*%\DTLforeach*[?condition?]{?db name?}{?assign list?}{?text?}
[\not\DTLiseq{\Name}{main.tex}]
{pix}{\Name=name,\Title=title}{
\newpage
\begin{tikzpicture}[remember picture,overlay]

\node[anchor=south,inner sep=0pt] (icon) at (7.4,-8.5){\includegraphics[height=5cm]{\Name}}; %inserting the picture according to name

\node[inner sep=0,text width=\paperwidth,align=flush center] (text) at (7.4,-9){\Title};

\end{tikzpicture}
}

\end{document}


there are a few errors, in the line of the \end{tikzpicture} an \endgroup is missing and a } and then in the end it says there are to many } but I don't understand why? And if I write the \endgroup in my .tex it says it is too much. So it is working like this, as the missing parts are added automatically, but I always have to press enter to accept the changes. Probably one of you can help here.

thanks a lot!

• You appear to be asking some questions which you want help with in this answer. If this isn't a complete working answer then I'd suggest you should edit the question instead as this becomes an example of what you've tried rather than a solution, if this is a complete answer but has sparked some new questions then you should ask them separately by opening new question(s). – Dai Bowen Jul 18 '17 at 14:29
• thanks, I edited my answer regarding to your suggestions. I hope it is okay so now, as I don't want to add it to the already long question, especially as I am still open to other solutions. Further the answer is working, even if it isn't perfect yet. But I excluded the new question. – acep Jul 21 '17 at 8:37

the answer above works fine for only one language, but here now my solution for two languages (with subtitles), like asked in the question and a level option. The person making the table has to write in the last column the file name of the picture instead of putting the picture and then it works fine.

\documentclass[english]{article}

\usepackage[paperwidth=11cm, paperheight=10.4cm]{geometry}

\usepackage{graphicx}
\usepackage{tikz}
\graphicspath{{../pix/}}
\usepackage{datatool}
\usepackage{etoolbox}

\newbool{GER}
%\booltrue{GER} % if german version activate
\newcommand{\Levelgew}{1} % say which level (if you say level 2 it will print level1+2)

\DTLsetseparator{;}
\DTLloaddb[keys={level,eng,engunderline,ger,gerunderline,name}]{cards}{_scrumflowcards.csv} %\DTLloadrawdb[?options?]{?db name?}{?filename?}

\begin{document}
\ifbool{GER}
{
\DTLforeach*%\DTLforeach*[?condition?]{?db name?}{?assign list?}{?text?}
[\not\DTLisgt{\Level}{\Levelgew}]
{cards}{\Level=level,\Title=ger,\Underline=gerunderline,\Name=name}
{
\clearpage%start a new page for each row
\thispagestyle{empty}%get rid of the pagenumbers

\begin{tikzpicture}[remember picture,overlay]

\node[yshift=-2.2cm,anchor=south] (icon) at (current page.center) {\includegraphics[height=6cm]{\Name}};

\node[yshift=-3.5cm,text width=8cm,align=flush center] (text) at (current page.center){\huge\bfseries\sffamily\Title\\[15pt]
\LARGE \Underline};

\end{tikzpicture}
}

}{
\DTLforeach*%\DTLforeach*[?condition?]{?db name?}{?assign list?}{?text?}
[\not\DTLisgt{\Level}{\Levelgew}]
{cards}{\Level=level,\Title=eng,\Underline=engunderline,\Name=name}
{
\clearpage%start a new page for each row
\thispagestyle{empty}%get rid of the pagenumbers

\begin{tikzpicture}[remember picture,overlay]

\node[yshift=-2.2cm,anchor=south] (icon) at (current page.center) {\includegraphics[height=6cm]{\Name}};

\node[yshift=-3.5cm,text width=8cm,align=flush center] (text) at (current page.center){\huge\bfseries\sffamily\Title\\[15pt]
\LARGE \Underline};

\end{tikzpicture}
}
}
\end{document}


at the end I used the pgfpackage (\pgfpagesphysicalpageoptions and \pgfpageslogicalpageoptions) to print multiple of the cards/pages on one a4 paper/sheet.