jspitz / covington

Maintenance of the covington LaTeX package
9 stars 0 forks source link

Non latin text alignment: Keep glosslineone as it as and change just line two alignment #8

Closed guimaluf closed 4 years ago

guimaluf commented 4 years ago

Hi,

I'm writing more in a request for help and guidance then to enhancemente or improvement. I have written latex text for a while but never risked myself on styles and packages.

I'm studying Tibetan language and I would like to create some latex templates for its traditional texts, called pechas. I'd struggled for a while on finding out how tu put word-by-word vertical translation. I discovered glossing and through your package I would like to modify for my needs.

I would like to keep the Tibetan text as it is and adjust the space only for the word-by-word translation. Something like this

image

There are 3 lines:

  1. Tibetan text
  2. word-by-word translation
  3. phonetics transliteration

I'm trying to achieve a latex template where I can do 1 and 2 together. I really believe your glossing code is a starting point for me. If you could point me if that is possible and maybe give me some idea on what to do I would be quite happy :)

Another issue, is that Tibetan doesn't use space as word separator, instead they use tseg(་). In order to make you package work I've set tseg as an space character, but when using gloss the tseg char disappear.

% Define tseg as a space
\catcode`\་=10

image

Thank very much for all your effort

jspitz commented 4 years ago

Could you send me an example file alongside with your attempts to implement it?

guimaluf commented 4 years ago

Thank you very much for your help.

All I'm doing its here in the repo/branch: https://github.com/guimaluf/tibetan-pecha/tree/glossing

The file I'm working with: https://github.com/guimaluf/tibetan-pecha/blob/glossing/tsigdun-soldeb-naldjor/tsigdun-soldeb-naldjor.tex

You may have to install the Jomolhari font.

I haven't changed nothing in convington yet, I would like to try using default settings if possible. I'm reading its source code, but I'm n00b at tex coding.

Thanks once again :)

jspitz commented 4 years ago

This works for me. You have to undo the tseg catcode change.

% New gloss line parser that segments at tsegs rather than spaces
\gdef\xgettsegwords(#1,#2)#3་#4\xgle% #1=linebox, #2=\each, #3=1st word, #4=remainder
   {\def\more{#4}%
    \setbox#1=\vbox{\hbox{#2\strut#3\ifx\more\empty\else་\fi}% adds tseg
        \unvbox#1%
    }%
    \ifx\more\empty\let\more=\xdonewords%
    \else\let\more=\xgettsegwords%
    \fi%
    \more(#1,#2)#4\xgle%
}

% allow zero space between words
\glossglue = 0pt plus 2pt minus 1pt

% redefine gloss parsers used by \digloss and \trigloss to use tseg parser in first line
\makeatletter
\gdef\xtwosent#1\xgle#2\xgle% #1 = first line, #2 = second line
   {\xgettsegwords(\lineone,\eachwordone)#1་\xgle%
    \xgetwords(\linetwo,\eachwordtwo)#2 \xgle%
    \ifx\cov@glp\empty\else\glosslinepreamble{\cov@glp}\cov@nopagebreak\newline\fi%
    \loop\lastword{\eachwordone}{\lineone}{\wordone}%
         \lastword{\eachwordtwo}{\linetwo}{\wordtwo}%
         \global\setbox\gline=\hbox{\unhbox\gline%
                                    \hskip\glossglue%
                                    \vtop{% vtop was vbox
                                          \box\wordone%
                                          \nointerlineskip%
                                          \box\wordtwo%
                                         }%
                                   }%
         \testdone%
         \ifnotdone%
    \repeat%
    \egroup% matches \bgroup in \gloss
}

\gdef\xthreesent#1\xgle#2\xgle#3\xgle% #1 = first line, #2 = second line, #3 = third
{\xgettsegwords(\lineone,\eachwordone)#1་\xgle%
    \xgetwords(\linetwo,\eachwordtwo)#2 \xgle%
    \xgetwords(\linethree,\eachwordthree)#3 \xgle%
    \ifx\cov@glp\empty\else\glosslinepreamble{\cov@glp}\cov@nopagebreak\newline\fi%
    \loop\lastword{\eachwordone}{\lineone}{\wordone}%
    \lastword{\eachwordtwo}{\linetwo}{\wordtwo}%
    \lastword{\eachwordthree}{\linethree}{\wordthree}%
    \global\setbox\gline=\hbox{\unhbox\gline
        \hskip\glossglue
        \vtop{% vtop was vbox
            \box\wordone
            \nointerlineskip
            \box\wordtwo
            \nointerlineskip
            \box\wordthree
        }%
    }%
    \testdone
    \ifnotdone
    \repeat
    \egroup % matches \bgroup in \gloss
}

\makeatother

Note that this assumes that each gloss has Tibetan (or tseg-separated words, for that matter) in the first line.

Here is you common.tex file with this change (the .txt suffix is only to make github accept the upload) common.tex.txt

jspitz commented 4 years ago

Closing (not a covington bug).