| 1 |
\documentclass[12pt]{ltxdoc} |
| 2 |
%\documentclass{article} |
| 3 |
%\usepackage[utf8]{luainputenc} |
| 4 |
\usepackage{fontspec} |
| 5 |
\setmainfont[Ligatures=TeX]{Linux Libertine O} |
| 6 |
\usepackage[czech,english]{babel} |
| 7 |
\usepackage{luacode} |
| 8 |
\usepackage{amsfonts} |
| 9 |
%\usepackage[]{polyglossia} |
| 10 |
%\setmainlanguage{english} |
| 11 |
%\setotherlanguage{czech} |
| 12 |
%\usepackage{url} |
| 13 |
\usepackage{hyperref} |
| 14 |
%\input prevent-single |
| 15 |
%\usepackage[]{prevent-single} |
| 16 |
\usepackage[]{luavlna} |
| 17 |
%\input prevent-single |
| 18 |
%\def\preventsingledebugon{} |
| 19 |
\newenvironment{mycode}{ |
| 20 |
%\leavevmode% |
| 21 |
\medskip% |
| 22 |
\parindent=0pt% |
| 23 |
}{\medskip} |
| 24 |
|
| 25 |
\ifdefined\version\else |
| 26 |
\def\version{{{VERSION}}} |
| 27 |
\let\gitdate\date |
| 28 |
\fi |
| 29 |
|
| 30 |
\begin{document} |
| 31 |
\title{The \verb|luavlna| package} |
| 32 |
\author{Michal Hoftich (\url{[email protected]})\\Miro Hrončok (\url{[email protected]})} |
| 33 |
\date{Version \version\\\gitdate} |
| 34 |
\maketitle |
| 35 |
\tableofcontents |
| 36 |
\section{Introduction} |
| 37 |
|
| 38 |
|
| 39 |
This is a small package for Plain Lua\TeX and Lua\LaTeX. In some languages, like |
| 40 |
Czech or Polish, there should be no single letter words at the line |
| 41 |
end, according to the typographical norms. There exists some |
| 42 |
external commands (like \verb!vlna!) or packages (\verb!encxvlna! |
| 43 |
for enc\TeX, \verb!xevlna! for Xe\TeX, |
| 44 |
\verb!impnattypo! for Lua\LaTeX). %This package is for plain |
| 45 |
%lua\TeX and for lua\LaTeX. |
| 46 |
|
| 47 |
Another feature is inclusion of a non-breakable space after |
| 48 |
initials, like in personal names, after or before academic degrees |
| 49 |
and between numbers and units (SI and others). |
| 50 |
|
| 51 |
The code is modified version of Patrick Gundlach's answer on |
| 52 |
TeX.sx\footnote{\url{http://tex.stackexchange.com/a/28128/2891}}. |
| 53 |
The difference is that it is possible to specify which single letters |
| 54 |
should be taken into account for different languages. |
| 55 |
% The support for degrees and units was added as well. |
| 56 |
% The code works also for single letters at the beginning of the brackets. |
| 57 |
|
| 58 |
|
| 59 |
|
| 60 |
\section{Usage} |
| 61 |
|
| 62 |
The usage is simple: |
| 63 |
|
| 64 |
\begin{verbatim} |
| 65 |
\input ucode |
| 66 |
\uselanguage{czech} |
| 67 |
%% in the case of luacsplain, use instead: |
| 68 |
%% \chyph |
| 69 |
\input luavlna |
| 70 |
\preventsingledebugon |
| 71 |
\input luaotfload.sty |
| 72 |
\font\hello={name:Linux Libertine O:+rlig;+clig;+liga;+tlig} at 12pt |
| 73 |
\hsize=3in |
| 74 |
\hello |
| 75 |
Příliš žluťoučký kůň úpěl ďábelské ódy. |
| 76 |
Text s krátkými souhláskami a samohláskami i dalšími jevy |
| 77 |
z nabídky možností (v textu možnými). |
| 78 |
|
| 79 |
I začátek odstavce je třeba řešit, i když výskyt zalomení |
| 80 |
není pravděpodobný. |
| 81 |
|
| 82 |
Co třeba í znaky š diakritikou? |
| 83 |
|
| 84 |
Různé možnosti [v závorkách <i jiných znacích |
| 85 |
|
| 86 |
Podpora iniciál a titulů: M. J. Hegel, Ing. Běháková, Ph.D., Ž. Zíbrt, |
| 87 |
Ch. Borner. |
| 88 |
|
| 89 |
Podpora jednotek: 100,5 MN\cdot{}s, 100.5 kJ, 200 µA, $-1$ dag, |
| 90 |
12 MiB. |
| 91 |
|
| 92 |
Uvnitř matematiky by mělo být zpracování vypnuté: $k \in \mathbb N$. |
| 93 |
Pokračujeme v příkladu. |
| 94 |
|
| 95 |
\preventsingledebugoff |
| 96 |
\bye |
| 97 |
\end{verbatim} |
| 98 |
|
| 99 |
%\noindent\parbox{3in}{% |
| 100 |
|
| 101 |
\noindent |
| 102 |
\begin{minipage}{3in} |
| 103 |
\preventsingledebugon |
| 104 |
\selectlanguage{czech} |
| 105 |
Příliš \textit{žluťoučký kůň} úpěl ďábelské ódy. |
| 106 |
Text s krátkými souhláskami a samohláskami i dalšími jevy z nabídky možností (v textu možnými). |
| 107 |
|
| 108 |
I začátek odstavce je třeba řešit, i když výskyt zalomení není pravděpodobný. |
| 109 |
|
| 110 |
Co třeba í znaky š diakritikou? |
| 111 |
|
| 112 |
Různé možnosti [v závorkách \textless i jiných znacích |
| 113 |
|
| 114 |
Podpora iniciál a titulů: M. J. Hegel, Ing. Běháková, Ph.D., Ž. Zíbrt, Ch. Borner. |
| 115 |
|
| 116 |
Podpora jednotek: 100,5 MN\cdot{}s, 100.5 kJ, 200 µA, $-1$ dag, 12 MiB. |
| 117 |
|
| 118 |
Uvnitř matematiky by mělo být zpracování vypnuté: $k \in \mathbb N$. Pokračujeme v příkladu. |
| 119 |
|
| 120 |
\preventsingledebugoff |
| 121 |
%} |
| 122 |
\end{minipage} |
| 123 |
|
| 124 |
\selectlanguage{english} |
| 125 |
\bigskip |
| 126 |
It is also possible to use the package with Lua\LaTeX, just use |
| 127 |
|
| 128 |
\begin{verbatim} |
| 129 |
\usepackage{luavlna} |
| 130 |
\end{verbatim} |
| 131 |
|
| 132 |
in the preamble. |
| 133 |
|
| 134 |
\section{Package options} |
| 135 |
The \verb|luavlna| package recognizes the following options |
| 136 |
|
| 137 |
\begin{description} |
| 138 |
\item[\texttt{noprocess}] -- disable the automatic document processing. |
| 139 |
\item[\texttt{noinitials}] -- disable processing of the initials. |
| 140 |
\item[\texttt{nounits}] -- disable processing of the SI units. |
| 141 |
\item[\texttt{nopredegrees}] -- disable processing of the the academic degrees before names. |
| 142 |
\item[\texttt{nosufdegrees}] -- disable processing of the the academic degrees after names. |
| 143 |
\item[\texttt{debug}] -- enable the debugging mode. |
| 144 |
\item[\texttt{defaults}] -- load default settings. Enabled by default. |
| 145 |
\end{description} |
| 146 |
|
| 147 |
|
| 148 |
\section{Default values} |
| 149 |
|
| 150 |
Luavlna defines default settings for Czech and Slovak. If you want to disable them, |
| 151 |
you can use the \texttt{defaults=false} option for Luavlna package. In Plain Lua\TeX{}, |
| 152 |
use: |
| 153 |
|
| 154 |
\begin{mycode} |
| 155 |
\begin{verbatim} |
| 156 |
\let\nosingledefaults\relax |
| 157 |
\input luavlna |
| 158 |
\end{verbatim} |
| 159 |
\end{mycode} |
| 160 |
|
| 161 |
\section{Commands} |
| 162 |
|
| 163 |
\begin{mycode} |
| 164 |
\cmd{\singlechars}\marg{language name}\marg{letters} |
| 165 |
\end{mycode} |
| 166 |
|
| 167 |
Enable this feature for certain letters in given language. |
| 168 |
%Language code is internall \TeX\ code for the language, it is $0$ for English, |
| 169 |
%$16$ for Czech. Please note that in \verb|csplain|, language code for Czech |
| 170 |
%is $5$ and you will have to set it yourself. |
| 171 |
|
| 172 |
Default values: |
| 173 |
|
| 174 |
\begin{mycode} |
| 175 |
\begin{verbatim} |
| 176 |
%% only Czech and Slovak are supported out of the box |
| 177 |
\singlechars{czech}{AIiVvOoUuSsZzKk} |
| 178 |
\singlechars{slovak}{AIiVvOoUuSsZzKk} |
| 179 |
\end{verbatim} |
| 180 |
\end{mycode} |
| 181 |
|
| 182 |
|
| 183 |
%By default, all |
| 184 |
%single letters are processed, this command can be used to pass a |
| 185 |
%string of characters, which should be processed only. |
| 186 |
|
| 187 |
\begin{mycode} |
| 188 |
\cmd{\compoundinitials}\marg{language name}\marg{compounds} |
| 189 |
\end{mycode} |
| 190 |
|
| 191 |
Declare compound letters for given language. Second argument should be comma |
| 192 |
separated list of compound letters, in exact form in which they can appear. |
| 193 |
|
| 194 |
Default values: |
| 195 |
|
| 196 |
\begin{mycode} |
| 197 |
\begin{verbatim} |
| 198 |
\compoundinitials{czech}{Ch,CH} |
| 199 |
\end{verbatim} |
| 200 |
\end{mycode} |
| 201 |
|
| 202 |
|
| 203 |
\subsection{Split hyphens} |
| 204 |
|
| 205 |
The hyphenated words like ``je-li'' should be be hyphenated as ``je-/-li`` |
| 206 |
according to the Czech typesetting rules. This behaviour can be enabled or disabled for a particular |
| 207 |
language using the following commands: |
| 208 |
|
| 209 |
\begin{mycode} |
| 210 |
\cmd{\enablesplithyphens}\marg{language name}\\ |
| 211 |
\cmd{\disablesplithyphens}\marg{language name} |
| 212 |
\end{mycode} |
| 213 |
|
| 214 |
By default, it is enabled for the Czech language. |
| 215 |
|
| 216 |
Example in action: |
| 217 |
|
| 218 |
\begin{minipage}{3in} |
| 219 |
\selectlanguage{czech} |
| 220 |
Sedlec-Prčice, modro-zelený, překladatel-tlumočník, kuchař-číšník, propan-butan, |
| 221 |
Otýlie Sklenářová-Malá, František Jílek-Oberpfalcer. |
| 222 |
\selectlanguage{english} |
| 223 |
\end{minipage} |
| 224 |
|
| 225 |
The similar behaviour can be achieved using the \verb|\splithyphens| command |
| 226 |
provided by Czech langauge definitions for the Babel package, but it's use is |
| 227 |
discouraged. It prevents use ot the hyphen character in many situations. The |
| 228 |
solution provided by Luavlna should be safe. |
| 229 |
|
| 230 |
|
| 231 |
\subsection{Turning off language switching} |
| 232 |
|
| 233 |
By default, language of the nodes is taken into account. If you want to use |
| 234 |
settings for one language for a whole document, you can use following command: |
| 235 |
|
| 236 |
\begin{mycode} |
| 237 |
\cmd{\preventsinglelang}\marg{language name} |
| 238 |
\end{mycode} |
| 239 |
|
| 240 |
\subsection{Turning off processing} |
| 241 |
|
| 242 |
If you want to stop the processing of spaces in the document you can use the following command: |
| 243 |
|
| 244 |
\begin{mycode} |
| 245 |
\cmd{\preventsingleoff} |
| 246 |
\end{mycode} |
| 247 |
|
| 248 |
To resume processing, use |
| 249 |
|
| 250 |
\begin{mycode} |
| 251 |
\cmd{\preventsingleon} |
| 252 |
\end{mycode} |
| 253 |
|
| 254 |
You can also disable initials, units and degrees processing: |
| 255 |
|
| 256 |
\begin{mycode} |
| 257 |
\cmd{\noinitials}\\ |
| 258 |
\cmd{\nounits}\\ |
| 259 |
\cmd{\nopredegrees}\\ |
| 260 |
\cmd{\nosufdegrees} |
| 261 |
\end{mycode} |
| 262 |
|
| 263 |
|
| 264 |
\subsection{Debugging commands} |
| 265 |
\begin{mycode} |
| 266 |
\cmd{\preventsingledebugon}\par |
| 267 |
\cmd{\preventsingledebugoff} |
| 268 |
\end{mycode} |
| 269 |
|
| 270 |
Insert debugging marks on/off. Default off. |
| 271 |
|
| 272 |
\section{Lua module \texttt{luavlna-langno.lua}} |
| 273 |
|
| 274 |
When we process glyph nodes with Lua\TeX\ callbacks, there are \verb|lang| |
| 275 |
fields available. These are numerical codes of languages, but no information |
| 276 |
about language names easily accesible from Lua side is available.\footnote{% |
| 277 |
Language names are stored in \TeX macros like \verb|\string\l@langname|, but |
| 278 |
different formats use different naming of these macros} |
| 279 |
These numbers are format dependent, majority of formats like |
| 280 |
Lua\LaTeX use \verb|language.dat| file provided by \verb|babel| |
| 281 |
for assign numbers to languages, but for example \verb|csplain| |
| 282 |
use its own system. |
| 283 |
|
| 284 |
To allow easy setting of language dependent parameters, \verb|langno| module |
| 285 |
was created. It's purpose is to translate language code to language name and |
| 286 |
the other way. Lua\LaTeX, Lua\TeX\ and CSplain formats are supported at the moment. |
| 287 |
|
| 288 |
\subsection{Recognized languages} |
| 289 |
\subsubsection{Lua\TeX\ and Lua\LaTeX} |
| 290 |
|
| 291 |
File \verb|language.dat| is processed to load language names, aliases and assigned numbers. These language names are the same as names supported by the \verb|babel| package. |
| 292 |
|
| 293 |
\begin{quotation} |
| 294 |
\small\noindent |
| 295 |
\begin{luacode*} |
| 296 |
langno = require "luavlna-langno" |
| 297 |
function print_format_lang(fmt) |
| 298 |
local luatex = langno.load_languages(fmt) |
| 299 |
local t = {} |
| 300 |
for k, v in pairs(luatex.names) do |
| 301 |
if k and k~="" then |
| 302 |
t[#t+1]=k |
| 303 |
end |
| 304 |
end |
| 305 |
table.sort(t) |
| 306 |
tex.print(table.concat(t,", ")) |
| 307 |
end |
| 308 |
print_format_lang("luatex") |
| 309 |
\end{luacode*} |
| 310 |
\end{quotation} |
| 311 |
|
| 312 |
\subsubsection{CSplain} |
| 313 |
|
| 314 |
Different method is used with the CSplain format. The \verb|lua-hyphen.lan| file is parsed for the language codes. |
| 315 |
|
| 316 |
\begin{quotation} |
| 317 |
\small\noindent |
| 318 |
\begin{luacode*} |
| 319 |
print_format_lang("csplain") |
| 320 |
\end{luacode*} |
| 321 |
\end{quotation} |
| 322 |
|
| 323 |
|
| 324 |
\section{License} |
| 325 |
|
| 326 |
Permission is granted to copy, distribute and/or modify this software |
| 327 |
under the terms of the LaTeX Project Public License, version 1.3. |
| 328 |
|
| 329 |
\end{document} |