4

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?

  • Welcome to TeX.Stackexchange! Your example compiles fine for me with an up-to-date texlive2018. Can you try to update to the current version? – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:07
  • 1
    Please don't ask multiple question in the same question. Maybe it would be better to move your questions about grids and stuff to a separate question. – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:08
  • @samcarter Strange. This fails for me with TL2018 with the same error. And there was a change datatool using that macro between TL2017 and TL2018. – Alan Munn Oct 31 '18 at 15:17
  • @AlanMunn Which operating system do you have? – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:19
  • @samcarter I'm using a Mac. (Same as you, I think?) – Alan Munn Oct 31 '18 at 15:34
  • @AlanMunn Yes, that is very strange! – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:35
  • @AlanMunn I was too lazy to create .csv file myself, so I used filecontents to 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
  • @samcarter Are you sure you get no errors? If I push through the errors I get output. – Alan Munn Oct 31 '18 at 15:40
  • @AlanMunn I just checked my log file again, no errors (https://gist.github.com/samcarter/f6a6bcb0a60a72242564489a57fc8dae) – samcarter_is_at_topanswers.xyz Oct 31 '18 at 15:41
  • @samcarter Wierd, I just made a copy of the .csv file 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
  • @AlanMunn Maybe this are strange Halloween effects everything works fine tomorrow? – samcarter_is_at_topanswers.xyz Oct 31 '18 at 16:54
  • No error for me. – egreg Oct 31 '18 at 18:37
  • As far as I am aware, I have the latest version. I installed Tex Live 2018 from the DVD yesterday. And as I mentioned, the same code works for me in Tex Live 2017 so it's not an issue with the code itself (or the CSV). –  Oct 31 '18 at 21:37
  • 1
    @MilesO'Brien Can you check if https://gist.github.com/samcarter/04f867916fc62d6f11673d4155cd638c works for you (preferably in a new folder)? – samcarter_is_at_topanswers.xyz Oct 31 '18 at 22:15
  • 1
    \DTLsettabseparator works fine for me. Your use of \DTLsetseparator with 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 .tex and .csv files 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
  • @samcarter That works. I see that it generates a CSV. Is there a way to read from an existing CSV? –  Nov 03 '18 at 13:35
  • @Nicola Talbot Thank you for the information about the "tab" character, but the CSV I am using works in Tex Live 2017, so I don't think that there's been any silent conversion. –  Nov 03 '18 at 13:38
  • @MilesO'Brien From the discussion with AlanMunn I suspect that the problem is the encoding of the file. If the existing cvs file has the correct encoding it should also work. – samcarter_is_at_topanswers.xyz Nov 03 '18 at 13:39
  • In that case, I simply don't understand it. The CSV was created with Libre Office and saved at UTF-8 with TAB as the delimiter, just at the original example. Does Windows handle this differently from Linux? –  Nov 03 '18 at 13:48
  • @Nicola Talbot Changing \DTLsetseparator to \DTLsettabseparator works for me in TL 2018 and proves that there is nothing wrong with the format of my spreadsheet. Apologies! For some reason, I was so focused on the second half of your post that I didn't think to try the first. I am grateful to everyone who helped. –  Nov 04 '18 at 17:02
  • @AlanMunn Your answer that you deleted does actually seem to be the correct answer. – Nicola Talbot Nov 04 '18 at 17:23
  • @NicolaTalbot I've undeleted my answer now. – Alan Munn Nov 05 '18 at 18:18

1 Answers1

1

Try the following changes to the document.

Comment out the following line:

\DTLsetseparator{   }% literal tab; with UTF8 source, \DTLsettabseparator% doesn't work

And replace it with:

\DTLsettabseparator % add this line

Then after you load the CSV file, add the following line:

\DTLmaketabspace % immediately after loading  add this line

So the complete loading lines should now read:

\DTLsettabseparator % add this line
\DTLloaddb{text}{Chapter2.csv} % load file
\DTLmaketabspace % immediately after loading  add this line
Alan Munn
  • 218,180