summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/fixltxhyph
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2012-04-02 23:56:18 +0000
committerKarl Berry <karl@freefriends.org>2012-04-02 23:56:18 +0000
commitea3699c08ce15cc51cb3fb3c02381b6acd11896b (patch)
tree3de48c3c204fcdf4e91542fe4c1cfa173eccb3b5 /Master/texmf-dist/source/latex/fixltxhyph
parent4f96777e93485d3be29c6c9b1564693d1b7a095e (diff)
fixltxhyph (2apr12)
git-svn-id: svn://tug.org/texlive/trunk@25832 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/fixltxhyph')
-rw-r--r--Master/texmf-dist/source/latex/fixltxhyph/fixltxhyph.dtx211
1 files changed, 112 insertions, 99 deletions
diff --git a/Master/texmf-dist/source/latex/fixltxhyph/fixltxhyph.dtx b/Master/texmf-dist/source/latex/fixltxhyph/fixltxhyph.dtx
index 902826a9604..ab888913a03 100644
--- a/Master/texmf-dist/source/latex/fixltxhyph/fixltxhyph.dtx
+++ b/Master/texmf-dist/source/latex/fixltxhyph/fixltxhyph.dtx
@@ -7,7 +7,7 @@
\preamble
______________________________________________________
The FiXLtxHyph package
- Copyright (C) 2011 Claudio Beccari
+ Copyright (C) 2011-2012 Claudio Beccari
All rights reserved
License information appended
@@ -15,7 +15,7 @@
\endpreamble
\postamble
-Copyright 20112012 Claudio Beccari
+Copyright 2011-2012 Claudio Beccari
Distributable under the LaTeX Project Public License,
version 1.3c or higher (your choice). The latest version of
@@ -28,7 +28,7 @@ the derived file fixltxhyph.sty, and the English
documentation fixltxhyph.pdf.
-By running pdflatex on fixltxhyph.dtx the user gets the sty file,
+By running pdflatex on fixltxhyph.dtx the user gets the .sty file,
and the English documentation file in pdf format.
\endpostamble
@@ -46,7 +46,7 @@ and the English documentation file in pdf format.
% \iffalse
%<*driver>
\documentclass{ltxdoc}
-\ProvidesFile{fixltxhyph.dtx}[2012/02/17 v.0.3 Documented TeX file for
+\ProvidesFile{fixltxhyph.dtx}[2012/04/02 v.0.4 Documented TeX file for
the FixLtxHyph package]
\GetFileInfo{fixltxhyph.dtx}
\usepackage[latin1]{inputenc}
@@ -56,7 +56,7 @@ the FixLtxHyph package]
\usepackage{multicol}
\title{\centering The FixLtxHyph package\protect\\
A small fix in order to hyphenate emphasized words after a vocalic elision\protect\\
-in Catalan, French, Italian and Romansh}
+in Catalan, French, Italian, Romansh, and Friulan}
\date{\fileversion\space\filedate}
\author{Claudio Beccari}
\usepackage{array}
@@ -72,73 +72,61 @@ in Catalan, French, Italian and Romansh}
\end{document}
%</driver>
% \fi
-% \CheckSum{48}
+% \CheckSum{84}
%
% \begin{abstract}
% This file fixes a small feature of the hyphenation algorithm used by the \TeX\ system
% typesetting engines that manifests itself only with those languages that use the
% apostrophe for marking a vocalic elision. This small package was set up to fix this
-% little undesirable feature in Italian, but it was extended to Catalan, French and the
+% little undesirable feature in Italian, but it was extended to Catalan, French, the
% future implementation of the fourth official Swiss language Rumantsch Grischun (Romansh
-% in English).
+% in English) and the future implementation of the Regional Language Friulan, spoken
+% and written in North Eastern Italy. This fix operates correctly with both \prog{pdflatex} and \prog{xelatex}.
% \end{abstract}
% \section{What is the feature to be fixed}
-% The four languages Catalan, French, Italian and Romansh use the apostrophe for marking
-% the vocalic elision of the ending vowel at the end of prepositions, articles, articulated
-% prepositions, definite adjectives, and other words playing similar rôles when they just
-% precede nouns, adjectives, verbs, numerals, that start with a vowel.
+% The five languages Catalan, French, Italian, Romansh, and Friulan use the apostrophe
+% for marking the vocalic elision of the ending vowel at the end of prepositions, articles,
+% articulated prepositions, definite adjectives, and other words playing similar rôles when
+% they just precede nouns, adjectives, verbs, numerals, that start with a vowel. Probably
+% there are other languages that use the apostrophe in a similar way. I can easily upgrade
+% this small package if \LaTeX\ users of other languages let me know about such languages.
%
% This feature is common to most Romance languages (from West to East) from Catalan and
% Valencian, to French, Langue d'oc, Occitan, Provençal, Vivaroalpin, Italian, Piedmontese,
% Lombard, Romansh, Ladin, Friulian; up to now only Catalan, French and Italian are handled
% by the \TeX\ system programs; at the same time most of these languages are minority ones
% and are being protected by local legislation or are supported by specific cultural or
-% linguistic institutions; only Romansh has got a national/federal legal status in
-% Switzerland and is being used in legal and official documents in the Swiss Confederation,
-% not only in its area of everyday use, the Kanton Graubunden or Canton Grigioni or
-% Chantun Grischun (where seven Romansh varieties are being spoken, besides Swiss
-% German, Italian, and other languages).
+% linguistic institutions; Romansh has got a national/federal legal status in
+% Switzerland and is being used in legal and official documents in the whole Swiss
+% Confederation, not only in its area of everyday use, the Kanton Graubunden or Canton
+% Grigioni or Chantun Grischun (where seven Romansh varieties are being spoken, besides
+% Swiss German, Italian, and other languages). The Friulan language has an official
+% regional status in the North-eastern Italian Region Friuli\,-Venezia Giulia.
%
% This spelling rule is very rigorous in French; I suppose it is also a rigorous rule in
-% Catalan and Romansh, but I am not that familiar with these languages even if I can
-% understand their written forms. In Italian it used to be a rigorous rule many years ago,
-% but nowadays it is less frequently used when plurals are involved.
-% Nevertheless apostrophes are practically the only para-alphabetic sign you see in an
-% Italian text except for letters and punctuation marks.
+% Catalan, Romansh, and Friulan but I am not that familiar with these languages even if I
+% can understand their written forms. In Italian it used to be a rigorous rule many years
+% ago, but nowadays it is less frequently used when plurals are involved.
+% Nevertheless apostrophes are practically the only analphabetic sign you see in an
+% Italian text except for letters and punctuation and quotation marks.
%
-% In order to hyphenate correctly these word combinations all four languages have to
+% In order to hyphenate correctly these word combinations all five languages have to
% declare the apostrophe, that has a category code of~12, as a glyph with non zero lower
-% case code. In facts all four languages declare:
+% case code. In facts all five languages declare:
%\begin{verbatim}
%\lccode`\'=`\'
%\end{verbatim}
% or something equivalent. With this little trick, the typesetting engine considers the
% apostrophe as a valid word character and treats the whole string as a single word; the
% patterns of these languages, of course, take into consideration also the apostrophe so
-% that the resulting correct line break points are easily found\footnote{For typesetting
-% Romansh and hyphenating it, initially I wrote myself a short language definition file,
-% where, among other things, Romansh was considered as a dialect of Italian. In this way I did
-% not need to build up the specific Romansh patterns; of course this was done only for thesting
-% this small package.
-% With my great surprise, my first feeling was that Italian patterns did a pretty
-% good job (the common Latin ancestor helps a lot, of course); I spotted only very few final
-% syllables without a vowel (which is wrong) and a couple of digraphs wrongly divided. After
-% this ``successful'' start, I made up the Romansh hyphenation patters by just modifying the
-% Italian ones in order to correct the few errors mentioned above; I checked my Romansh
-% patterns aginst the hyphenation rules described in the \emph{Grammatica per l'instrucziun
-% dal rumantsch grischun} published by the Department of romance languages and literature
-% of the Friburg University, Switzerland. The patterns I produced work pretty well, but they
-% are not built up for etimological hyphenation, therefore some prefixex or compound words
-% might be divided without respecting the compound word barrier. At the date of writing these
-% notes, the Romansh patterns and the language description file have been
-% uploaded to the polyglossia and babel teams, but they are not yet available for the
-% general user.}:
+% that the resulting correct line breaks are easily found:
%\begin{center}
%\begin{tabular}{l>{\ttfamily}ll}
%Catalan & d'aquesta & d'a-ques-ta \\
-%French & l'électricité & l'élec-tri-ci-té \\
+%French & l'électricité & l'élec-tri-ci-té \\
%Italian & dell'eleganza & del-l'e-le-gan-za \\
-%Romansh & l'identitad & l'i-den-ti-tad
+%Romansh & l'identitad & l'i-den-ti-tad \\
+%Friulan & l'arbul & l'ar-bul
%\end{tabular}
%\end{center}
%
@@ -149,12 +137,13 @@ in Catalan, French, Italian and Romansh}
%Catalan & d'\string\emph\{aquesta\} & d'\emph{aquesta} \\
%French & l'\string\emph\{électricité\} & l'\emph{électricité} \\
%Italian & dell'\string\emph\{eleganza\} & dell'\emph{eleganza} \\
-%Romansh & l'\string\emph\{identitad\} & l'\emph{identitad}
+%Romansh & l'\string\emph\{identitad\} & l'\emph{identitad} \\
+%Friulan & l'\string\emph\{arbul\} & l'\emph{arbul}
%\end{tabular}
%\end{center}
%
% This behavior is easily explained, so that it is not to be considered a bug, but a
-% feature; a feature that is annoying only when using the above four named languages.
+% feature; a feature that is annoying only when using the above five named languages.
% The point is that all \TeX\ system typesetting engines consider a word to be that
% character string starting after a character invalid in a word and finishing with the
% first token invalid in a word. Notice that when the hyphenating algorithm comes to work
@@ -170,29 +159,31 @@ in Catalan, French, Italian and Romansh}
% of type (1); (3) an implicit kern. \dots\ Notice that all these letters are
% in font~$f$.''
%
-% This was a specific programming choice decided by Donald Knuth together with Frank Liang,
-% his PhD student who developed the hyphenation algorithm implemented in the typesetting
-% engines of the \TeX\ system\footnote{I have been told that Lua\TeX\ is developing
-% a different algorithm that eliminates this feature.}.
-% As all such decisions, it is a compromise between accuracy and speed. And remember that at
-% the beginning \prog{tex} the program was used essentially with English, a language that
-% does not use accented letters and uses elision in a much different way as the one we are
-% speaking here. The problem did non exist and, I suppose, it will never exist in English.
+% This was a specific programming choice decided by Donald~E.\ Knuth together with Frank
+% Liang, his PhD student who developed the hyphenation algorithm implemented in the
+% typesetting engines of the \TeX\ system\footnote{I have been told that Lua\TeX\ is
+% developing a different algorithm that eliminates this feature.}.
+% As all such decisions, it is a compromise between accuracy and speed. And remember that
+% at the beginning \prog{tex} the program was used essentially with English, a language
+% that does not use accented letters and uses elision in a much different way as the one we
+% are speaking here. The problem did non exist and, I suppose, it will never exist in
+% English.
%
% \section{The solutions}
% As a compromise I decided to solve the problem in an automatic way only when the second
% part of the ``word'' to be hyphenated is emphasized. I suppose it is the most frequent
-% situation, although no one can avoid thinking to other situations; for example; the
+% situation, although no one can avoid thinking to other situations; for example: the
% second part of such ``word'' after the apostrophe is bolded, is colored, is written
-% in another font selected on purpose or is in another alphabet, it is in italics, with
-% no choice on the inclination; in such cases the solution is manual and remains manual,
-% because there are too many possibilities and it is cumbersome to deal with all of them.
+% in another font selected on purpose or is in another alphabet, is in italics (with
+% no automatic inclination switching); in such cases the solution is manual and remains
+% manual, because there are too many possibilities and it is cumbersome to deal with all
+% of them.
%
% But manual or automatic, how should we proceed? Simply we must convince that the
% starting letter must not be the start of the part preceding the apostrophe, but what
% follows it.
-% This is simple: it suffices to put after the apostrophe a unbreakable, zero width glob of
-% glue; \TeX\ starts looking for a potential starting letter after the glue.
+% This is simple: it suffices to put after the apostrophe an unbreakable, zero width glob
+% of glue; \TeX\ starts looking for a potential starting letter after the glue.
% Therefore the manual solution consists in defining a short macro such as the following
% one:
%\begin{verbatim}
@@ -204,29 +195,29 @@ in Catalan, French, Italian and Romansh}
%\begin{verbatim}
%... d'\hz\textbf{aquesta} ...
%\end{verbatim}
-% The |\hz|, whose name reminds the sentence ``Horizontal skip of an unbreakable Zero width
+% The |\hz|, whose name reminds the phrase ``Horizontal skip of an unbreakable Zero width
% glob of glue'', finishes the preceding word and sets the grounds for starting the search
% of a new starting letter of another word; it will be found after the font selections code
% introduced in the horizontal list by the selected font identification.
%
% The automatic solution, on the opposite, implies a small but substantial modification of
% the |\emph| command. In facts the text command uses the text declaration |\em|; on turn
-% |\em| is a robusta commanda, that is it is defined as \verb*|\protext\em |: it would be
-% very unwise to modify a protected command, so it is necessary to modifiy the ``protected''
-% one, and this operation is not trivial because of the space in the name of this macro.
-% In any case if we find out how, we must add |\hz| to the definition of \verb*|\em | before
-% its argument, the real text to emphasize, is processed.
+% |\em| is a robust command, that is it is defined as \verb*|\protect\em |: it would be
+% very unwise to modify a protected command, so it is necessary to modify the
+% \texttt{protect}ed one, and this operation is not trivial because of the space in this macro name.
+% In any case if we find out how, we must add |\hz| to the definition of \verb*|\em |
+% before its argument, the real text to emphasize, is processed.
%
-% This small package does exactly this, only for the four named languages, and only if
+% This small package does exactly this, only for the five named languages, and only if
% they are used, and only with the |\emph| command. The |\hz| command is available to the
% user in a global way, so that when this package is loaded, the manual solution remains
% valid for every language, although in very unlikely situations.
%
-% It has been tested with the four languages, and
-% apparently it works as expected; it has been throughly tested in all situations with
-% Italian; it should work properly also in French and in Romansh. The adopted solution
-% does not fiddle with active characters and therefore it does not interfere with the
-% internal workings and settings of Catalan and the other languages.
+% It has been tested with the five languages with both \prog{pdflatex} and \prog{xelatex},
+% and apparently it works as expected; it has been throughly tested in all situations with
+% Italian; it should work properly also in French, in Romansh, and in Friulan. The adopted
+% solution does not fiddle with active characters and therefore it does not interfere with
+% the internal workings and settings of Catalan and the other languages.
%
% \section{Installation}
% With modern \TeX\ distributions these instructions are superfluous; should you need to
@@ -252,7 +243,7 @@ in Catalan, French, Italian and Romansh}
%\usepackage{fixltxhyph}
%\end{verbatim}
%
-%\ section{Aknowledgements}
+%\section{Aknowledgements}
%I wish to thank Lorenzo Pantieri who tested the preliminary and the actual versions of
% this package and directly or indirectly helped debugging the code, especially in the
% preliminary version that used active characters and was particularly buggy. Another
@@ -264,40 +255,45 @@ in Catalan, French, Italian and Romansh}
% We start by identifying the package and the necessary format file:
% \begin{macrocode}
%<*style>
-\ProvidesPackage{fixltxhyph}[2011/12/25 v.0.1 Small fix for hyphenating
+\ProvidesPackage{fixltxhyph}[2011/04/02 v.0.4 Small fix for hyphenating
emphasized words preceded by vocalic elision]
\NeedsTeXFormat{LaTeX2e}[2011/06/27]
% \end{macrocode}
-% Then we make sure that the package \texttt{babel} has already been loaded; otherwise
-% we warn the user and exit; no patches can be made to an unknown package.
+% Then we make sure that the package \texttt{babel} or \texttt{polyglossia} has already
+% been loaded; otherwise we warn the user and exit; no patches can be made to an unknown
+% package.
% \begin{macrocode}
-\@ifpackageloaded{babel}{}{%
-\PackageWarning{FixLtXHyph}{This package must be loaded after babel}%
-\endinput}
+\@ifpackageloaded{babel}{}{\@ifpackageloaded{polyglossia}{}{%
+\PackageWarning{FixLtXHyph}{This package must be loaded after babel
+ or polyglossia}%
+\endinput}}
% \end{macrocode}
%
% We need the package |etoolbox| in order to perform any action on control sequences
-% that contain spaces in their names.
+% that contain spaces in their names; we do not need any means to test if we are working
+% with \texttt{babel} or with \texttt{polyglossia} because, thanks to the previous
+% tests, one of the two packages has certainly been loaded.
% \begin{macrocode}
-\RequirePackage{etoolbox}
+\@ifpackageloaded{etoolbox}{}{\RequirePackage{etoolbox}}
% \end{macrocode}
% We define a very short command |\hz| in order to have available a handy command
-% for inserting an unbreakable zero width glob of glue in case we needed to do some
+% for inserting an unbreakable zero-width glob of glue in case we needed to do some
% sort of patching by hand.
% \begin{macrocode}
\newcommand\hz{\nobreak\hskip\z@skip}
% \end{macrocode}
-% We make patches only if one or more of the four languages Catalan, French, Italian, or
-% Romansh has been invoked as an option to \texttt{babel}; if none of these options had
-% been selected, evidently the user had his/her thoughts focused on other details, so
-% that s/he missed the point that this patch is necessary only for the above mentioned
-% four languages. In any case no harm should happen if from now on nothing gets done,
-% except for the definition of |hz| that remains available to the user.
+% We make patches only if one or more of the five languages Catalan, French, Italian,
+% Romansh, or Friulan (or its alias Furlan) has been invoked as an option to \texttt{babel}
+% or specified to \texttt{polyglossia}; if none of these options had been selected,
+% evidently the user was thinking to other details and missed the point that this patch is
+% necessary only for the above mentioned five languages. In any case no harm takes place
+% if from now on nothing else gets done, except for the definition of |hz| that remains
+% available to the user.
%
% The next bit of code defines some aliases in order to keep the original meaning of the
% declaration |\em|; in order to patch an alias, so as to be able to set the proper
-% definitions only for the named four languages and to rest the original situation when a
-% change of language takes place.
+% definitions only for the named five languages and to restore the original situation when
+% a change of language takes place.
% \begin{macrocode}
\letcs{\FLH@originalem}{em }
\let\FLH@newem\FLH@originalem
@@ -306,18 +302,35 @@ emphasized words preceded by vocalic elision]
%
% We then use a repetition cycle based on a list of language names; if the
% language with one of the listed names has been invoked as an option to \texttt{babel},
-% then the patched \verb*|\em | definition is made the default, while when changing
-% language the original definition is restored:
+% or specified to \texttt{polyglossia} then the patched \verb*|\em | definition is made
+% the default, while when changing language the original definition is restored; we define a macro that contains the language names:
% \begin{macrocode}
-\def\@tempB{catalan,french,italian,romansh}
-\@for\@tempA:=\@tempB\do{%
-\expandafter\ifx\csname captions\@tempA\endcsname\relax\else
-\expandafter\addto\csname extras\@tempA\endcsname{\cslet{em }{\FLH@newem}}%
-\expandafter\addto\csname noextras\@tempA\endcsname{\cslet{em }{\FLH@originalem}}\fi}
+\def\@tempB{catalan,french,italian,romansh,friulan,furlan}
+% \end{macrocode}
+% then we perform the above mentioned cycles; we have to distinguish if we are using
+% \texttt{polyglossia} or \texttt{babel} because the internal setting and resetting macros
+% of these two packages have different names; they are all made up by the agglutination of
+% a prefixx to the language name, so we have to build the macro names to patch with the
+% usual deferred name contraction by means of |\expandafter| and |\csname| with its
+% companion |\endcsname|.
+% \begin{macrocode}
+\@ifpackageloaded{polyglossia}%
+{\@for\@tempA:=\@tempB\do{%
+ \expandafter\ifx\csname captions\@tempA\endcsname\relax\else
+ \expandafter\addto\csname noextras@\@tempA\endcsname{\cslet{em }{\FLH@originalem}}%
+ \expandafter\addto\csname blockextras@\@tempA\endcsname{\cslet{em }{\FLH@newem}}%
+ \expandafter\addto\csname inlineextras@\@tempA\endcsname{\cslet{em }{\FLH@newem}}%
+ \fi}%
+}{\@for\@tempA:=\@tempB\do{%
+ \expandafter\ifx\csname captions\@tempA\endcsname\relax\else
+ \expandafter\addto\csname extras\@tempA\endcsname{\cslet{em }{\FLH@newem}}%
+ \expandafter\addto\csname noextras\@tempA\endcsname{\cslet{em }{\FLH@originalem}}%
+ \fi}%
+}
% \end{macrocode}
%
-% Eventually the documented file is terminated and its final commands are issued.
-%\begin{macrocode}
+% This documented file is now terminated and its final commands are issued.
+% \begin{macrocode}
\endinput
%</style>
% \end{macrocode}