5

When typesetting linguistic examples with transcriptions of the Arabic letters hamza and ayn, ʾ and ʿ respectively, the alignment with the literal translation on the line below looks awkward. See example (1). This also goes for lists and tabular environments. The alignment in Table 1 is not nice.

A way to remedy this is to use \llap{ʾ} to push this character to the left and making the word align with the second character. This gives the much better looking (in my opinion) example (2) and Table 2.

Now to my question. Is there a way to automate this? I want two character, ʾ and ʿ to become \llap{ʾ} and \llap{ʿ} when preceded by a space (and if possible also by the tab character) in certain environments, primarily example. This solution would work for tables by adding a space before the items, as in the code fore Table 1. I figure it would be possible to activate these characters. (As far as I understand is possible to activate Unicode characters in XeLaTeX, which is what I am using.) I know about \@ifnextchar, but what would be needed here is something like \@ifprevchar.

EDIT: I need a solution in which I can put individual words in the example transcription in environments, e.g. \textbf{}.

\documentclass{article}
\usepackage{fontspec}
%\usepackage[utf8]{inputenc}
\usepackage{array}

\usepackage{covington}


\begin{document}


\begin{example}
\gll bi-lātīk ʾanā ʾaktub ʾaḥla nuṣūṣ
with-latex I write prittyest texts
\glt `With \LaTeX{} I can write the prettiest texts.'
\glend
\end{example}

\begin{example}
\gll bi-lātīk \llap{ʾ}anā \llap{ʾ}aktub \llap{ʾ}aḥla nuṣūṣ
with-latex I write prittyest texts
\glt `With \LaTeX{} I can write the prettiest texts.'
\glend
\end{example}

\begin{table}[h!]
\centering
\caption{Ugly alignment}
\begin{tabular}{>{\itshape}ll}
 ʾanna & comp.\\
 ʾinna & `verily'\\
 lākinna & `but'\\
 laʿalla & `perhaps'\\
 layta & `if only'\\
\end{tabular}
\end{table}


\begin{table}[h!]
\centering
\caption{Nice alignment}
\begin{tabular}{>{\itshape}ll}
\llap{ʾ}anna & comp.\\
\llap{ʾ}inna & `verily'\\
lākinna & `but'\\
laʿalla & `perhaps'\\
layta & `if only'\\
\end{tabular}
\end{table}

\end{document}

enter image description here

0
3

Not easy, but doable, at least for tabular and example or examples. Note how you should specify the font change in the column table.

\documentclass{article}
\usepackage{fontspec}

\usepackage{etoolbox,array,collcell}

\usepackage{covington}

\makeatletter
\newrobustcmd{\checkforstart}{%
  \@ifnextchar ʾ{\llap}{\checkforayn}%
}
\newcommand{\checkforayn}{%
  \@ifnextchar ʿ{\llap}{}%
}
\makeatother

\newcolumntype{H}[1]{>{#1\collectcell\docheckforstart}l<{\endcollectcell}}
\newcommand{\docheckforstart}[1]{\checkforstart #1}


\begin{document}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%%% For technical reasons this can't go in the preamble, sorry
\catcode`\^^M=12
\patchcmd{\getwords}{\strut}{\strut\checkforstart}{}{}%
\catcode`\^^M=5
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\begin{example}
\gll bi-lātīk ʾanā ʾaktub ʾaḥla nuṣūṣ ʿTEST
with-latex I write prittyest texts TEST
\glt `With \LaTeX{} I can write the prettiest texts.'
\glend
\end{example}

\begin{example}
\gll bi-lātīk \llap{ʾ}anā \llap{ʾ}aktub \llap{ʾ}aḥla nuṣūṣ ʿTEST
with-latex I write prittyest texts TEST
\glt `With \LaTeX{} I can write the prettiest texts.'
\glend
\end{example}

\begin{tabular}{H{\itshape} l}
ʾanna & comp.\\
ʾinna & `verily'\\
lākinna & `but'\\
laʿalla & `perhaps'\\
layta & `if only'\\
\end{tabular}

\end{document}

enter image description here

6
  • Nice. However it doesn't work when I have made individual words in the example transcriptions bold. I suppose the \textbf then takes the first position in the \checkforstart command. Is it possible to get around this?
    – Andreas
    May 10 '14 at 9:05
  • Also, could you briefly explain what the commands in the solution and say which of the packages the commands are from?
    – Andreas
    May 10 '14 at 9:07
  • @Andreas Sorry, but this can work only if the words in the transcription are “naked”.
    – egreg
    May 10 '14 at 9:14
  • Hmm, guess I have to edit them manually.
    – Andreas
    May 10 '14 at 10:31
  • @Andreas Unfortunately there is no \@ifprevchar; it's possible to hook into \getwords, but doing it for all situations would be really time consuming and risky. Better to define a shortcut, say \? to do the \llap.
    – egreg
    May 10 '14 at 15:12

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.