3

I am typesetting a text in the classics. A part of it consists of numbered verses. For each verse line I would like to show (1) a line number, (2) the verse text, and (3) an optional "clause".

As there are tens of thousands of these verses and most are rather short, I would like to set the document with two columns. Some verses are very long, so it is important to fill them like paragraphs. Finally, the line numbers that appear to the left of the verses should be set manually (they are generated by a script).

The following is the best I have come up with so far (note that the command "clause" is defined to ensure that the clauses appear on the right even after a line break):

\documentclass[9pt, DIV=22]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0cm}
\begin{document}
\twocolumn
\newcommand\clause[1]{{%
    \unskip\nobreak\hfil\penalty50
    \hskip2em\hbox{}\nobreak\hfil\textbf{#1}%
    \parfillskip=0pt \finalhyphendemerits=0 \par}}

\section{Traktate}
\subsection{Ad Demetrianum}
{\tiny 1} \textbf{1} Oblatrantem te

% Most verses are short.
{\tiny 2} et aduersus Deum

{\tiny 3} qui unus et uerus est
\clause{T2gdz}

{\tiny 4} ore sacrilego
\clause{Tg}

{\tiny 5} et uerbis impiis

{\tiny 6} obstrepentem frequenter,
\clause{Pg}

{\tiny 7} Demetriane,

{\tiny 8} contempseram

{\tiny 9} uerecundius et melius existimans

{\tiny 10} errantis inperitiam silentio spernere
\clause{T2d}

{\tiny 11} quam loquendo dementis insaniam prouocare.
\clause{V3d}

{\tiny 12} Nec hoc sine magisterii diuini auctoritate faciebam,
\clause{TT12g}

{\tiny 13} cum scriptum sit:

% Many verses span multiple lines, a few are very long.
{\tiny 14} In aures inprudentis noli quicquam dicere, ne quando audierit inrideat sensatos sermones tuos, [Prou. 23, 9]
\clause{bib}

\end{document}

I wonder: Is there a way to put the line numbers in a "column of their own"? This would mean that the numbers are right-aligned, and that the verse texts are set in a separate column to the right of the line numbers.

The obvious solution seems to be to use tables. Here the problem is that most table packages do not support \twocolumn or multicol and tables spanning multiple pages. I almost succeeded with the "tabu" package using a trick to make it work with multiple columns. But a problem that I have been unable to solve is that when using tables long verses are not split across pages. Since some verses take up half of a page this is not acceptable.

If there was a way to specify a prefix that will be prepended to each physical line after the text has been filled, the above example could be modified to fulfill all the requirements.

  • Welcome to TeX SE! Would something from here help? Unfortunately, however, most of the packages are designed to automate line numbering since that's presumably the more usual request... – cfr Jun 2 '14 at 1:10
2

this approach doesn't need any packages, but it does require reformatting of the input to use a command with three arguments, often with the third empty.

\documentclass[11pt]{book}

\newenvironment{versus}{%
  \begingroup
  \parindent0pt
  \leftskip2.5em\relax
  \rightskip1em plus.75\textwidth\relax
  \parfillskip0pt\relax
  \parskip2pt plus 1pt minus .5pt
}{%
  \par
  \endgroup  
}
\newcommand{\xverse}[3]{%
  \leavevmode
  \llap{\tiny #1\quad}\ignorespaces#2\unskip
  \penalty9999 \hbox{}\nobreak\hfill{\bfseries#3\unskip}\kern-1em\null
  \par
}

\begin{document}

\section{Traktate}
\subsection{Ad Demetrianum}

\begin{versus}
\xverse{1}{\textbf{1} Oblatrantem te}
{}

% Most verses are short.
\xverse{2}{et aduersus Deum}
{}

\xverse{3}{qui unus et uerus est}
{T2gdz}

\xverse{4}{ore sacrilego}
{Tg}

\xverse{5}{et uerbis impiis}
{}

\xverse{6}{obstrepentem frequenter,}
{Pg}

\xverse{7}{Demetriane,}
{}

\xverse{8}{contempseram}
{}

\xverse{9}{uerecundius et melius existimans}
{}

\xverse{10}{errantis inperitiam silentio spernere}
{T2d}

\xverse{11}{quam loquendo dementis insaniam prouocare.}
{V3d}

\xverse{12}{Nec hoc sine magisterii diuini auctoritate faciebam,}
{TT12g}

\xverse{13}{cum scriptum sit:}
{}

% Many verses span multiple lines, a few are very long.
\xverse{14}{In aures inprudentis noli quicquam dicere, ne quando audierit inrideat sensatos sermones tuos, [Prou. 23, 9]}
{bib}
\end{versus}
\end{document}

this is the result:

output of example code

i've used this to good effect for tables of contents and the like. notice that \rightskip has a smallish default indent, so that the third argument, if present, always sticks out just a little, to make it more obvious.

it would be easy enough to generate the numbers automatically, if that's appropriate.

a more compact (and to my way of thinking, cleaner) approach would be to use a delimited macro for the individual verses, doing away with the necessity of entering an empty set of braces if the last argument isn't present, but that's not the "latex way". for the sake of argument, here's a possibility (assuming that a greater or a less than sign will never appear in the text):

\def\xverse #1>#2>#3<{ as above }

\xverse 1>\textbf{1} Oblatrantem te><
\xverse 3> qui unus et uerus est> T2gdz<

extra spaces in the input are guarded against with \unskip and \ignorespaces.

| improve this answer | |
2

You can use lineno package.

\documentclass[9pt, DIV=22]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0cm}
\usepackage[switch]{lineno}
\begin{document}
\twocolumn
\newcommand\clause[1]{{%
    \unskip\nobreak\hfil\penalty50
    \hskip2em\hbox{}\nobreak\hfil\textbf{#1}%
    \parfillskip=0pt \finalhyphendemerits=0 \par}}

\section{Traktate}
\subsection{Ad Demetrianum}
\begin{linenumbers}
 \textbf{1} Oblatrantem te

% Most verses are short.
 et aduersus Deum

 qui unus et uerus est
\clause{T2gdz}

 ore sacrilego
\clause{Tg}

 et uerbis impiis

 obstrepentem frequenter,
\clause{Pg}

 Demetriane,

 contempseram

 uerecundius et melius existimans

 errantis inperitiam silentio spernere
\clause{T2d}

 quam loquendo dementis insaniam prouocare.
\clause{V3d}

 Nec hoc sine magisterii diuini auctoritate faciebam,
\clause{TT12g}

 cum scriptum sit:

% Many verses span multiple lines, a few are very long.
In aures inprudentis noli quicquam dicere, ne quando audierit inrideat sensatos sermones tuos, [Prou. 23, 9]
\clause{bib}
\end{linenumbers}

\end{document}

enter image description here

You can reset line numbers some where in mid document (when you want) by

\resetlinenumber[<number>]

or use

\begin{linenumbers}[1]

or use starred variant

\begin{linenumbers*}

Using xtab package: Here you have to manually fix the width of the second column.

\documentclass[9pt, DIV=22]{scrartcl}

\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\setlength{\parindent}{0cm}
\usepackage{xtab,array}
\newcounter{rowno}
\textheight=4in   %% just for demo
\begin{document}
\twocolumn
\newcommand\clause[1]{{%
    \unskip\nobreak\hfil\penalty50
    \hskip2em\hbox{}\nobreak\hfil\textbf{#1}%
    \parfillskip=0pt \finalhyphendemerits=0 \par}}

\section{Traktate}
\subsection{Ad Demetrianum}
\setcounter{rowno}{-1}
\begin{xtabular}{>{\stepcounter{rowno}\therowno.}rp{0.8\linewidth}}
 &\textbf{1} Oblatrantem te \\

% Most verses are short.
 &et aduersus Deum \\

 & qui unus et uerus est 
\clause{T2gdz}\\

 & ore sacrilego  
\clause{Tg}\\

 & et uerbis impiis \\

 & obstrepentem frequenter,
\clause{Pg} \\

 & Demetriane, \\

 & contempseram \\

 & uerecundius et melius existimans \\

 & errantis inperitiam silentio spernere
\clause{T2d} \\

 & quam loquendo dementis insaniam prouocare.
\clause{V3d} \\

 & Nec hoc sine magisterii diuini auctoritate faciebam,
\clause{TT12g} \\

 & cum scriptum sit: \\

% Many verses span multiple lines, a few are very long.
& In aures inprudentis noli quicquam dicere, ne quando audierit inrideat sensatos sermones tuos, [Prou. 23, 9]
\clause{bib}
\end{xtabular}
\end{document}

enter image description here

| improve this answer | |

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.