I am trying to modify this specific solution to interlinear texts, which I found here.
% !TEX TS-program = XeLaTeX
\documentclass[11pt]{book}
\usepackage[margin=1in]{geometry}
\usepackage{titlesec}
\usepackage{polyglossia}
\defaultfontfeatures{Ligatures=TeX}
\setmainlanguage{brazil}
\setotherlanguage[variant=ancient]{greek}
\setmainfont{Linux Libertine O}
\usepackage{datatool}
\usepackage{expex}
% Format chapter and verse (\section) headings
\titleformat{\chapter}[display]
{\normalfont\filcenter}
{\LARGE\MakeUppercase{\chaptertitlename} \thechapter}
{1pc}
{\vspace{1pc}%
\LARGE}
\titlespacing{\chapter}
{0pt}{0pt}{10pt}
\titleformat{\section}[leftmargin]
{\normalfont
\vspace{0pt}%
\bfseries\Large\filleft}
{\thesection}{.5em}{}
\titlespacing{\section}
{4pc}{1.5ex plus .1ex minus .2ex}{0pt}
% format section label
\renewcommand{\thesection}{\arabic{chapter}:\arabic{section}}
% multiple gloss lines will align on the left margin
\lingset{glhangstyle=none}
% initialize some token registers to build up the lines from the database cells
\newtoks\glosslineA
\newtoks\glosslineB
\newtoks\glosslineC
% create a command to append a cell to the token register
% Thanks to Enrico Gregorio for this code
\long\def\Append#1#2{#1=\expandafter{%
\the\expandafter\expandafter\expandafter#1\expandafter\space #2}}
% Define a command to empty the token registers
\def\emptytoks{\glosslineA{}\glosslineB{}\glosslineC{}}
% Define a command used to escape * in the input cell
\def\esc#1{#1} %
\def\SecTest{section} % verse delimiter check
\begin{document}
\DTLsetseparator{ }% literal tab; with UTF8 source, \DTLsettabseparator doesn't work
\DTLloaddb{text}{Chapter2.csv}
\setcounter{chapter}{1}
\chapter{O sonhou do Nabucodonsor}
\DTLforeach{text}
{% assign each cell in a row to a macro
\Codes=Number,
\GreekText=Greek,
\PortugueseText=Portuguese%
}
{% If we're in the first row, start a section; otherwise if we find a section, output
% the previous section's lines, and start a new section, then empty the token registers
\DTLiffirstrow{\section{}}{
\DTLifeq{\Codes}{\SecTest}{
\begingl
\expandafter\gla\the\glosslineA//
\expandafter\glb\the\glosslineB//
\expandafter\glc\the\glosslineC//
\endgl
\section{}
\emptytoks
}
{% For each cell, append it to the token register for that line
\Append\glosslineA{\Codes}%
\Append\glosslineB{\GreekText}%
\Append\glosslineC{\PortugueseText}%
}}}
% output the last section's lines.
\begingl
\expandafter\gla\the\glosslineA//
\expandafter\glb\the\glosslineB//
\expandafter\glc\the\glosslineC//
\endgl
\end{document}
First, I need to make it work on Windows with Tex Live 2018, which I installed from the DVD. When I try to run it in Texmaker, an error message appears.
\dtlcols@text=\count308
! Argument of \@dtl@lopoff has an extra }.
But I know that this is a red herring, because the exact same code works perfectly with Tex Live 2017 under Linux. I think that the problem is that the CSV is not being read for some reason. (I'm using the same CSV that was posted in that thread.) Has there been a change in the behavior of one of the packages from 2017 to 2018?
datatoolusing that macro between TL2017 and TL2018. – Alan Munn Oct 31 '18 at 15:17filecontentsto create it. Maybe some problem with encoding of the .csv file? (This works for me: https://gist.github.com/samcarter/04f867916fc62d6f11673d4155cd638c with TL18, updated this morning) – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:39.csvfile from the original answer and the file now compiles without error. But my original test files don't work with TL 2018 although they do with TL 2017. – Alan Munn Oct 31 '18 at 16:42\DTLsettabseparatorworks fine for me. Your use of\DTLsetseparatorwith a literal tab as the argument will set the separator to a space because that's how (La)TeX usually interprets the TAB character. You'd need to change the catcode of TAB first in order to use TAB in\DTLsetseparator(as in @AlanMunn's deleted answer). It also might be worth checking both the.texand.csvfiles in an editor that has an option to show visible spaces to make sure that any copying&pasting or downloading hasn't performed a silent conversion of TAB. – Nicola Talbot Nov 01 '18 at 10:07