Debian Codegraph @

texmf-dist/doc/lualatex/luaquotes/luaquotes-documentation.tex

raw
1 \documentclass{article}
2 \usepackage{luaquotes}
3 \usepackage{verbatim}
4 \usepackage{xcolor}
5 \usepackage{longtable}
6 \definecolor{darkspringgreen}{rgb}{0.09, 0.45, 0.27}
7 \definecolor{dsg}{rgb}{0.09, 0.45, 0.27}
8 \usepackage[hidelinks]{hyperref}
9 \usepackage{hologo}
10 \usepackage[british]{babel}
11 \usepackage[useregional]{datetime2}
12 \DTMlangsetup[en-GB]{ord=omit}
13 \definecolor{LightGray}{gray}{0.9}
14 %\usepackage{mathpazo}
15 \IfFontExistsTF{Palatine Parliamentary}{\setromanfont[RawFeature={+onum,+pnum},%
16 BoldFont={Palatine Parliamentary Bold},
17 ItalicFont={Palatine Parliamentary Italic}]{Palatine Parliamentary Regular}
18 }{\setromanfont[RawFeature={+onum,+pnum}]{TeX Gyre PagellaX}}
19 \setmonofont[Scale=.9]{Source Code Pro}
20 %\newfontface\primeback[Scale=1.01]{Libertinus Serif}
21 \newcommand{\primeback}{}
22
23 \newfontface\boxy{DejaVu Sans}
24 \newcommand{\thebox}{{\boxy ▯}}
25 %\usepackage[firstnumber=last]{fancyvrb}
26 \usepackage{minted}
27 \date{\today\\\smallskip\ttfamily Version \luaquotesversionnumber}
28 \author{Elijah Z Granet\thanks{e-mail: \href{mailto:[email protected]}{\ttfamily [email protected]}}}
29
30 \title{\texttt{LuaQuotes}:\\A package for smart quotation marks}
31
32 \begin{document}
33 \maketitle
34 \tableofcontents
35 \clearpage
36 \section{Overview}
37 \subsection{Purpose}
38 This package provides a function to automatically have 'smart quotes' in \hologo{LuaLaTeX}. By 'smart quotes', I refer to the automatic insertion of curved or 'typographer's' quotation marks when the user types straight quotation marks. The below figure illustrates the distinction in English typography:
39 \begin{center}
40 \renewcommand{\arraystretch}{2}
41 \begin{tabular}{ccc}
42 \ttfamily User input &\color{red} Smart Quotes Off & \color{darkspringgreen}Smart Quotes On\\
43 \LARGE\texttt{"Howdy!"}%
44 & \LARGE\textcolor{red}{\sqtworight}Howdy!\sqtworight%
45 & \LARGE "Howdy!"\\
46 \LARGE\texttt{'Don't!'}%
47 & \LARGE\textcolor{red}{\sqoneright}%
48 Don\sqoneright t!\sqoneright%
49 & \LARGE 'Don't!'
50
51 \end{tabular}
52 \end{center}
53
54 \section{Smart quotes}
55
56
57
58 \subsection{Options}
59 The default option, for English quotation marks, is called by:
60 \begin{minted}[
61 frame=lines,
62 framesep=2mm,
63 baselinestretch=1.2,
64 bgcolor=LightGray,
65 fontsize=\footnotesize,
66 breaklines,
67 ]
68 {latex}
69 \usepackage{luaquotes}
70 \end{minted}
71 The French, German, German (guillemets), and Swiss German options, for those languages' punctuation, are called by the following respective commands.
72 \begin{minted}[
73 frame=lines,
74 framesep=2mm,
75 baselinestretch=1.2,
76 bgcolor=LightGray,
77 fontsize=\footnotesize,
78 breaklines,
79 ]
80 {latex}
81 \usepackage[fr]{luaquotes} %French
82 \usepackage[de]{luaquotes} % German
83 \usepackage[degm]{luaquotes} % German with guillemets
84 \usepackage[dech]{luaquotes} %Swiss German
85 \end{minted}
86 \subsubsection{English Features}
87 The English features are designed to smartly recognise English punctuation:
88 \begin{center}
89 \renewcommand{\arraystretch}{2}
90 \begin{tabular}{ccc}
91 \ttfamily Feature & User input & Output\\
92 Double Quotes & \LARGE\texttt{"Hello!"}%
93 &
94 \LARGE "Hello"\\
95 Single Quotes& \LARGE\texttt{'Hello!'}%
96 & \LARGE 'Hello' \\
97 Contractions & \LARGE \texttt{Don't} & \LARGE Don't\\
98 \end{tabular}
99 \end{center}
100
101 \subsubsection{French option}
102 The French option produces the following output, including the extra space around punctuation prescribed by French typography:
103 \begin{center}
104 \renewcommand{\arraystretch}{2}
105 \begin{tabular}{cc}
106 \ttfamily User input &Output\\
107 \LARGE\texttt{"Salut!"}%
108 & \LARGE \glmtl Salut!\glmtr\\
109 \LARGE\texttt{'Salut!'}%
110 & \LARGE \sglmtl Salut!\sglmtr\\
111
112 \end{tabular}
113 \end{center}
114 \subsubsection{The German option}
115 The German option produces the following output:
116
117 \begin{center}
118 \renewcommand{\arraystretch}{2}
119 \begin{tabular}{cc}
120 \ttfamily User input &Output\\
121 \LARGE\texttt{"Hallo!"}%
122 & \LARGE \dedouble Hallo!\sqtwoleft\\
123 \LARGE\texttt{'Hallo!'}%
124 & \LARGE \desingle Hallo!\sqoneleft\\
125
126 \end{tabular}
127 \end{center}
128 \subsubsection{The German (guillemets) option}
129 The German (guillemets) option produces the following output:
130
131 \begin{center}
132 \renewcommand{\arraystretch}{2}
133 \begin{tabular}{cc}
134 \ttfamily User input &Output\\
135 \LARGE\texttt{"Hallo!"}%
136 & \LARGE \degmdouble Hallo!\degmtr\\
137 \LARGE\texttt{'Hallo!'}%
138 & \LARGE \degmsingle Hallo!\desgmtr\\
139
140 \end{tabular}
141 \end{center}
142
143 \subsubsection{The Swiss German option}
144 The Swiss German option produces the following output:
145
146 \begin{center}
147 \renewcommand{\arraystretch}{2}
148 \begin{tabular}{cc}
149 \ttfamily User input &Output\\
150 \LARGE\texttt{"Hallo!"}%
151 & \LARGE \glmtl Hallo!\glmtr\\
152 \LARGE\texttt{'Hallo!'}%
153 & \LARGE \sglmtl Hallo!\sglmtr\\
154
155 \end{tabular}
156 \end{center}
157
158 \subsection{Activation and De-activation}
159 The package automatically activates the smart quotes function at the beginning of the document. To deactivate the smart quotes function within a document, the following commands are used:
160 \begin{minted}[
161 frame=lines,
162 framesep=2mm,
163 baselinestretch=1.2,
164 bgcolor=LightGray,
165 fontsize=\footnotesize,
166 breaklines,
167 ]
168 {latex}
169 \dumbquotes %English
170 \frdumbquotes %French
171 \dedumbquotes %German
172 \degmdumbquotes %German with French-style quotes
173 \end{minted}
174
175 The following commands re-activate the smart quotes function:
176 \begin{minted}[
177 frame=lines,
178 framesep=2mm,
179 baselinestretch=1.2,
180 bgcolor=LightGray,
181 fontsize=\footnotesize,
182 breaklines,
183 ]
184 {latex}
185 \smartquotes %English
186 \frsmartquotes %French
187 \desmartquotes % German
188 \degmsmartquotes % German with French-style quotes
189 \end{minted}
190
191 A limitation on the (de-)activation of the package is that the Lua filters will not deactivate within the same paragraph, so the function can only be changed across paragraphs.
192
193 \subsection{Monospace}
194 As a general rule, smart quotes are rather undesirable in monospace text, and therefore, within the \color{darkspringgreen} \verb!\texttt!\color{black}\ environment the package does not apply smart quotes. Thus, the same input produces in roman face \textcolor{darkspringgreen}{"Hello World"} but in monospace \texttt{"Hello World"}.
195
196 As the example above shows, the default behaviour of this package forces straight quotes in monospace, and disables \TeX\ quote ligatures (but not other \TeX\ ligatures) to do so, on the assumption that any form of curved quotes are undesirable.
197
198 For extended periods of monospaced text called by {\color{darkspringgreen}\verb!\ttfamily!}, the activation and de-activation methods above should be used. I considered altering the {\color{darkspringgreen}\verb!\ttfamily!} command to always call on {\color{darkspringgreen}\verb!\dumbquotes!}, but I thought it best to avoid messing with the command. This may change in future development.
199
200
201 If a user desires to disable the smart quotes for other faces, this is easily done globally by adding the following line to the font's configuration in {\color{darkspringgreen}\texttt{fontspec}}:
202 \begin{minted}[
203 frame=lines,
204 framesep=2mm,
205 baselinestretch=1.2,
206 bgcolor=LightGray,
207 fontsize=\footnotesize,
208 breaklines,
209 ]
210 {latex}
211 RawFeature={+qtbye}
212 \end{minted}
213 This will, however, result in the font using straight quotes rather than the standard \TeX\ quote ligatures, making it a distinct option than the activation and de-activation options \textit{supra}.
214 \section{Auxiliary Punctuation}
215 The smart quotes feature covers the 'standard' usage of quotes, but there are many instances where quotation mark or quote-mark like features are needed outside the automatic formatting. The package provides several commands for this.
216 \subsection{Standalone quotes}
217 The marks in this section are the set of quotation marks used generally in writing and require little explanation. However, it should be noted that the commands {\color{dsg}\verb!\sqoneright!} and {\color{dsg}\verb!\apost!} (which produce identical output) are very useful for aphetic words by which the first syllable is clipped, as in the sequence {\color{dsg}\texttt{'bout}} the smart quotes function will incorrectly produce an opening quote instead of the correct closing quote to indicate the elision. Thus, the incorrect result of {\color{red} 'bout} is produced. The solution is to use the code {\color{dsg}\verb!\apost bout!} which produces \textcolor{dsg}{\apost bout}.
218
219 \begin{center}
220 \renewcommand{\arraystretch}{4}
221 \begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}}
222 \textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\
223 Single low quote & \ttfamily U+201A & \verb!\desingle! & \Huge\desingle\thebox\\
224 Double low quote & \ttfamily U+201E & \verb!\dedouble! & \Huge\dedouble\thebox
225 \\
226 Single straight quote & \ttfamily U+0027 & \verb!\dqone! & \Huge\dqone\thebox\\
227 Double straight quote & \ttfamily U+0022 & \verb!\dqtwo! & \Huge\dqtwo\thebox\\
228 Left single quote & \ttfamily U+2018 & \verb!\sqoneleft! & \Huge\sqoneleft\thebox\\
229 Right single quote & \ttfamily U+2019 & \verb!\sqoneright! & \Huge\thebox\sqoneright\\
230 Apostrophe & \ttfamily U+2019 & \verb!\apost! & \Huge\thebox\apost\\
231 Left double quote & \ttfamily U+201C & \verb!\sqtwoleft! & \Huge\sqtwoleft\thebox\\
232 Right double quote & \ttfamily U+201D & \verb!\sqtworight! & \Huge\thebox\sqtworight\\
233 Left guillemet [w/ space]& \ttfamily U+00AB & \verb!\glmtl! & \Huge\glmtl\thebox\\
234 Right guillemet [w/ space]& \ttfamily U+00BB & \verb!\glmtr! & \Huge\thebox\glmtr\\
235 \texttt{degm} left guillemet & \ttfamily U+00BB & \verb!\degmtl! & \Huge\degmtl\thebox\\
236 \texttt{degm} right guillemet & \ttfamily U+00AB & \verb!\degmtr! & \Huge\thebox\degmtr\\
237 Single left guillemet [w/ space]& \ttfamily U+2039 & \verb!\sglmtl! & \Huge\sglmtl\thebox\\
238 Single right guillemet [w/ space]& \ttfamily U+203A & \verb!\sglmtr! & \Huge\thebox\sglmtr\\
239 \texttt{degm} single left guillemet & \ttfamily U+203A & \verb!\desgmtl! & \Huge\desgmtl\thebox\\
240 \texttt{degm} single right guillemet & \ttfamily U+2039 & \verb!\desgmtr! & \Huge\thebox\desgmtr\\
241
242 \end{longtable}
243 \end{center}
244
245 \subsection{Additional symbols}
246 These are quote like symbols which are useful for precise punctuation, since standard smart quotation marks do not work well in their specialised use cases.
247
248
249 \begin{center}
250 \begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}}
251 \textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\
252 Backtick & \ttfamily U+0060 & \verb!\bcktck! & \Huge\bcktck\thebox
253 \end{longtable}
254 \end{center}
255 For typesetting US/Imperial measurements like feet and inches, the correct symbol is a prime and double prime. Many modern typefaces have these symbols, and they are thus useful for typesetting feet and inch measurements (like 6\primeback\lqprime\normalfont 4\primeback\lqdoubleprime ).
256
257
258 \begin{center}
259 \begin{longtable}{p{3cm}p{1.5cm}p{2.4cm}p{2.5cm}}
260 \textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\
261 Single Prime & \ttfamily U+2032 & \verb!\lqprime! & \Huge\thebox\lqprime\\
262 Double Prime & \ttfamily U+2033 & \verb!\lqdoubleprime! & \Huge\thebox\lqdoubleprime
263 \end{longtable}
264 \end{center}
265
266 %\newcommand{\lqprime}{′}
267 %\newcommand{\lqdoubleprime}{″}
268
269
270
271
272 For certain Polynesian languages, a letter called the \okina Okina is used; while this appears identical to a left single quotation mark in many fonts, it is encoded differently in Unicode because it is properly a letter, not a punctuation mark.
273
274
275
276
277 \begin{center}
278 \begin{longtable}{p{3cm}p{1.5cm}p{2cm}p{2.5cm}}
279 \textbf{Name} & \textbf{UTF-8} & \textbf{Command} & \textbf{Produces}\\
280 Okina & \ttfamily U+022B & \verb!\okina! & \Huge\okina\thebox\\\
281
282
283 \end{longtable}
284 \end{center}
285
286
287
288
289 \section{Future Development and Localisation}
290 The package's online repository is the best place to report bugs, feature requests, or other contributions, and is located at: \\\url{https://github.com/ezgranet/luaquotes}.
291
292 One obvious point of future development is the addition of other language localisations; this is technologically easy in principle but difficult for me to accomplish without assistance because it requires detailed knowledge of typographic conventions for any given language standard, and therefore the aid of contributors and collaborators. \section{Licence}
293 This project is licensed under the Latex Public Project Licence version 1.3\textit{c}. This documentation is copyright of the author but licensed under CC-BY-SA 3.0.
294
295
296 \clearpage\section{Implementation}
297
298 \begin{minted}[
299 frame=lines,
300 baselinestretch=1.2,
301 fontsize=\footnotesize,
302 linenos,
303 breaklines,
304 firstnumber=last
305 ]
306 {latex}
307
308
309 \def\luaquotesversionnumber{1.4.0}
310 \ProvidesPackage{luaquotes}
311 [2023/01/25\luaquotesversionnumber smart quotes with lua]
312 % !TeX program = lualatex
313 % !TeX encoding = utf8
314 % This work may be distributed and/or modified under the
315 % conditions of the LaTeX Project Public License, either version 1.3c
316 % of this license or (at your option) any later version.
317 % The latest version of this license is in
318 % http://www.latex-project.org/lppl.txt
319 % and version 1.3c or later is part of all distributions of LaTeX
320 % version 2005/12/01 or later.
321 %
322 % This work has the LPPL maintenance status `maintained'.
323 %
324 % The Current Maintainer of this work is Elijah Z Granet
325
326 %%%%%%%%%%%%%%%%%%%%%%%%%%%
327 %%%%%%%%%%%%%%%%%%%%%%%%%%%
328 % to show the package only works with Lua
329 %%%%%%%%%%%%%%%%%%%%%%%%%%%
330 %%%%%%%%%%%%%%%%%%%%%%%%%%%
331 \RequirePackage{iftex}
332 \ifPDFTeX {
333 \PackageError{luaquotes}
334 {You are using pdfTeX but this package only works
335 \MessageBreak with LuaTeX}{}
336 }
337 \else\ifXeTeX{ \PackageError{luaquotes}
338 {You are using XeTeX but this package only works
339 \MessageBreak with LuaTeX}{}
340 }\fi\fi
341 %%%%%%%%%%%%%%%%%%%%%%%%%%%
342 %%%%%%%%%%%%%%%%%%%%%%%%%%%
343 % Dependency
344 %%%%%%%%%%%%%%%%%%%%%%%%%%%
345 %%%%%%%%%%%%%%%%%%%%%%%%%%%
346 \RequirePackage{luacode}
347 %%%%%%%%%%%%%%%%%%%%%%%%%%%
348 %%%%%%%%%%%%%%%%%%%%%%%%%%%
349 % fontspec for the auxiliary
350 % quotes where tligs need
351 % to be disabled
352 %%%%%%%%%%%%%%%%%%%%%%%%%%%
353 %%%%%%%%%%%%%%%%%%%%%%%%%%%
354 \RequirePackage{fontspec}
355 %%%%%%%%%%%%%%%%%%%%%%%%%%%
356
357 %%%%%%%%%%%%%%%%%%%%%%%%%%%
358 %%%%%%%%%%%%%%%%%%%%%%%%%%%
359 % removing the effects for monospace
360 %%%%%%%%%%%%%%%%%%%%%%%%%%%
361 \begin{luacode}
362 local uchar = unicode.utf8.char
363 fonts.handlers.otf.addfeature{
364 name = "qtbye",
365 type = "substitution",
366 data =
367 {
368 “ = 0x0022,
369 ” = 0x0022,
370 ’ = 0x0027,
371 « = 0x0022,
372 » = 0x0022,
373 ‹ = 0x0027,
374 › = 0x0027
375 },
376 }
377 \end{luacode}
378 %%%%%%%%%%%%%%%%%%%%%%%%%%%
379 %%%%%%%%%%%%%%%%%%%%%%%%%%%
380 %%%%%%%%%%%%%%%%%%%%%%%%%%%
381 %%%%%%%%%%%%%%%%%%%%%%%%%%%
382 % Code here and throughout similar
383 %functions partly adapted from TeX.SE user
384 % Mico
385 % https://tex.stackexchange.com/questions/499953/how-to-generate-correct-single-and-double-quotes-in-tex
386 %%%%%%%%%%%%%%%%%%%%%%%%%%%
387 %%%%%%%%%%%%%%%%%%%%%%%%%%%
388
389 \luaexec{
390 function doublequotes ( s )
391 return ( s:gsub ( '"(..-)"' , "“\%1”" ) )
392 end}
393
394 %%%%%%%%%%%%%%%%%%%%%%%%%%%
395 %%%%%%%%%%%%%%%%%%%%%%%%%%%
396 % Assuming ' at the start of the line means an opening quotation mark not an apostrophe
397 %%%%%%%%%%%%%%%%%%%%%%%%%%%
398 %%%%%%%%%%%%%%%%%%%%%%%%%%%
399 \luaexec{function singlequotelinestart ( s )
400 return (s:gsub ("^'","‘" ) )
401 end}
402
403
404
405 % \luaexec{
406 % function abbrevsingle ( s )
407 % return ( s:gsub ( " '(..-) " , " ’\%1 " ) )
408 % end}
409
410 \luaexec{function singlequotes ( s )
411 return ( s:gsub ( " '"," ‘" ) )
412 end}
413
414
415 %%%%%%%%%%%%%%%%%%%%%%%%%%%
416 %%%%%%%%%%%%%%%%%%%%%%%%%%%
417 % parentheses
418 %%%%%%%%%%%%%%%%%%%%%%%%%%%
419 %%%%%%%%%%%%%%%%%%%%%%%%%%%
420 \newcommand{\sqoneleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‘}}
421
422 \luaexec{function psinglequotes ( s )
423 return ( s:gsub ( "\%('",[[(\sqoneleft]] ) )
424 end}
425
426 \newcommand\singlequotespon{\directlua{
427 luatexbase.add_to_callback (
428 "process_input_buffer" , psinglequotes , "psinglequotes" )
429 }}
430 \newcommand\singlequotespoff{\directlua{luatexbase.remove_from_callback (
431 "process_input_buffer" , "psinglequotes" )}}
432
433
434 %%%%%%%%%%%%%%%%%%%%%%%%%%%
435 %%%%%%%%%%%%%%%%%%%%%%%%%%%
436 % DE parentheses
437 %%%%%%%%%%%%%%%%%%%%%%%%%%%
438 %%%%%%%%%%%%%%%%%%%%%%%%%%%
439 %\newcommand{\sqoneleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‘}}
440
441 \luaexec{function depsinglequotes ( s )
442 return ( s:gsub ( "\%('",[[(‚]] ) )
443 end}
444
445 \newcommand\desinglequotespon{\directlua{
446 luatexbase.add_to_callback (
447 "process_input_buffer" , depsinglequotes , "depsinglequotes" )
448 }}
449 \newcommand\desinglequotespoff{\directlua{luatexbase.remove_from_callback (
450 "process_input_buffer" , "depsinglequotes" )}}
451
452 \luaexec{function depsinglequotesclose ( s )
453 return ( s:gsub ( "'\%)",[[\sqoneleft)]] ) )
454 end}
455
456 \newcommand\desinglequotespcloseon{\directlua{
457 luatexbase.add_to_callback (
458 "process_input_buffer" , depsinglequotesclose , "depsinglequotesclose" )
459 }}
460 \newcommand\desinglequotespcloseoff{\directlua{luatexbase.remove_from_callback (
461 "process_input_buffer" , "depsinglequotesclose" )}}
462
463
464
465 %%%%%%%%%%%%%%%%%%%%%%%%%%%
466 %%%%%%%%%%%%%%%%%%%%%%%%%%%
467 % FR Parentheses
468 %%%%%%%%%%%%%%%%%%%%%%%%%%%
469 %%%%%%%%%%%%%%%%%%%%%%%%%%%
470 \newcommand{\sglmtlp}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹\hskip .16667em}}
471 \newcommand{\sglmtrp}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\hskip .16667em›}}
472
473 \luaexec{function frpsinglequotes ( s )
474 return ( s:gsub ( "\%('",[[(\sglmtlp]] ) )
475 end}
476 \luaexec{function frpsinglequotesclose ( s )
477 return ( s:gsub ( "'\%)",[[\sglmtrp)]] ) )
478 end}
479
480 \newcommand\frsinglequotespon{\directlua{
481 luatexbase.add_to_callback (
482 "process_input_buffer" , frpsinglequotes , "frpsinglequotes" )
483 }}
484 \newcommand\frsinglequotespoff{\directlua{luatexbase.remove_from_callback (
485 "process_input_buffer" , "frpsinglequotes" )}}
486 \newcommand\frsinglequotespcloseon{\directlua{
487 luatexbase.add_to_callback (
488 "process_input_buffer" , frpsinglequotesclose , "frpsinglequotesclose" )
489 }}
490 \newcommand\frsinglequotespcloseoff{\directlua{luatexbase.remove_from_callback (
491 "process_input_buffer" , "frpsinglequotesclose" )}}
492
493 %%%%%%%%%%%%%%%%%%%%%%%%%%%
494 %%%%%%%%%%%%%%%%%%%%%%%%%%%
495 % DECH Parentheses
496 %%%%%%%%%%%%%%%%%%%%%%%%%%%
497 %%%%%%%%%%%%%%%%%%%%%%%%%%%
498 \newcommand{\sglmtlpdech}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹}}
499 \newcommand{\sglmtrpdech}{{\addfontfeature{RawFeature={-qtbye,-tlig}}›}}
500
501 \luaexec{function dechpsinglequotes ( s )
502 return ( s:gsub ( "\%('",[[(\sglmtlpdech]]) )
503 end}
504 \luaexec{function dechpsinglequotesclose ( s )
505 return ( s:gsub ( "'\%)",[[\sglmtrpdech)]]) )
506 end}
507
508 \newcommand\dechsinglequotespon{\directlua{
509 luatexbase.add_to_callback (
510 "process_input_buffer" , dechpsinglequotes , "dechpsinglequotes" )
511 }}
512 \newcommand\dechsinglequotespoff{\directlua{luatexbase.remove_from_callback (
513 "process_input_buffer" , "dechpsinglequotes" )}}
514 \newcommand\dechsinglequotespcloseon{\directlua{
515 luatexbase.add_to_callback (
516 "process_input_buffer" , dechpsinglequotesclose , "dechpsinglequotesclose" )
517 }}
518 \newcommand\dechsinglequotespcloseoff{\directlua{luatexbase.remove_from_callback (
519 "process_input_buffer" , "dechpsinglequotesclose" )}}
520
521 %%%%%%%%%%%%%%%%%%%%%%%%%%%
522 %%%%%%%%%%%%%%%%%%%%%%%%%%%
523 % activation and deactivation
524 %%%%%%%%%%%%%%%%%%%%%%%%%%%
525 %%%%%%%%%%%%%%%%%%%%%%%%%%%
526 \newcommand\doublequoteson{\directlua{luatexbase.add_to_callback (
527 "process_input_buffer" ,
528 doublequotes ,
529 "doublequotes" )}}
530 \newcommand\doublequotesoff{\directlua{luatexbase.remove_from_callback (
531 "process_input_buffer" ,
532 "doublequotes" )}}
533 % \newcommand\abbrevsingleon{\directlua{luatexbase.add_to_callback (
534 % "process_input_buffer" ,
535 % abbrevsingle ,
536 % "abbrevsingle" )}}
537 % \newcommand\abbrevsingleoff{\directlua{luatexbase.remove_from_callback (
538 % "process_input_buffer" ,
539 % "abbrevsingle" )}}
540
541 \newcommand\singlequotelinestarton{\directlua{
542 luatexbase.add_to_callback (
543 "process_input_buffer" , singlequotelinestart , "singlequotelinestart" )
544 }}
545 \newcommand\singlequotelinestartoff{\directlua{
546 luatexbase.remove_from_callback (
547 "process_input_buffer" , "singlequotelinestart" )
548 }}
549 \newcommand\singlequoteson{\directlua{
550 luatexbase.add_to_callback (
551 "process_input_buffer" , singlequotes , "singlequotes" )
552 }}
553 \newcommand\singlequotesoff{\directlua{luatexbase.remove_from_callback (
554 "process_input_buffer" , "singlequotes" )}}
555 %%%%%%%%%%%%%%%%%%%%%%%%%%%
556 %%%%%%%%%%%%%%%%%%%%%%%%%%%
557 % global functions, useful for things like this
558 %%%%%%%%%%%%%%%%%%%%%%%%%%%
559 %%%%%%%%%%%%%%%%%%%%%%%%%%%
560 \newcommand{\smartquotes}{%
561 \doublequoteson%
562 \singlequotelinestarton%
563 % \abbrevsingleon%
564 \singlequoteson
565 \singlequotespon}
566 \newcommand{\dumbquotes}{
567 \doublequotesoff
568 % \abbrevsingleoff
569 \singlequotelinestartoff
570 \singlequotesoff
571 \singlequotespoff
572 }
573
574 \DeclareOption{en}{
575 \AtBeginDocument{\dechsmartquotes\dechdumbquotes\frsmartquotes\frdumbquotes\desmartquotes\dedumbquotes\degmsmartquotes\degmdumbquotes\smartquotes}
576 \renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}}
577 }
578
579 %%%%%%%%%%%%%%%%%%%%%%%%%%%
580 %%%%%%%%%%%%%%%%%%%%%%%%%%%
581 % auxiliary punctuation
582 %%%%%%%%%%%%%%%%%%%%%%%%%%%
583 %%%%%%%%%%%%%%%%%%%%%%%%%%%
584 % Essentially to be used where the
585 % thing fails to provide the
586 % quotation or
587 % quote like punctuation
588 % needed
589 %%%%%%%%%%%%%%%%%%%%%%%%%%%
590 %%%%%%%%%%%%%%%%%%%%%%%%%%%
591 %%%%%%%%%%%%%%%%%%%%%%%%%%%
592 %%%%%%%%%%%%%%%%%%%%%%%%%%%
593 %%%%%%%%%%%%%%%%%%%%%%%%%%%
594 %%%%%%%%%%%%%%%%%%%%%%%%%%%
595 %%%%%%%%%%%%%%%%%%%%%%%%%%%
596 %%%%%%%%%%%%%%%%%%%%%%%%%%%
597 % German quotations
598 %%%%%%%%%%%%%%%%%%%%%%%%%%%
599 %%%%%%%%%%%%%%%%%%%%%%%%%%%
600 \newcommand{\desingle}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201A}}}
601 \newcommand{\dedouble}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"201E}}}
602 \newcommand{\degmsingle}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"203A}}}
603 \newcommand{\degmdouble}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"00BB}}}
604 %%%%%%%%%%%%%%%%%%%%%%%%%%%
605 %%%%%%%%%%%%%%%%%%%%%%%%%%%
606 % backtick
607 %%%%%%%%%%%%%%%%%%%%%%%%%%%
608 %%%%%%%%%%%%%%%%%%%%%%%%%%%
609 \newcommand{\bcktck}{{\addfontfeature{RawFeature={-qtbye,-tlig}}`}}
610 %%%%%%%%%%%%%%%%%%%%%%%%%%%
611 %%%%%%%%%%%%%%%%%%%%%%%%%%%
612 % Straight double
613 % and single quotes
614 %%%%%%%%%%%%%%%%%%%%%%%%%%%
615 %%%%%%%%%%%%%%%%%%%%%%%%%%%
616
617 \newcommand{\dqone}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0027}}}
618 \newcommand{\dqtwo}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\symbol{"0022}}}
619 %%%%%%%%%%%%%%%%%%%%%%%%%%%
620 %%%%%%%%%%%%%%%%%%%%%%%%%%%
621 % Prime, mostly for
622 % Feet and inches
623 %%%%%%%%%%%%%%%%%%%%%%%%%%%
624 %%%%%%%%%%%%%%%%%%%%%%%%%%%
625 \newcommand{\lqprime}{′}
626 \newcommand{\lqdoubleprime}{″}
627 %%%%%%%%%%%%%%%%%%%%%%%%%%%
628 %%%%%%%%%%%%%%%%%%%%%%%%%%%
629 % The Okina, for typing
630 % Hawaiʻi
631 %%%%%%%%%%%%%%%%%%%%%%%%%%%
632 %%%%%%%%%%%%%%%%%%%%%%%%%%%
633 \newcommand{\okina}{ʻ}
634 %%%%%%%%%%%%%%%%%%%%%%%%%%%
635 %%%%%%%%%%%%%%%%%%%%%%%%%%%
636 % The individual smart quotes
637 %
638 %%%%%%%%%%%%%%%%%%%%%%%%%%%
639 %%%%%%%%%%%%%%%%%%%%%%%%%%%
640 %%%%%%%%%%%%%%%%%%%%%%%%%%%
641 %%%%%%%%%%%%%%%%%%%%%%%%%%%
642 \newcommand{\sqtwoleft}{{\addfontfeature{RawFeature={-qtbye,-tlig}}“}}
643 \newcommand{\sqtworight}{{\addfontfeature{RawFeature={-qtbye,-tlig}}”}}
644 \newcommand{\sqoneright}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}}
645 \newcommand{\apost}{{\addfontfeature{RawFeature={-qtbye,-tlig}}’}}
646 %sqoneleft command moved because order mattered
647 \newcommand{\glmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}«\,}}
648 \newcommand{\glmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,»}}
649 \newcommand{\sglmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹\,}}
650 \newcommand{\sglmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}\,›}}
651
652 \newcommand{\degmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}»}}
653 \newcommand{\degmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}«}}
654 \newcommand{\desgmtl}{{\addfontfeature{RawFeature={-qtbye,-tlig}}›}}
655 \newcommand{\desgmtr}{{\addfontfeature{RawFeature={-qtbye,-tlig}}‹}}
656 %%%%%%%%%%%%%%%%%%%%%%%%%%%
657 %%%%%%%%%%%%%%%%%%%%%%%%%%%
658 % DEUTSCH
659 %%%%%%%%%%%%%%%%%%%%%%%%%%%
660 %%%%%%%%%%%%%%%%%%%%%%%%%%%
661 \luaexec{function dedoublequotes ( s )
662 return ( s:gsub ( '"(..-)"' , "„\%1“" ) )
663 end}
664 \luaexec{function desinglequotelinestart ( s )
665 return (s:gsub ("^'","‚" ) )
666 end}
667 \luaexec{function desinglequotesclose( s )
668 return ( s:gsub ( " '(..-)'", " ‚\%1`" ) )
669 end}
670
671 %% Two utility macros to activate/deactivate the Lua function:
672 \newcommand\dedoublequoteson{\directlua{luatexbase.add_to_callback (
673 "process_input_buffer" , dedoublequotes , "dedoublequotes" )}}
674 \newcommand\dedoublequotesoff{\directlua{luatexbase.remove_from_callback (
675 "process_input_buffer" , "dedoublequotes" )}}
676 \newcommand\desinglequotelinestarton{\directlua{luatexbase.add_to_callback (
677 "process_input_buffer" , desinglequotelinestart , "desinglequotelinestart" )}}
678 \newcommand\desinglequotelinestartoff{\directlua{luatexbase.remove_from_callback (
679 "process_input_buffer" , "desinglequotelinestart" )}}
680 \newcommand\desinglequotescloseon{\directlua{luatexbase.add_to_callback (
681 "process_input_buffer" , desinglequotesclose , "desinglequotesclose" )}}
682 \newcommand\desinglequotescloseoff{\directlua{luatexbase.remove_from_callback (
683 "process_input_buffer" , "desinglequotesclose" )}}
684 \newcommand{\desmartquotes}{\dedoublequoteson
685 \desinglequotelinestarton
686 \desinglequotescloseon
687 \desinglequotespon
688 \desinglequotespcloseon
689 }
690 \newcommand{\dedumbquotes}{\dedoublequotesoff
691 \desinglequotelinestartoff
692 \desinglequotescloseoff
693 \desinglequotespoff
694 \desinglequotespcloseoff
695 }
696 \DeclareOption{de}{
697 \AtBeginDocument{
698 \dechsmartquotes\dechdumbquotes
699 \frsmartquotes
700 \frdumbquotes
701 \smartquotes
702 \dumbquotes\dumbquotes
703 \desmartquotes}
704 \renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}}
705 }
706
707 %%%%%%%%%%%%%%%%%%%%%%%%%%%
708 %%%%%%%%%%%%%%%%%%%%%%%%%%%
709 % SCHÖNERES DEUTSCH
710 %%%%%%%%%%%%%%%%%%%%%%%%%%%
711 %%%%%%%%%%%%%%%%%%%%%%%%%%%
712 \luaexec{function degmdoublequotes ( s )
713 return ( s:gsub ( '"(..-)"' , "»\%1«" ) )
714 end}
715 \luaexec{function degmsinglequotelinestart ( s )
716 return (s:gsub ("^'","›" ) )
717 end}
718 \luaexec{function degmsinglequotesclose( s )
719 return ( s:gsub ( " '(..-)'", " ‚\%1‹" ) )
720 end}
721
722 %% Two utility macros to activate/deactivate the Lua function:
723 \newcommand\degmdoublequoteson{\directlua{luatexbase.add_to_callback (
724 "process_input_buffer" , degmdoublequotes , "degmdoublequotes" )}}
725 \newcommand\degmdoublequotesoff{\directlua{luatexbase.remove_from_callback (
726 "process_input_buffer" , "degmdoublequotes" )}}
727 \newcommand\degmsinglequotelinestarton{\directlua{luatexbase.add_to_callback (
728 "process_input_buffer" , degmsinglequotelinestart , "degmsinglequotelinestart" )}}
729 \newcommand\degmsinglequotelinestartoff{\directlua{luatexbase.remove_from_callback (
730 "process_input_buffer" , "degmsinglequotelinestart" )}}
731 \newcommand\degmsinglequotescloseon{\directlua{luatexbase.add_to_callback (
732 "process_input_buffer" , degmsinglequotesclose , "degmsinglequotesclose" )}}
733 \newcommand\degmsinglequotescloseoff{\directlua{luatexbase.remove_from_callback (
734 "process_input_buffer" , "degmsinglequotesclose" )}}
735 \newcommand{\degmsmartquotes}{\degmdoublequoteson
736 \degmsinglequotelinestarton
737 \degmsinglequotescloseon}
738 \newcommand{\degmdumbquotes}{\degmdoublequotesoff
739 \degmsinglequotelinestartoff
740 \degmsinglequotescloseoff}
741 \DeclareOption{degm}{
742 \AtBeginDocument{
743 \dechsmartquotes\dechdumbquotes
744 \frsmartquotes
745 \frdumbquotes
746 \smartquotes
747 \dumbquotes\dumbquotes
748 \degmsmartquotes}
749 \renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}}
750 }
751
752 %%%%%%%%%%%%%%%%%%%%%%%%%%%
753 %%%%%%%%%%%%%%%%%%%%%%%%%%%
754 % Français
755 %%%%%%%%%%%%%%%%%%%%%%%%%%%
756 %%%%%%%%%%%%%%%%%%%%%%%%%%%
757 \luaexec{function frdoublequotes ( s )
758 return ( s:gsub ( '"(..-)"' , "«\\,\%1\\,»" ) )
759 end}
760
761
762 \luaexec{function frsinglequotelinestart ( s )
763 return (s:gsub ("^'","'" ) )
764 end}
765 \luaexec{function frsinglequotesclose( s )
766 return ( s:gsub ( " '(..-)'", " ‹\\,\%1\\,›" ) )
767 end}
768
769 %% Two utility macros to activate/deactivate the Lua function:
770 \newcommand\frdoublequoteson{\directlua{luatexbase.add_to_callback (
771 "process_input_buffer" ,frdoublequotes , "frdoublequotes" )}}
772 \newcommand\frdoublequotesoff{\directlua{luatexbase.remove_from_callback (
773 "process_input_buffer" , "frdoublequotes" )}}
774 \newcommand\frsinglequotelinestarton{\directlua{luatexbase.add_to_callback (
775 "process_input_buffer" ,frsinglequotelinestart , "frsinglequotelinestart" )}}
776 \newcommand\frsinglequotelinestartoff{\directlua{luatexbase.remove_from_callback (
777 "process_input_buffer" , "frsinglequotelinestart" )}}
778 \newcommand\frsinglequotescloseon{\directlua{luatexbase.add_to_callback (
779 "process_input_buffer" ,frsinglequotesclose , "frsinglequotesclose" )}}
780 \newcommand\frsinglequotescloseoff{\directlua{luatexbase.remove_from_callback (
781 "process_input_buffer" , "frsinglequotesclose" )}}
782 \newcommand{\frsmartquotes}{\frdoublequoteson
783 \frsinglequotespon
784 \frsinglequotespcloseon
785 \frsinglequotelinestarton
786 \frsinglequotescloseon}
787 \newcommand{\frdumbquotes}{\frdoublequotesoff
788 \frsinglequotespoff
789 \frsinglequotespcloseoff
790 \frsinglequotelinestartoff
791 \frsinglequotescloseoff}
792 \DeclareOption{fr}{
793 \AtBeginDocument{\dechsmartquotes\dechdumbquotes\desmartquotes\dedumbquotes\degmsmartquotes\degmdumbquotes\smartquotes\dumbquotes\dumbquotes\frsmartquotes}
794 \renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}}
795
796
797 }
798
799 %%%%%%%%%%%%%%%%%%%%%%%%%%%
800 %%%%%%%%%%%%%%%%%%%%%%%%%%%
801 % Deutsch (Schweiz)
802 %%%%%%%%%%%%%%%%%%%%%%%%%%%
803 %%%%%%%%%%%%%%%%%%%%%%%%%%%
804 \luaexec{function dechdoublequotes ( s )
805 return ( s:gsub ( '"(..-)"' , "«\%1»" ) )
806 end}
807
808
809 \luaexec{function dechsinglequotelinestart ( s )
810 return (s:gsub ("^'","'" ) )
811 end}
812 \luaexec{function dechsinglequotesclose( s )
813 return ( s:gsub ( " '(..-)'", " ‹\%1›" ) )
814 end}
815 %% Two utility macros to activate/deactivate the Lua function:
816 \newcommand\dechdoublequoteson{\directlua{luatexbase.add_to_callback (
817 "process_input_buffer" ,dechdoublequotes , "dechdoublequotes" )}}
818 \newcommand\dechdoublequotesoff{\directlua{luatexbase.remove_from_callback (
819 "process_input_buffer" , "dechdoublequotes" )}}
820 \newcommand\dechsinglequotelinestarton{\directlua{luatexbase.add_to_callback (
821 "process_input_buffer" ,dechsinglequotelinestart , "dechsinglequotelinestart" )}}
822 \newcommand\dechsinglequotelinestartoff{\directlua{luatexbase.remove_from_callback (
823 "process_input_buffer" , "dechsinglequotelinestart" )}}
824 \newcommand\dechsinglequotescloseon{\directlua{luatexbase.add_to_callback (
825 "process_input_buffer" ,dechsinglequotesclose , "dechsinglequotesclose" )}}
826 \newcommand\dechsinglequotescloseoff{\directlua{luatexbase.remove_from_callback (
827 "process_input_buffer" , "dechsinglequotesclose" )}}
828 \newcommand{\dechsmartquotes}{\dechdoublequoteson
829 \dechsinglequotespon
830 \dechsinglequotespcloseon
831 \dechsinglequotelinestarton
832 \dechsinglequotescloseon}
833 \newcommand{\dechdumbquotes}{\dechdoublequotesoff
834 \dechsinglequotespoff
835 \dechsinglequotespcloseoff
836 \dechsinglequotelinestartoff
837 \dechsinglequotescloseoff}
838 \DeclareOption{dech}{
839 \AtBeginDocument{\desmartquotes\dedumbquotes\degmsmartquotes\degmdumbquotes\smartquotes\dumbquotes\dumbquotes\frsmartquotes\frdumbquotes\dechsmartquotes}
840 \renewcommand{\texttt}[1]{{\ttfamily\addfontfeature{RawFeature={+qtbye,-tlig}} #1}}
841
842
843 }
844
845
846 %%%%%%%%%%%%%%%%%%%%%%%%%%%
847 % Default option is English
848 %%%%%%%%%%%%%%%%%%%%%%%%%%%
849 %%%%%%%%%%%%%%%%%%%%%%%%%%%
850 \ExecuteOptions{en}%
851 \ProcessOptions*
852
853
854
855
856
857
858 \end{minted}
859 \section{Version History}
860 \subsection*{\normalfont\texttt{1.4.0}}
861 \ttfamily Added support for Swiss German options, on user request
862
863
864 \subsection*{\normalfont\texttt{1.3.0}}
865 \ttfamily 15 January 2023 fixed single quotes and parentheses
866
867
868 \subsection*{\normalfont\texttt{1.2.2}}
869 \ttfamily Added the "degm" option
870
871 \subsection*{\normalfont\texttt{1.2.1}}
872 \ttfamily Suspended automatic elision support due to implementation issues
873
874 \subsection*{\normalfont\texttt{1.1.0}}
875 \ttfamily 25 October 2022: Added support for elision
876
877
878 \subsection*{\normalfont\texttt{1.0.1}}
879
880
881
882 \ttfamily 30 August 2022: Further corrections to bug preventing non-English usage
883
884 \subsection*{\normalfont\texttt{1.0.1}}
885
886 \ttfamily 28 August 2022: Change bug preventing non-English usage
887
888
889 \subsection*{\normalfont\texttt{1.0.0}}
890
891 \ttfamily 21 August 2022: Package creation
892
893
894 \end{document}