修改直行文本的具体示例并在 Tex Live 2018 上运行

修改直行文本的具体示例并在 Tex Live 2018 上运行

我正在尝试修改这个特定的解决方案以适应直行文本,我发现这里

% !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}

首先,我需要让它在 Windows 上使用 Tex Live 2018(我从 DVD 安装了它)。当我尝试在 Texmaker 中运行它时,出现了一条错误消息。

\dtlcols@text=\count308
! Argument of \@dtl@lopoff has an extra }.

但我知道这只是个幌子,因为完全相同的代码在 Linux 下与 Tex Live 2017 完美兼容。我认为问题是由于某种原因 CSV 没有被读取。(我使用的是与该线程中发布的相同的 CSV。)从 2017 年到 2018 年,其中一个软件包的行为是否发生了变化?

答案1

尝试对文档进行以下更改。

注释掉以下行:

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

并将其替换为:

\DTLsettabseparator % add this line

然后在加载 CSV 文件后添加以下行:

\DTLmaketabspace % immediately after loading  add this line

因此,完整的加载行现在应为:

\DTLsettabseparator % add this line
\DTLloaddb{text}{Chapter2.csv} % load file
\DTLmaketabspace % immediately after loading  add this line

相关内容