summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/reledmac/examples/2-subdivision-number-in-header.tex
blob: 33f18419f2cb50918bf4764e71c29b72fff4cf84 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
\documentclass[twoside]{article}
\usepackage[osf,p]{libertinus}
\usepackage{microtype}
\usepackage[pdfusetitle,hidelinks]{hyperref}
\usepackage[english, main=latin]{babel}
\babeltags{english = english}
\usepackage[series={},noend,nocritical,noeledsec,nofamiliar]{reledmac}

% CONFIG FANCYHDR TO SHOW LEFT/RIGHT MARKS IN HEADERS
\usepackage{fancyhdr}
\pagestyle{fancy}

%% What to show in the header
\newcommand{\mymarks}{%
  \ifdefstrequal{\leftmark}{\rightmark}%
  {\rightmark}%
  {\rightmark\ – \leftmark}%
}
%% Configure the header itself
\fancyhead[LE,RO]{}
\fancyhead[CE,CO]{\mymarks}
\fancyhead[LO,RE]{}


\def\sectionmark#1{}%Disable section marking

\begin{document}


\begin{english}
\date{}
\title{Subdivision number inside the header}
\maketitle
\begin{abstract}
  This file shows how to use the \verb+\doinsidethislinehook+ 
  command to use \verb+\markboth+ to add verse (sentence) numbers inside the headers.
  
  We can't call \verb+\markboth+ directly inside the \verb+pstart+…\verb+\pend+, because it creates trouble with vertical spacing.
 
  We show two examples: the first one add directly the verse number inside the source code, while the second use a counter to determine it automatically.

  To understand this example, you must be familiar with \LaTeX\ marking mechanism (\verb+\markboth+) and the \emph{fancyhdr} package.
\end{abstract}
\end{english}

\begin{english}
\section{Manual subdivision number}

\begin{abstract}
 In this example, the verse (sentence) number is typeset directly in the source code.
 We wrap it in a \verb+\versenumber+ macro, which:
 \begin{itemize}
   \item typesets it with a bold fontface, followed by a dot;
   \item uses \verb+\doinsidelinehook+ to call correctly \verb+\markboth+.
 \end{itemize}
\end{abstract}
\end{english}


\newcommand{\versenumber}[1]{%
  \doinsidethislinehook{\markboth{#1}{#1}}%
  \textbf{#1}.%
}

\beginnumbering
\pstart
\versenumber{1} Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
\versenumber{2} Morbi nec augue elit. 
\versenumber{3} Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat. 
\versenumber{4} Morbi ultrices at magna et cursus. 
\versenumber{5} Sed vel purus luctus, euismod erat in, fermentum orci.
\versenumber{6} Vivamus ac rutrum sapien, id ultricies augue.
\versenumber{7} Fusce sed rutrum lorem, ut auctor urna.
\versenumber{8} Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\versenumber{9} Nunc id tristique ipsum.
\versenumber{10} Quisque semper faucibus orci at eleifend.
\versenumber{11} Proin velit velit, sagittis nec consequat in, auctor eget tortor.
\versenumber{12} Pellentesque lorem elit, scelerisque id vulputate vel, faucibus a eros.
\versenumber{13} Nunc nec orci ullamcorper, sollicitudin magna id, maximus quam.
\versenumber{14} Pellentesque nec mauris purus.
\versenumber{15} Duis suscipit nunc vitae faucibus posuere. 
\versenumber{16} Integer mattis varius cursus.
\versenumber{17} Proin risus diam, imperdiet sit amet sem sed, dapibus sodales quam.
\versenumber{18} Pellentesque bibendum sapien eu nisl efficitur placerat. 
\versenumber{19} Aenean dignissim ante ac erat pharetra, non pellentesque ante sodales.
\versenumber{20} Nunc lorem nunc, elementum in accumsan id, blandit ac elit.
\versenumber{21} In rhoncus augue ex, quis tristique ex laoreet non.
\versenumber{22} Phasellus tincidunt, mauris nec auctor maximus, sapien elit elementum dolor.
\versenumber{23} Id pretium urna tortor sed purus.
\versenumber{24} Donec velit leo, varius ac dui eget, tincidunt euismod nibh.
\versenumber{25} Nulla facilisis sit amet leo et vehicula.
\versenumber{26} Morbi ultrices elementum nisi, ac semper neque faucibus non.
\versenumber{27} Curabitur et justo gravida eros consequat elementum.
\versenumber{28} Quisque eu consequat eros, vitae ullamcorper risus.
\versenumber{29} Nullam pellentesque id lectus a aliquet.
\versenumber{30} Cras rhoncus, arcu ut consequat ultricies, massa ante sollicitudin massa, vehicula ullamcorper quam libero vitae eros.
\versenumber{31} In dapibus arcu sed sem vehicula, ut imperdiet odio hendrerit.
\versenumber{32} Praesent nec diam turpis.
\versenumber{33} Vestibulum erat ante, maximus id pulvinar vitae, sagittis sed odio.
\versenumber{34} Pellentesque sit amet tellus aliquam, mattis purus a, consectetur turpis.
\versenumber{35} Praesent nunc magna, posuere ac faucibus eu, ullamcorper vel sem.
\versenumber{36} Aenean vel dolor eget felis malesuada molestie ac non justo.
\versenumber{37} Phasellus semper gravida mollis.
\versenumber{38} Mauris fermentum eget ex et eleifend.
\versenumber{39} Morbi sit amet cursus velit.
\versenumber{40} Ut efficitur, risus vel mattis ultrices, arcu metus scelerisque dui, eget semper dolor justo ac nisl.
\versenumber{41} Fusce euismod ultrices faucibus.
\versenumber{42} Vestibulum sit amet lacus dui.
\versenumber{43} Maecenas et nisi vel ex scelerisque dictum at vel nibh.
\versenumber{44} Morbi mattis quam ut congue elementum.
\versenumber{45} Etiam luctus ac metus id faucibus.
\versenumber{46} Nulla vulputate massa non tincidunt fringilla.
\versenumber{47} Praesent accumsan eget enim eu dapibus.
\versenumber{48} Nunc auctor, odio nec venenatis auctor, nibh sem efficitur sapien, ut mollis nunc nunc at massa.
\versenumber{49} Morbi vitae turpis iaculis, imperdiet quam vel, blandit purus.
\versenumber{50} Suspendisse lobortis dui et enim egestas, sed convallis dolor viverra.
\versenumber{51} Etiam mollis dolor nec laoreet facilisis.
\versenumber{52} Pellentesque fringilla mauris rhoncus pretium facilisis.
\versenumber{53} Quisque vitae posuere justo.
\versenumber{54} Quisque a rutrum elit.
\versenumber{55} In at pretium magna.
\versenumber{56} Morbi sed ullamcorper lectus.
\versenumber{57} Praesent ut rhoncus odio.
\versenumber{58} Cras a metus nisl.
\versenumber{59} Aliquam et congue nisi, viverra ultricies metus.
\versenumber{60} Duis fringilla laoreet nisi, at suscipit ex porttitor sed.
\versenumber{61} Mauris sit amet purus efficitur, euismod sem vitae, mattis neque.
\versenumber{62} Mauris pretium, turpis a suscipit pulvinar, est nunc lacinia lacus, at pulvinar nunc lacus in erat.
\versenumber{63} Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\versenumber{64} Morbi nec augue elit.
\versenumber{65} Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat.
\versenumber{66} Morbi ultrices at magna et cursus.
\versenumber{67} Sed vel purus luctus, euismod erat in, fermentum orci.
\versenumber{68} Vivamus ac rutrum sapien, id ultricies augue.
\versenumber{69} Fusce sed rutrum lorem, ut auctor urna.
\versenumber{70} Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\versenumber{71} posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat.
\versenumber{72} Morbi ultrices at magna et cursus.
\versenumber{73} Sed vel purus luctus, euismod erat in, fermentum orci.
\versenumber{74} Vivamus ac rutrum sapien, id ultricies augue.
\versenumber{75} Fusce sed rutrum lorem, ut auctor urna.
\versenumber{76} Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\versenumber{77} Id pretium urna tortor sed purus.
\versenumber{78} Donec velit leo, varius ac dui eget, tincidunt euismod nibh.
\versenumber{79} Nulla facilisis sit amet leo et vehicula.
\versenumber{80} Morbi ultrices elementum nisi, ac semper neque faucibus non.
\versenumber{81} Curabitur et justo gravida eros consequat elementum.
\versenumber{82} Quisque eu consequat eros, vitae ullamcorper risus.
\versenumber{83} Nullam pellentesque id lectus a aliquet.
\versenumber{84} Cras rhoncus, arcu ut consequat ultricies, massa ante sollicitudin massa, vehicula ullamcorper quam libero vitae eros.
\versenumber{85} In dapibus arcu sed sem vehicula, ut imperdiet odio hendrerit.
\versenumber{86} Praesent nec diam turpis.
\versenumber{87} Vestibulum erat ante, maximus id pulvinar vitae, sagittis sed odio.
\pend
\endnumbering
\newpage

\begin{english}
\section{Automatic verse number}

\begin{abstract}
 In this example, the verse (sentence) number is not typeset directly, but stored in a \LaTeX\ counter (whose name is \verb+verse+).
 The \verb+\autoversenumber+ macro:
 \begin{itemize}
   \item increases the counter;
   \item typesets it with a bold face, followed by a dot;
   \item use \verb+\doinsidelinehook+ to call correctly \verb+\markboth+.
 \end{itemize}

 The main problem is that, because of \emph{reledmac} mechanism,  the lines are typeset after the \verb+\pend+, 
 at a time when the \verb+verse+ counter is already set to its maximal value.
 Consequently, with the hack, the \verb+\markboth+ macro won't have set the marker to the correct value.

 However, we can solve this issue, because the argument of \verb+doinsidethislinehook+ is written in a auxiliary file
 when  it is read.

 Nevertheless, to write the correct value of the counter in the auxiliary file, we need to do some hacks with \TeX\'s expansion mechanism.

\end{abstract}
\end{english}

\newcounter{verse}
\newcommand{\autoversenumber}{%
  \refstepcounter{verse}%Add 1 to the counter
  \edef\tmp{\noexpand\markboth{\the\value{verse}}{\the\value{verse}}}%\tmp will be expanded to \markboth{<verse-value>}{<verse-value}>
  \expandafter\doinsidethislinehook\expandafter{\tmp}%First, we expand \tmp to  the value, and then, pass the result as argument to \doinsidelinehook
  \textbf{\theverse}.\space%Typeset the verse counter value in bold, followed by a dot and then a space.
}

\beginnumbering
\pstart
\autoversenumber Lorem ipsum dolor sit amet, consectetur adipiscing elit. 
\autoversenumber Morbi nec augue elit. 
\autoversenumber Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat. 
\autoversenumber Morbi ultrices at magna et cursus. 
\autoversenumber Sed vel purus luctus, euismod erat in, fermentum orci.
\autoversenumber Vivamus ac rutrum sapien, id ultricies augue.
\autoversenumber Fusce sed rutrum lorem, ut auctor urna.
\autoversenumber Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\autoversenumber Nunc id tristique ipsum.
\autoversenumber Quisque semper faucibus orci at eleifend.
\autoversenumber Proin velit velit, sagittis nec consequat in, auctor eget tortor.
\autoversenumber Pellentesque lorem elit, scelerisque id vulputate vel, faucibus a eros.
\autoversenumber Nunc nec orci ullamcorper, sollicitudin magna id, maximus quam.
\autoversenumber Pellentesque nec mauris purus.
\autoversenumber Duis suscipit nunc vitae faucibus posuere. 
\autoversenumber Integer mattis varius cursus.
\autoversenumber Proin risus diam, imperdiet sit amet sem sed, dapibus sodales quam.
\autoversenumber Pellentesque bibendum sapien eu nisl efficitur placerat. 
\autoversenumber Aenean dignissim ante ac erat pharetra, non pellentesque ante sodales.
\autoversenumber Nunc lorem nunc, elementum in accumsan id, blandit ac elit.
\autoversenumber In rhoncus augue ex, quis tristique ex laoreet non.
\autoversenumber Phasellus tincidunt, mauris nec auctor maximus, sapien elit elementum dolor.
\autoversenumber Id pretium urna tortor sed purus.
\autoversenumber Donec velit leo, varius ac dui eget, tincidunt euismod nibh.
\autoversenumber Nulla facilisis sit amet leo et vehicula.
\autoversenumber Morbi ultrices elementum nisi, ac semper neque faucibus non.
\autoversenumber Curabitur et justo gravida eros consequat elementum.
\autoversenumber Quisque eu consequat eros, vitae ullamcorper risus.
\autoversenumber Nullam pellentesque id lectus a aliquet.
\autoversenumber Cras rhoncus, arcu ut consequat ultricies, massa ante sollicitudin massa, vehicula ullamcorper quam libero vitae eros.
\autoversenumber In dapibus arcu sed sem vehicula, ut imperdiet odio hendrerit.
\autoversenumber Praesent nec diam turpis.
\autoversenumber Vestibulum erat ante, maximus id pulvinar vitae, sagittis sed odio.
\autoversenumber Pellentesque sit amet tellus aliquam, mattis purus a, consectetur turpis.
\autoversenumber Praesent nunc magna, posuere ac faucibus eu, ullamcorper vel sem.
\autoversenumber Aenean vel dolor eget felis malesuada molestie ac non justo.
\autoversenumber Phasellus semper gravida mollis.
\autoversenumber Mauris fermentum eget ex et eleifend.
\autoversenumber Morbi sit amet cursus velit.
\autoversenumber Ut efficitur, risus vel mattis ultrices, arcu metus scelerisque dui, eget semper dolor justo ac nisl.
\autoversenumber Fusce euismod ultrices faucibus.
\autoversenumber Vestibulum sit amet lacus dui.
\autoversenumber Maecenas et nisi vel ex scelerisque dictum at vel nibh.
\autoversenumber Morbi mattis quam ut congue elementum.
\autoversenumber Etiam luctus ac metus id faucibus.
\autoversenumber Nulla vulputate massa non tincidunt fringilla.
\autoversenumber Praesent accumsan eget enim eu dapibus.
\autoversenumber Nunc auctor, odio nec venenatis auctor, nibh sem efficitur sapien, ut mollis nunc nunc at massa.
\autoversenumber Morbi vitae turpis iaculis, imperdiet quam vel, blandit purus.
\autoversenumber Suspendisse lobortis dui et enim egestas, sed convallis dolor viverra.
\autoversenumber Etiam mollis dolor nec laoreet facilisis.
\autoversenumber Pellentesque fringilla mauris rhoncus pretium facilisis.
\autoversenumber Quisque vitae posuere justo.
\autoversenumber Quisque a rutrum elit.
\autoversenumber In at pretium magna.
\autoversenumber Morbi sed ullamcorper lectus.
\autoversenumber Praesent ut rhoncus odio.
\autoversenumber Cras a metus nisl.
\autoversenumber Aliquam et congue nisi, viverra ultricies metus.
\autoversenumber Duis fringilla laoreet nisi, at suscipit ex porttitor sed.
\autoversenumber Mauris sit amet purus efficitur, euismod sem vitae, mattis neque.
\autoversenumber Mauris pretium, turpis a suscipit pulvinar, est nunc lacinia lacus, at pulvinar nunc lacus in erat.
\autoversenumber Lorem ipsum dolor sit amet, consectetur adipiscing elit.
\autoversenumber Morbi nec augue elit.
\autoversenumber Vestibulum ante ipsum primis in faucibus orci luctus et ultrices posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat.
\autoversenumber Morbi ultrices at magna et cursus.
\autoversenumber Sed vel purus luctus, euismod erat in, fermentum orci.
\autoversenumber Vivamus ac rutrum sapien, id ultricies augue.
\autoversenumber Fusce sed rutrum lorem, ut auctor urna.
\autoversenumber Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\autoversenumber posuere cubilia Curae; Quisque cursus eros a erat placerat, et tempus neque volutpat.
\autoversenumber Morbi ultrices at magna et cursus.
\autoversenumber Sed vel purus luctus, euismod erat in, fermentum orci.
\autoversenumber Vivamus ac rutrum sapien, id ultricies augue.
\autoversenumber Fusce sed rutrum lorem, ut auctor urna.
\autoversenumber Proin rutrum dignissim turpis, placerat pellentesque nulla elementum in.
\autoversenumber Id pretium urna tortor sed purus.
\autoversenumber Donec velit leo, varius ac dui eget, tincidunt euismod nibh.
\autoversenumber Nulla facilisis sit amet leo et vehicula.
\autoversenumber Morbi ultrices elementum nisi, ac semper neque faucibus non.
\autoversenumber Curabitur et justo gravida eros consequat elementum.
\autoversenumber Quisque eu consequat eros, vitae ullamcorper risus.
\autoversenumber Nullam pellentesque id lectus a aliquet.
\autoversenumber Cras rhoncus, arcu ut consequat ultricies, massa ante sollicitudin massa, vehicula ullamcorper quam libero vitae eros.
\autoversenumber In dapibus arcu sed sem vehicula, ut imperdiet odio hendrerit.
\autoversenumber Praesent nec diam turpis.
\autoversenumber Vestibulum erat ante, maximus id pulvinar vitae, sagittis sed odio.

\pend
\endnumbering

\end{document}