12

How to do interlinear text like below?

Especially, number over the word is centered in relation to this word. I tried with hbox and centering command but not works.

\def\wrd#1#2{$\vcenter{\hbox{\valign{&\hbox{\centering##}&\hbox{\strut##}\cr#1&#2\cr}}}$}
9

You need \vbox and \halign, not \valign:

\documentclass{article}

\newcommand\wrd[2]{%
  \leavevmode
  \vbox{\offinterlineskip
    \halign{%
      \hfil##\hfil\cr
      {\footnotesize\sffamily\vphantom{p}#1}\cr
      \noalign{\vskip\lineskip}%
      \vphantom{A}#2\cr
    }%
  }%
}

\begin{document}

\linespread{1.8}\selectfont


\wrd{9176}{Longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}

\end{document}

enter image description here

  • What is this part \hfil##\hfil? Is it causing the centering or is it the \halign? – azetina Jan 20 '15 at 23:20
  • 1
    @azetina It's the template: the # stands for the cell's content, which is so centered in the available width. We have to use ## because it's inside a definition. – egreg Jan 20 '15 at 23:25
  • I understand the # and ## signs need but what is causing the centering? Is it the \hfil? So is \hfil##\hfil only being applied to the numbers? – azetina Jan 20 '15 at 23:30
  • @azetina No, it's applied to all the column (and there's only one). – egreg Jan 20 '15 at 23:35
10

The expex package is designed for creating interlinear linguistics examples, and it is easily adapted for texts of this type.

In order to center the number above the word (or group of words), use the expex option glwordalign=center.

% !TEX TS-program = XeLaTeX

\documentclass{article}

\usepackage{fontspec}
\setmainfont{Palatino Linotype}
\setsansfont{Arial}
\newfontfamily\versefont{Tahoma}

\usepackage{expex}
\lingset{everygla=\footnotesize\sffamily, % formatting the numbers in the gla line
    glwordalign=center, % center alignment within glwords
    aboveglbskip=-0.4ex, % narrows the vertical gap between the gla and glb lines
    glhangstyle=none, % no hanging indent
    glspace=!0pt plus .2em, % widens the allowable space between glwords to avoid overfull lines
    glrightskip=0pt plus .5\hsize} % widens the allowable space between the right margin and the end of the last glword on a line to avoid overfull lines

\newcommand{\vs}[1]{{\bfseries\versefont #1}}

\begin{document}
\exdisplay
\begingl
\gla 976 {} 1078 2424 5547 5207 1138 5207 11 {} 11 1080 o2464 1161 2464 1080 o2384 1161 2384 1080 o2455 2532 o80 846 {} 1161 2455 1080 o5329 2532 o2196 1537 o2283 1161 5329 1080 o2074 1161 2074 1080 o689 {} 1161//
\glb \underline{Zwój księgi} (o) narodzinach Jezusa Chrystusa, syna Dawida, syna Abrahama. \vs{2} Abraham zrodził Izaaka, a Izaak zrodził Jakuba, a Jakub zrodził Judę, i braci jego, \vs{3} a Juda zrodził Faresa i Zarę z Tamary, a Fares zrodził Esroma, a Esrom zrodził Arama, \vs{4} a//
\endgl
\xe
\end{document}

enter image description here

My example above needs to be compiled with XeLaTeX or LuaLaTeX, but this is just because of the way I selected fonts using fontspec and used Unicode input for the Polish. If you choose fonts and enter the Polish differently you can use pdfLaTeX.

See Alan Munn's answer to Doing an interlinear text if you are interested in importing the numbers from an external concordance file.

I wasn't able to get the lettrine package (for the drop-cap chapter number) to play nicely with expex line breaking; you could ask about this in a separate question if it is important to you.

6

A layman's aapproach with tabular

\documentclass{article}

\newcommand\wrd[2]{%
  \renewcommand\arraystretch{0.4}
  \begin{tabular}[t]{@{}c@{}}
   \footnotesize\textsf{#1}\\%
      #2
   \end{tabular}
}

\begin{document}

\linespread{1.8}\selectfont


\wrd{9176}{Longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}
\wrd{9176}{longword} \wrd{12345}{a} \wrd{o12}{end}

\end{document}

enter image description here

  • This shows that most functionality of TeX-core is available in the LaTeX2e layer. However, your a's are "jumping" ... – yo' Jan 21 '15 at 9:11
  • @yo' Yes, good spotted. That is why the teacher added \vphantoms in his answer. ;) – user11232 Jan 21 '15 at 12:11
6

Alternatively using the stackengine package:

enter image description here

\documentclass{article}
\usepackage{stackengine}
\newcommand\wrd[2]{%
  \stackengine{0.2ex}{\vphantom{A}#1}{{\footnotesize\sffamily\vphantom{p}#2}}{O}{c}{F}{T}{S}%
}

\begin{document}

\wrd{hello}{12} world

\end{document}

See the stackengine manual, pg 6, for more information. Here is a snapshot of the interpretation of the above.

enter image description here

  • I would set \useanchorwidth to F, or else \wrd{a}{1161} will bump into adjacent text. – Steven B. Segletes Jan 21 '15 at 1:46
  • 1
    You could eliminate the \vphantoms if you chose a Long stacktype and set the gap accordingly. – Steven B. Segletes Jan 21 '15 at 1:48
3

Using stacks. Oops. I see azetina beat me to it. My MWE is a bit more elaborative, but give him the vote.

\documentclass[12pt]{article}
\usepackage{stackengine}
\usepackage{palatino,setspace}
\newcommand\wrd[2]{\def\stacktype{L}\stackon[10pt]{#1}{\scriptsize\sffamily#2}}
\newcommand\verseno[1]{\bgroup\bfseries\sffamily#1\egroup}
\begin{document}
\doublespacing
\verseno{1} \wrd{\underline{Zwoj ksiegi}}{976} (o) \wrd{narodzinach}{1078} \wrd{Jesuza}{2424}
\wrd{Chrystusa}{5547}, \wrd{syna}{5207} \wrd{Dawida}{1138}, \wrd{syna}{5207}
\wrd{Abrahama}{11}. \verseno{2} \wrd{Abraham}{11} \wrd{zrodzil}{1080}
\wrd{Izaaka}{o2462}, \wrd{a}{1161} \wrd{Izaak}{2464} \wrd{zrodzil}{1080}
\end{document}

enter image description here

  • Lets just stick to your one. I mean you are the author :) – azetina Jan 21 '15 at 4:05
1

One simple approach could be use an inline math environment using \overset, but may be you can be also interested in the source of the dvgloss package. The format is not the required in this case (upper line is not centered with sans serif} but because he simpler sintaxis of \gl macro and some other feature worth take a look to source code of the package . Example:

MWE

\documentclass[a5paper]{article}
\usepackage{amsmath}
\usepackage{dvgloss}
\usepackage{lettrine}

\def\verseno#1{{\bfseries\sffamily#1}}
\def\wrd#1#2{\ensuremath{\overset{\mathsf{#2}}{\textrm{\vphantom{I}#1}}}}
\begin{document}


Using \verb|\overset| from \verb|amsmath|:\\[1em]


\lettrine[lines=2,lraise=.4,findent=1em]{\verseno{1}}{} 
\wrd{\underline{Zwoj ksiegi}}{976} (o) \wrd{narodzinach}{1078} \wrd{Jesuza}{2424} \wrd{Chrystusa}{5547}, \wrd{syna}{5207} \wrd{Dawida}{1138}, \wrd{syna}{5207} \wrd{Abrahama}{11}. 
\verseno{\Large 2} \wrd{Abraham}{11} \wrd{zrodzil}{1080} \wrd{Izaaka}{o2462}, \wrd{a}{1161} \wrd{Izaak}{2464} \wrd{zrodzil}{1080}

\bigskip

With \verb|dvgloss|:\\[1em]

\lettrine[lines=2,lraise=0,findent=1em]{\verseno{1}}{} 
\gl{976  {~} 1078 * 2424 5547 * 5207 1138 5207 11 22 33 44}{{\underline{Zwoj ksiegi}} (o) narodzinach Jesuza Chrystusa, syna Dawida, syna Abrahama.}%
%
\verseno{\raisebox{-1.5ex}{\large 2}}  \gl{11 1080 o2462 1161 2464 1080}{Abraham zrodzil Izaaka, a Izaak zrodzil} 

\end{document}

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.