I am trying to compile a bilingual dictionary from a spreadsheet file that was exported as csv. The file contains columns with the kinds of information that one would expect from a dictionary: lexeme, part of speech, gender, sense, example sentence, example translation. I am simplifying things here for a better explanation.
lexeme,partofspeech,gender,sense,example,extranslation
For my tex-file I used \newcommand to create an \entry command with six arguments. In this way, I can define the formatting (parentheses, italics, headers, etc.)
\newcommand{\entry}[6]{\markboth{#1}{#1}{\textbf{#1}}\ {\textcolor{blue}{(#2)}}\ {#3}\ $\bullet$\ {#4} \ {\textit{#5}} {#6}\vspace{0.2cm}\par}
In the document, I call \entry when importing the csv-file. I used the csvsimple package to import my csv-file. Following \csvreader: the {first argument} identifies the csv-file, the {second argument} defines my table headings, the {third argument} contains the \entry command that is applied to each line in the csv.
\csvreader{dictionary.csv}{lexeme=\lexeme,partofspeech=\partofspeech,gender=\gender,sense=\sense,example=\example,extranslation=\extranslation}{\entry{\lexeme}{\partofspeech}{\gender}{\sense}{\example}{\extranslation}}
All this works fine for a csv-file that looks like this:
lexeme,partofspeech,gender,sense,example,extranslation
lexeme-1,noun,feminine,translation-1,example-1,extranslation-1
lexeme-2,noun,masculine,translation-2,example-2,extranslation-2
However, there are lexemes/entries that contain more than one example sentence. And they looks like this:
lexeme,partofspeech,gender,sense,example,extranslation
lexeme-1,noun,feminine,translation-1,example-1a,extranslation-1a
,,,,example-1b,extranslation-1b
Moreover, there are lexemes/entries that have more than one sense. and they would look like this:
lexeme,partofspeech,gender,sense,example,extranslation
lexeme-1,noun,feminine,translation-1a,example-1a,extranslation-1a
,verb,,translation-1b,example-1b,translation-1b,
With the \csvreader settings (above), I get problems. As one would expect, I get a new entry for each new line, when I really to add just an example/translation that belongs to the lexemes/entry in previous line. This would be relevant for all lines in which the first value is empty (i.e. that to not have a lexeme). How can I do this?
EDIT: I was asked to provide a MWE
\documentclass[11pt,a4paper,twoside]{article}
\usepackage{fontspec}
\usepackage{csvsimple}
\usepackage{color}
\newcommand{\entry}[6]{\markboth{#1}{#1}{\textbf{#1}}\ {\textcolor{blue}{(#2)}}\ {#3}\ $\bullet$\ {#4} \ {\textit{#5}} {#6}\vspace{0.2cm}\par}
\begin{document}
\csvreader{dictionary.csv}{lexeme=\lexeme,partofspeech=\partofspeech,gender=\gender,sense=\sense,example=\example,extranslation=\extranslation}{\entry{\lexeme}{\partofspeech}{\gender}{\sense}{\example}{\extranslation}}
\end{document}
The csv-file look like this:
lexeme,partofspeech,gender,sense,example,extranslation
lexeme-1,noun,feminine,translation-1a,example-1a,extranslation-1a
,verb,,translation-1b,example-1b,translation-1b
lexeme-2,noun,feminine,translation-2,example-2a,extranslation-2a
,,,,example-2b,extranslation-2b
The pdf-output of the MWE contains four dictionary entries. What I want to achieve is that lines two and four from the csv-file are appended to the respective cells (i.e. in the same column) of the preceding line.
\ifx\relax#1\relax empty \else ... \fi
but what you can do in the empty case depends on how you have typeset the previous row and whether you can easily add this extra information, so a more complete example would help – David Carlisle Feb 4 '20 at 14:12\vspace{0.2cm}\par
(\vspace
before the par is wrong anyway) and then just add\par
at the start of the entry in the non-empty case, – David Carlisle Feb 4 '20 at 16:11