| 1 |
% \iffalse meta comment |
| 2 |
% !TEX encoding = UTF-8 Unicode |
| 3 |
% !TEX TS-program = lualatex |
| 4 |
|
| 5 |
%<*internal> |
| 6 |
\begingroup |
| 7 |
\input docstrip.tex |
| 8 |
\keepsilent |
| 9 |
\preamble |
| 10 |
Copyright 2025 Claudio Beccari All rights reserved. |
| 11 |
|
| 12 |
This system is distributed in the hope that it will |
| 13 |
be useful, but WITHOUT ANY WARRANTY; without even |
| 14 |
the implied warranty of MERCHANTABILITY or FITNESS |
| 15 |
FOR A PARTICULAR PURPOSE. |
| 16 |
|
| 17 |
This file is distributed under the LPPL licence, |
| 18 |
version 1.3c dated 2008-05-04 or later as it appears |
| 19 |
in CTAN/macros/latex/base/lppl.tex. |
| 20 |
See the end of this file. |
| 21 |
|
| 22 |
\endpreamble |
| 23 |
\askforoverwritefalse |
| 24 |
% |
| 25 |
\generateFile{testhyphens.sty}{f}{\from{testhyphens.dtx}{package}} |
| 26 |
|
| 27 |
\def\tmpa{plain} |
| 28 |
\ifx\tmpa\fmtname\endgroup\expandafter\bye\fi |
| 29 |
\endgroup |
| 30 |
%</internal> |
| 31 |
% \fi |
| 32 |
% |
| 33 |
% \iffalse |
| 34 |
%^^A The following trick uses the same date for every file header. |
| 35 |
%<package>\NeedsTeXFormat{LaTeX2e} |
| 36 |
%<*driver> |
| 37 |
\ProvidesFile{testhyphens.dtx}[% |
| 38 |
%</driver> |
| 39 |
%<package>\ProvidesPackage{testhyphens}[% |
| 40 |
%<*driver,package> |
| 41 |
2025/01/16 v.1.0 |
| 42 |
%<package>Prints list of hyphenated words] |
| 43 |
%</driver,package> |
| 44 |
%<*driver> |
| 45 |
] |
| 46 |
%</driver> |
| 47 |
%<*driver> |
| 48 |
\documentclass{ltxdoc} |
| 49 |
\GetFileInfo{testhyphens.dtx} |
| 50 |
\title{The \textsf{testhyphens} package\\[3mm] |
| 51 |
{\Large Version number \fileversion, last |
| 52 |
revised on \filedate.}} |
| 53 |
\author{Claudio Beccari\\ |
| 54 |
email: claudio(dot)beccari(at)gmail(dot)com} |
| 55 |
\date{} |
| 56 |
\providecommand\babel{\pack{babel}} |
| 57 |
\newcommand\lbr{\char123\relax} |
| 58 |
\newcommand\rbr{\char125\relax} |
| 59 |
% |
| 60 |
\renewcommand*\meta[1]{{\normalfont\textlangle\textit{#1}\textrangle}} |
| 61 |
\newcommand*\pack[1]{\textsf{#1}} |
| 62 |
\newcommand*\prog[1]{\texttt{#1}} |
| 63 |
\providecommand*\marg[1]{{\normalfont\texttt{\{}\meta{#1}\texttt{\}}}}\let\Arg\marg |
| 64 |
\renewcommand*\oarg[1]{\texttt{[}\meta{#1}\texttt{]}} |
| 65 |
\newcommand\amb[1]{\texttt{\itshape#1}} |
| 66 |
\usepackage{multicol} |
| 67 |
\usepackage{iftex} |
| 68 |
% |
| 69 |
\ifpdftex% |
| 70 |
\usepackage[utf8]{inputenc} |
| 71 |
\usepackage[LGR,T1]{fontenc} |
| 72 |
\usepackage{lmodern,textcomp} |
| 73 |
\usepackage[greek,italian,english]{babel} |
| 74 |
\else |
| 75 |
\usepackage{fontspec} |
| 76 |
\usepackage{polyglossia} |
| 77 |
\setotherlanguage[variant=mono]{greek} |
| 78 |
\setmainlanguage{english} |
| 79 |
\setotherlanguage{italian} |
| 80 |
\usepackage[default]{fontsetup} |
| 81 |
\fi |
| 82 |
|
| 83 |
\usepackage{metalogo,FramedSyntax} |
| 84 |
\usepackage{testhyphens} |
| 85 |
% |
| 86 |
\begin{document} |
| 87 |
\maketitle |
| 88 |
\DocInput{testhyphens.dtx} |
| 89 |
\end{document} |
| 90 |
%</driver> |
| 91 |
% \fi |
| 92 |
% |
| 93 |
% \begin{abstract} |
| 94 |
% This small file implements some code that was |
| 95 |
% already published on TUGboat, but it is adapted |
| 96 |
% to \LaTeX\ engines, and it is usable as a |
| 97 |
% specific environment. |
| 98 |
% It helps those \TeX{}ers who create hyphenation |
| 99 |
% patterns, as well normal \LaTeX\ users, in order |
| 100 |
% to test the correctness of the hyphenation points |
| 101 |
% of words lists. |
| 102 |
% It works with \pack{pdflatex}, \prog{xelatex}, and |
| 103 |
% \prog{lualatex}. |
| 104 |
% \end{abstract} |
| 105 |
% |
| 106 |
%{\columnseprule=0.4pt |
| 107 |
%\begin{multicols}{2} |
| 108 |
%\tableofcontents |
| 109 |
%\end{multicols}} |
| 110 |
% |
| 111 |
% \section{Introduction} |
| 112 |
% |
| 113 |
% This small package introduces the environment |
| 114 |
% |checkhyphens|. This environment may set the |
| 115 |
% hyphenation parameters to any specific values, |
| 116 |
% even different from those setup for the language |
| 117 |
% in use; it processes a list of one or more space |
| 118 |
% delimited words typesetting them one per line with |
| 119 |
% hyphens between each syllable. If typesetting |
| 120 |
% this list takes place within a \amb{multicolulmn} |
| 121 |
% environment, it renders much easier to read long |
| 122 |
% lists. |
| 123 |
% |
| 124 |
% The hyphenation patterns of a specific language |
| 125 |
% to be tested, may be those of the default |
| 126 |
% language before entering the environment, or can |
| 127 |
% be those of another language specified with |
| 128 |
% |\selectlanguage| within the environment. |
| 129 |
% |
| 130 |
% The environment \amb{checkhyphens} accepts also an |
| 131 |
% optional argument to set the hyphenation |
| 132 |
% parameters, and a body consisting of a list |
| 133 |
% of one or more space separated words; if the |
| 134 |
% user just pastes a text copied from somewhere that |
| 135 |
% includes punctuation, the punctuation signs are |
| 136 |
% ignored, but are not taken off from the printed |
| 137 |
% list. |
| 138 |
% |
| 139 |
% The main code was published long ago by Victor |
| 140 |
% Eijkout, in “The bag of tricks”, \textsf{\slshape |
| 141 |
% TUGboat} 14.4 (1993), p. 424. He himself states |
| 142 |
% that the code was created by Jonathan Kew; Victor |
| 143 |
% Eijkout just added an empty |
| 144 |
% |\discretionary{}{}{}|. The idea came to him from |
| 145 |
% the code created by Oliver Schoett that is used |
| 146 |
% for the hyphenation exception list of TUGboat. |
| 147 |
% Credit for the code goes completely to the |
| 148 |
% authors mentioned above; I just added some sugar |
| 149 |
% to use that code in \LaTeX\ documents for the |
| 150 |
% benefit of hyphenation pattern creators, and of |
| 151 |
% regular users who want to know how a certain word |
| 152 |
% or the words of a certain sentence would be |
| 153 |
% hyphenated by \TeX\ and friends. |
| 154 |
% |
| 155 |
% In 2018 a small extension package \pack{xltxtra} |
| 156 |
% by Will Robertson was added to the \TeX\ system |
| 157 |
% distribution that contains some fixes and |
| 158 |
% facilities to be used when typesetting with |
| 159 |
% \XeLaTeX; it contains the definition of the macro |
| 160 |
% \cs{showhyphens} macro; this macro was provided by |
| 161 |
% Enrico Gregorio; it is supposed to show the |
| 162 |
% hyphenation of a small word list when using |
| 163 |
% \XeLaTeX; unfortunately in these years, up to |
| 164 |
% 2024, \LaTeX\ has undergone so many changes that |
| 165 |
% this macro does not work any more, except perhaps |
| 166 |
% with few selected languages. |
| 167 |
% |
| 168 |
% Of course this package does not tell the whole |
| 169 |
% truth: in facts \TeX\ and friends hyphenate words |
| 170 |
% only when certain conditions are met; these |
| 171 |
% conditions are stated in Appendix~H of the |
| 172 |
% \TeX\-book, which is and remains the primary |
| 173 |
% reference for understanding the hyphenation |
| 174 |
% process used by \TeX\ and friends. |
| 175 |
|
| 176 |
% Sometimes users complain that certain words |
| 177 |
% are not hyphenated; users might use this package |
| 178 |
% and find out how their words are hyphenated; then |
| 179 |
% what's happening if they are not hyphenated the |
| 180 |
% right way? Simply those conditions are not met. |
| 181 |
% Therefore the full understanding of the above |
| 182 |
% mentioned Appendix~H is fundamental before |
| 183 |
% complaining about \TeX\ not working as expected |
| 184 |
% with hyphenation and possibly before raising a bug |
| 185 |
% notice. |
| 186 |
% |
| 187 |
% \section{Incompatibility with the previous |
| 188 |
% version 0.5a} |
| 189 |
% |
| 190 |
% In 2015 I had to change some definitions within |
| 191 |
% the body of this package in order to avoid |
| 192 |
% clashes mainly with the |french| language option |
| 193 |
% of babel; in facts that option declares most |
| 194 |
% punctuation marks as active characters. |
| 195 |
% Unfortunately those characters receive global |
| 196 |
% definitions, therefore they remain active even |
| 197 |
% when they should not perform any action. |
| 198 |
% |
| 199 |
% It is necessary to specify that the previous |
| 200 |
% version used the colon as a parameter separator; |
| 201 |
% while, in order to avoid conflicts with |french|, |
| 202 |
% now the parameter separator is a simple hyphen. |
| 203 |
% |
| 204 |
% Defining active characters when using |
| 205 |
% |polyglossia| may produce other incompatibilities |
| 206 |
% that are easily circumvented by specifying |
| 207 |
% languages in a different order. In facts, if you |
| 208 |
% specify languages as such |
| 209 |
%\begin{verbatim} |
| 210 |
%\setmainlanguage[babelshorthands]{italian} |
| 211 |
%\setotherlanguages{english,french} |
| 212 |
%\end{verbatim} |
| 213 |
% an error appears when |french| sets up its |
| 214 |
% parameters for the UNICODE apostrophe: the cause |
| 215 |
% of this error derives from the use of the |
| 216 |
% |italian| option |babelshorthands|; of course if |
| 217 |
% this option is not specified, no problems arise. |
| 218 |
% But if you interchange the declarations as in |
| 219 |
%\begin{verbatim} |
| 220 |
%\setotherlanguages{english,french} |
| 221 |
%\setmainlanguage[babelshorthands]{italian} |
| 222 |
%\end{verbatim} |
| 223 |
% no problems arise. |
| 224 |
% |
| 225 |
% \section{Changes from version 0.7} |
| 226 |
% |
| 227 |
% When version 0.7 was published, command |
| 228 |
% \cs{testhyphens} worked regularly also with |
| 229 |
% \XeLaTeX; this new version maintains the |
| 230 |
% environment \amb{checkhyphens}, but lets down |
| 231 |
% \cs{texthyphens} because this command raised |
| 232 |
% errors that I was not able to repair. Something |
| 233 |
% was changed in the \XeLaTeX\ format file that I |
| 234 |
% could not spot. |
| 235 |
% |
| 236 |
% Never mind: in 2015 the environment was more |
| 237 |
% effective than the command, and it survives in |
| 238 |
% this new version with all its power. |
| 239 |
% |
| 240 |
% \section{Usage} |
| 241 |
% This package has been tested with |pdflatex|, |
| 242 |
% |xelatex|, and |lualatex|; for |lualatex| a |
| 243 |
% package |showhyphens| exists that marks the hyphen |
| 244 |
% points of an entire document with thin red |
| 245 |
% vertical strokes at the possible break points. |
| 246 |
% Users may use the package they prefer by taking |
| 247 |
% into consideration their needs with respect with |
| 248 |
% the features and the functionalities of package |
| 249 |
% \pack{testhyphens} compared to those of |
| 250 |
% \pack{showhyphens}. |
| 251 |
% |
| 252 |
% Notice that even normal Plain \TeX\ and \LaTeX\ |
| 253 |
% have available the command |\showhyphens| but, |
| 254 |
% differently from this package, such command works |
| 255 |
% only when the typesetting engine is |tex| or |
| 256 |
% |pdftex|; moreover the result appears on the |
| 257 |
% console window and in the \texttt{.log} file |
| 258 |
% and it is not written down in the output document |
| 259 |
% as a record that remains available to the user. |
| 260 |
% This package |testhyphens|, on the opposite, |
| 261 |
% prints the result in the output document and works |
| 262 |
% with the typesetting engines |pdftex|, |xetex|, |
| 263 |
% and |luatex| as expected. |
| 264 |
% |
| 265 |
% This simple package is loaded just with the usual |
| 266 |
% statement |
| 267 |
% \begin{flushleft} |
| 268 |
%|\usepackage{testhyphens}| |
| 269 |
% \end{flushleft} |
| 270 |
% |
| 271 |
% The package new version defines for the end user |
| 272 |
% just the environment \amb{checkhyphens}: its |
| 273 |
% syntax is the following: |
| 274 |
%\begin{Sintassi} |
| 275 |
% |\begin{checkhyphens}|\oarg{hyphenation parameters} |
| 276 |
%\meta{space separated word list} |
| 277 |
% |\end{checkhyphens}| |
| 278 |
%\end{Sintassi} |
| 279 |
% where \meta{hyphenation parameters} is a |
| 280 |
% \emph{hyphen separated list} of two digits that in |
| 281 |
% order will be locally assigned by the environment |
| 282 |
% respectively to |\lefthyphenmin| and |
| 283 |
% |\righthyphenmin|; the \meta{space separated word |
| 284 |
% list} is self explanatory. Nevertheless it is good |
| 285 |
% to remember that the environment isolates single |
| 286 |
% words by using a space as a word separator; this |
| 287 |
% requires that the list is preceded and followed |
| 288 |
% by spaces or end of lines, Actually the initial |
| 289 |
% and final spaces are necessary when the opening |
| 290 |
% statement is on the same source line of the first |
| 291 |
% word and the closing statement is in the same |
| 292 |
% source line of the last word. |
| 293 |
% |
| 294 |
% \section[Hyphenation parameters]{Using hyphenation parameters} |
| 295 |
% |
| 296 |
% The hyphenation parameters are just |
| 297 |
% |\lefthyphenmin| and |\righthyphenmin|; they |
| 298 |
% represent the minimum number of characters that |
| 299 |
% the first and, respectively, the last word |
| 300 |
% fragment must have before or until hyphenation |
| 301 |
% takes place; for example in English the default |
| 302 |
% values are 2 and~3; in Italian the default values |
| 303 |
% are 2 and~2; in Greek the default values are |
| 304 |
% 1 and~1. |
| 305 |
% |
| 306 |
% Let us make an example: the word \emph{idea} is |
| 307 |
% spelt the same in English and in Italian, although |
| 308 |
% it is pronounced differently; but |
| 309 |
% the word is not hyphenated at all in both |
| 310 |
% languages. According to the Italian |
| 311 |
% syllabification rules its grammatical word |
| 312 |
% division is \emph{i-de-a}; in American English |
| 313 |
% the grammatical word division is the same; in any |
| 314 |
% case the initial and the terminal syllables are |
| 315 |
% too short to comply with the above mentioned |
| 316 |
% \TeX\ hyphenation parameters, and \TeX\ refrains |
| 317 |
% from hyphenating this word. On the opposite, in |
| 318 |
% Greek \foreignlanguage{greek}{ιδέα} is hyphenated |
| 319 |
% by \TeX\ as \foreignlanguage{greek}{ι-δέ-α}. |
| 320 |
% |
| 321 |
% If you use \amb{checkhyphens} with the optional |
| 322 |
% hyphenation parameters specified to 1 and~1 in |
| 323 |
% Italian or in English, as in |
| 324 |
%\begin{verbatim} |
| 325 |
%\begin{checkhyphens}[1-1] |
| 326 |
%idea |
| 327 |
%\end{checkhyphens} |
| 328 |
%\end{verbatim} |
| 329 |
% you don't get any hyphenation in English; but in |
| 330 |
% Italian hyphenation turns out to be \emph{i-de-a} |
| 331 |
% as in Greek. |
| 332 |
% |
| 333 |
% This happens because the Italian patterns were |
| 334 |
% created by hand and tested with parameters |
| 335 |
% 1 and~1, even if for typesetting purposes the |
| 336 |
% parameters are set to 2 and~2. In English the |
| 337 |
% patterns were created by means of the |
| 338 |
% \prog{patgen} program where parameters 2 and~3 |
| 339 |
% were set. |
| 340 |
% |
| 341 |
% Typographically speaking the values 1 and~1 for |
| 342 |
% Italian are almost useless, but in certain |
| 343 |
% difficult narrow-measure texts the user has the |
| 344 |
% possibility to locally set the first and/or the |
| 345 |
% second parameter to 1, and solve that particular |
| 346 |
% instance of problematic narrow-measure |
| 347 |
% typesetting. |
| 348 |
% |
| 349 |
% \section{Examples} |
| 350 |
% Here we show some actual examples by using the |
| 351 |
% \amb{checkhyphens} environment. |
| 352 |
% |
| 353 |
% While typesetting in English we might verify the |
| 354 |
% hyphenation of some words. |
| 355 |
% We set the source file with the following lines |
| 356 |
% %\begin{verbatim} |
| 357 |
%\begin{{chechhyphens} |
| 358 |
%manifests instruments |
| 359 |
%he analyses the samples and submits the analyses to the federal office |
| 360 |
%\end{checkhyphens} |
| 361 |
%\end{verbatim} |
| 362 |
% The result produced by this package, typeset |
| 363 |
% within a four-column \amb{multicols} environment, |
| 364 |
% is the following: |
| 365 |
% |
| 366 |
%\begin{multicols}{4} |
| 367 |
%\begin{checkhyphens} |
| 368 |
%he analyses the samples and submits the analyses to the federal office |
| 369 |
%\end{checkhyphens} |
| 370 |
%\end{multicols} |
| 371 |
% Notice the two instances of the word |analyses|; |
| 372 |
% in English \TeX\ hyphenates them the same way, but |
| 373 |
% one of the two words is hyphenated the wrong way; |
| 374 |
% unfortunately there is no way for \TeX\ to |
| 375 |
% distinguish homographic words that are not |
| 376 |
% homophonic ones. In plain terms the verb |
| 377 |
% “analyses” is stressed on the `y', while the noun |
| 378 |
% “analyses” is stressed on the second `a'; |
| 379 |
% the standard phonetic hyphenation rules for |
| 380 |
% English probably should hyphenate the verb as |
| 381 |
% “an-a-lyses”, but \TeX\ works only on the spelling |
| 382 |
% and not on the sound; furthermore it has no means |
| 383 |
% to find out if a word plays the rôle of a noun or |
| 384 |
% of a verb. |
| 385 |
% In this and similar situations (for example: “the |
| 386 |
% record” and “to record”) the user should |
| 387 |
% check a good reliable dictionary and possibly |
| 388 |
% insert an explicit discretionary hyphen~|\-|. |
| 389 |
% A good although oldish such dictionary would be |
| 390 |
% the \emph{Webster's New Word Speller divider} --- |
| 391 |
% The 33\,000 most used words spelled and |
| 392 |
% syllabified. World \& Collins World, (1971). |
| 393 |
% |
| 394 |
% In Italian any grammar book states the rules that |
| 395 |
% are valid for all Latin derived words and are |
| 396 |
% applicable also to technical scientific words, |
| 397 |
% although a phonetic hyphenation is allowed and |
| 398 |
% is more more adequate to the context; words |
| 399 |
% derived from Greek (very common in medicine) and |
| 400 |
% neologisms with foreign roots, do not find |
| 401 |
% specific rules either in grammars and in most |
| 402 |
% dictionaries; or better, if a word ends with one |
| 403 |
% or more consonants, this consonantic group must |
| 404 |
% not be separated from the word last vowel. |
| 405 |
% |
| 406 |
% While typesetting in Italian it is possible to |
| 407 |
% insert into the source file a set of lines such as |
| 408 |
% these: |
| 409 |
%\begin{verbatim} |
| 410 |
%\begin{checkhyphens} |
| 411 |
%ebbe la bell’idea di viaggiare in scooter |
| 412 |
%\end{checkhyphens} |
| 413 |
%\end{verbatim} |
| 414 |
% that produces the following result: |
| 415 |
%\begin{multicols}{4} |
| 416 |
%\begin{otherlanguage*}{italian} |
| 417 |
%\begin{checkhyphens} |
| 418 |
%ebbe la bell’idea di viaggiare in scooter |
| 419 |
%\end{checkhyphens} |
| 420 |
%\end{otherlanguage*}\end{multicols} |
| 421 |
% Notice that “idea” cannot be hyphenated by \TeX\ |
| 422 |
% when it is an isolated word; but in Italian the |
| 423 |
% apostrophe is used (also) to mark a vocalic |
| 424 |
% elision, therefore for hyphenation purposes, even |
| 425 |
% if it is not a letter, it is assigned a lowercase |
| 426 |
% code, and it becomes part of a word, in |
| 427 |
% our case the word string “bell'idea”. Therefore |
| 428 |
% the patterns that involve the apostrophe produce |
| 429 |
% the result shown above, where the first |
| 430 |
% grammatical hyphen point shows up |
| 431 |
% again\footnote{This is so with \prog{xelatex}; in |
| 432 |
% \prog{lualatex} the apostrophe is not assigned a |
| 433 |
% a lowercase code, therefore with |
| 434 |
% \prog{lualatex} “bell'idea” is not hyphenated at |
| 435 |
% all; it would be if the Unicode single upper |
| 436 |
% quotation mark was used instead of the |
| 437 |
% \textsc{ascii} character available with any |
| 438 |
% keyboard: “bell’idea”. These characters look the |
| 439 |
% same (at least with some OpenType fonts) but have |
| 440 |
% different Unicode code points.}. |
| 441 |
% |
| 442 |
% While typesetting in Greek we might insert in the |
| 443 |
% source file the following code: |
| 444 |
%\begin{flushleft}\ttfamily\obeylines |
| 445 |
%|\begin{checkhyphens}[1-1]| |
| 446 |
%\begin{otherlanguage*}{greek} |
| 447 |
% επεξεργάζεται αρχεία τα οποία περιέχουν τους |
| 448 |
% χαρακτήρες που υπάρχουν στο πληκτρολόγιο του |
| 449 |
% υπολογιστή σας |
| 450 |
%\end{otherlanguage*} |
| 451 |
%|\end{checkhyphens}| |
| 452 |
%\end{flushleft} |
| 453 |
%and we would get: |
| 454 |
%\begin{multicols}{4} |
| 455 |
%\begin{otherlanguage*}{greek} |
| 456 |
%\begin{checkhyphens}[1-1] |
| 457 |
%επεξεργάζεται αρχεία τα οποία περιέχουν τους χαρακτήρες που υπάρχουν |
| 458 |
%στο πληκτρολόγιο του υπολογιστή σας |
| 459 |
%\end{checkhyphens} |
| 460 |
%\end{otherlanguage*}\end{multicols} |
| 461 |
%\noindent while, had we set the hyphenation parameters different from the default |
| 462 |
% values 1~and~1, as in: |
| 463 |
%\begin{flushleft}\ttfamily\obeylines |
| 464 |
%|\begin{checkhyphens}[2-2]| |
| 465 |
%\begin{otherlanguage*}{greek} |
| 466 |
%επεξεργάζεται αρχεία τα οποία περιέχουν τους |
| 467 |
% χαρακτήρες που υπάρχουν στο πληκτρολόγιο του |
| 468 |
% υπολογιστή σας |
| 469 |
%\end{otherlanguage*} |
| 470 |
%|\end{checkhyphens}| |
| 471 |
%\end{flushleft} |
| 472 |
%the result would be: |
| 473 |
%\begin{multicols}{4} |
| 474 |
%\begin{otherlanguage*}{greek} |
| 475 |
%\begin{checkhyphens}[2-2] |
| 476 |
%επεξεργάζεται αρχεία τα οποία περιέχουν τους χαρακτήρες που υπάρχουν |
| 477 |
%στο πληκτρολόγιο του υπολογιστή σας |
| 478 |
%\end{checkhyphens} |
| 479 |
%\end{otherlanguage*} |
| 480 |
%\end{multicols} |
| 481 |
% |
| 482 |
% The pattern files for monotonic Greek used in |
| 483 |
% these examples were rebuilt with Greek letters -- |
| 484 |
% avoiding the Latin transliteration originally |
| 485 |
% used with the Latin Modern conformant Greek fonts |
| 486 |
% encoded with the \texttt{LGR} encoding; that was |
| 487 |
% done for the benefit of non-Greek Hellenists who |
| 488 |
% would use their Latin national keyboards. The |
| 489 |
% above mentioned upgrading was done by Dimitrios |
| 490 |
% Filippou in 2011; since then no modifications were |
| 491 |
% added, except for the patterns to be used with |
| 492 |
% \prog{xelatex} and \prog{lualatex}. |
| 493 |
% |
| 494 |
% For OpenType fonts Antonis Tsolomitis |
| 495 |
% produced a new font set that assembles the Latin |
| 496 |
% Modern Fonts together with the CBfonts and some |
| 497 |
% Cyrillic ones and other fonts for several other |
| 498 |
% scripts; this remarkable pretty complete |
| 499 |
% OpenType font is named “New Computer Modern” |
| 500 |
% (documentation with \texttt{texdoc NewCM}) that |
| 501 |
% uses the \pack{fontsetup} package for selecting |
| 502 |
% its varieties; this package is described by the |
| 503 |
% same documentation. This guide was |
| 504 |
% typeset with \ifxetex\prog{xelatex}\else |
| 505 |
% \ifluatex\prog{lualatex}\fi\fi, using this new |
| 506 |
% font, and the above Greek language examples are |
| 507 |
% correct. |
| 508 |
% |
| 509 |
% The first Greek example shows very clearly the |
| 510 |
% effect of |\lefthyphenmin=1| compared to the |
| 511 |
% second example where |\lefthyphenmin=2|. On the |
| 512 |
% other hand, the fact that some hyphen points may |
| 513 |
% be missing is certainly a feature that precludes |
| 514 |
% full hyphenation, but it does not produce |
| 515 |
% hyphenation errors. |
| 516 |
% |
| 517 |
% By using this package it was originally possible |
| 518 |
% to highlight the features/bugs in the Greek |
| 519 |
% hyphenation patterns. |
| 520 |
% \StopEventually{} |
| 521 |
% \CheckSum{101} |
| 522 |
% \section{The code} |
| 523 |
%\iffalse |
| 524 |
%<*package> |
| 525 |
%\fi |
| 526 |
% The following code has very few modifications |
| 527 |
% compared to the original code published by Victor |
| 528 |
% Eijkout. For my own benefit I changed the |
| 529 |
% declaration name from |\printhyphens| to |
| 530 |
% |\t@sthyphens|; with an at-sign internal name |
| 531 |
% it is less likely that this command is |
| 532 |
% redefined by some user. I also moved the command |
| 533 |
% |\offinterlineskip| from its penultimate position |
| 534 |
% in the original code to the first command to be |
| 535 |
% executed within a |\vbox|; in this way |
| 536 |
% I avoided certain cases in which the lack of |
| 537 |
% interline skip would remain active after closing |
| 538 |
% the environment. |
| 539 |
% |
| 540 |
% The code is based on treating the inter word space |
| 541 |
% as an active character that plays different rôles |
| 542 |
% according to its position; it lets the |
| 543 |
% environment isolate the words to be hyphenated |
| 544 |
% and open suitable boxes, that are closed at the |
| 545 |
% moment of processing the following word; the |
| 546 |
% |\everypar| token-list distinguishes the various |
| 547 |
% actions to be performed at each step. |
| 548 |
% |
| 549 |
% Another advantage is that the environment |
| 550 |
% processes one word at a time, therefore the word |
| 551 |
% list may be arbitrarily long; while creating the |
| 552 |
% patterns for the Albanian language I initially |
| 553 |
% worked with a half dozen pages taken from a |
| 554 |
% book, about 7000 words. Initially I deleted all |
| 555 |
% duplicate words then, while fine tuning |
| 556 |
% the pattern set, I deleted a certain number of the |
| 557 |
% test words; eventually a good set of patterns |
| 558 |
% was created under the supervision or a learned |
| 559 |
% Albanian friend. |
| 560 |
% |
| 561 |
% But the trick of this software is to set each word |
| 562 |
% within a vertical box where the measure (the text |
| 563 |
% width |\hsize|) is zero; in this way each word is |
| 564 |
% hyphenated at the first hyphen point, but the word |
| 565 |
% fragment that remains in the following line is |
| 566 |
% still too long and gets hyphenated again; the |
| 567 |
% process is repeated again and again until the |
| 568 |
% initial string is exhausted. The contents of the |
| 569 |
% |\vbox|, that now contains the syllables one per |
| 570 |
% line, is reassembled to form one line, and this |
| 571 |
% line is output within an |\hbox| and is therefore |
| 572 |
% the box typeset in vertical mode; this is why the |
| 573 |
% dommand must be issued in vertical mode, so as |
| 574 |
% to start processing the word list with the right |
| 575 |
% foot; this is also why the word list must start |
| 576 |
% and end with spaces; the first space or end of |
| 577 |
% line before the first word opens the first box, |
| 578 |
% and the last space or end of line after the last |
| 579 |
% word closes the box and outputs its contents in |
| 580 |
% horizontal mode.. |
| 581 |
% \begin{macrocode} |
| 582 |
\def\t@sthyphens{% |
| 583 |
\everypar{\setbox0\lastbox |
| 584 |
\setbox1\hbox{\strut}\vbox\bgroup |
| 585 |
\offinterlineskip |
| 586 |
\everypar{\setbox0\lastbox \nobreak\hskip\z@}\dimen0=\hsize |
| 587 |
\hsize=\z@ \hfuzz\maxdimen \def\par{\endgraf \hsize=\dimen0\getlastline |
| 588 |
\egroup\endgraf}}\breakafterword |
| 589 |
} |
| 590 |
|
| 591 |
\def\breakafterword{% |
| 592 |
\catcode`\^^M=13 \catcode`\ =13 |
| 593 |
} |
| 594 |
|
| 595 |
{\breakafterword\gdef^^M{\par}\global\let ^^M} |
| 596 |
|
| 597 |
\def\getlastline{\setbox0\lastbox |
| 598 |
\ifvoid0 |
| 599 |
\let\next\nomorelines |
| 600 |
\else |
| 601 |
\unskip\unpenalty |
| 602 |
\setbox1\hbox{\unhbox0\strut\discretionary{}{}{}% |
| 603 |
\unhbox1}\let\next\getlastline |
| 604 |
\fi |
| 605 |
\next} |
| 606 |
|
| 607 |
\def\nomorelines{\unhbox1} |
| 608 |
% \end{macrocode} |
| 609 |
% The above code is substantially the original one; |
| 610 |
% where the internal declaration control |
| 611 |
% sequence |\t@sthyphens| is defined. |
| 612 |
% Now we define the \amb{checkhyphens} environment |
| 613 |
% where we make sure that the whole process of the |
| 614 |
% word list contained in its body takes place in |
| 615 |
% vertical mode. In oder to process the optional |
| 616 |
% argument for setting the hyphenation parameters, |
| 617 |
% we define a delimited argument macro |
| 618 |
% |\s@thyphenpars| that uses the \emph{hyphen} as |
| 619 |
% the argument delimiter. |
| 620 |
% \begin{macrocode} |
| 621 |
\newenvironment{checkhyphens}[1][\lefthyphenmin-\righthyphenmin]{% |
| 622 |
\@tempcnta=\lefthyphenmin |
| 623 |
\@tempcntb=\righthyphenmin |
| 624 |
\s@thyphenpars[#1]\par |
| 625 |
\bgroup\t@sthyphens |
| 626 |
}{% |
| 627 |
\egroup\par |
| 628 |
} |
| 629 |
|
| 630 |
\def\s@thyphenpars[#1-#2]{% |
| 631 |
\@tempcnta=#1\relax |
| 632 |
\@tempcntb=#2\relax |
| 633 |
\unless\ifnum\@tempcnta=\lefthyphenmin \lefthyphenmin=\@tempcnta\fi |
| 634 |
\unless\ifnum\@tempcntb=\righthyphenmin \righthyphenmin=\@tempcntb\fi |
| 635 |
} |
| 636 |
% \end{macrocode} |
| 637 |
%\Finale |
| 638 |
%\iffalse |
| 639 |
%</package> |
| 640 |
%\fi |
| 641 |
% That's all. Happy \TeX\-ing. |
| 642 |
\endinput |
| 643 |
|