diff options
Diffstat (limited to 'Master/texmf-dist/source/generic/babel-italian/italian.dtx')
-rw-r--r-- | Master/texmf-dist/source/generic/babel-italian/italian.dtx | 194 |
1 files changed, 141 insertions, 53 deletions
diff --git a/Master/texmf-dist/source/generic/babel-italian/italian.dtx b/Master/texmf-dist/source/generic/babel-italian/italian.dtx index 377d413b1ac..ed95cab3d2e 100644 --- a/Master/texmf-dist/source/generic/babel-italian/italian.dtx +++ b/Master/texmf-dist/source/generic/babel-italian/italian.dtx @@ -22,7 +22,7 @@ % and covered by LPPL is defined by the unpacking scripts (with % extension .ins) which are part of the distribution. % \fi -% \CheckSum{622} +% \CheckSum{669} % \iffalse % Tell the \LaTeX\ system who we are and write an entry on the % transcript. @@ -32,7 +32,7 @@ %<code>\ProvidesLanguage{italian} %\fi %\ProvidesFile{italian.dtx} - [2013/10/02 v1.3a Italian support from the babel system] + [2013/10/13 v1.3c Italian support from the babel system] %\iffalse %% Italian support for the babel package %% Copyright (C) 2013 by Claudio Beccari @@ -200,16 +200,19 @@ % \item Since in all languages different from English the decimal separator % according to the ISO regulations \emph{must} be a comma, and since % no language description file nor the \babel\ package itself provides -% for this deficiency, a simple intelligent comma definition is +% for this functionality, a not so simple intelligent comma definition is % provided such that at least in mathematics it behaves correctly. % There are other packages that provide a similar functionality, for % example |icomma| and |ncccomma|; I believe that my solution is better % than that provided by both those packages; but, since this % functionality may be turned on or off at the user will, those -% packages may still be used By default this functionality is turned +% packages may still be used. By default this functionality is turned % off, therefore the user should turn it on by means of the % |\IntelligentComma| command; it can turn it off by means of -% |\NoIntelligentComma|. +% |\NoIntelligentComma|. Please, read subsection~\ref{ssec:comma} +% to see the various situations where a mathematical comma may be +% used and how to overcome the few cases when the macros of this file +% don't behave as expected. % \item In Italian legal documents it is common to tag list-items % with the old fashioned 21-letter Italian alphabet, that differs from % the Latin one by the omission of the letters `j', `k', `w',`x', and @@ -225,6 +228,15 @@ % section~\ref{s:itkbd} there are other comments and hints in order % to overcome some other keyboard limitations. % +%\subsection{Acknowlegements} +% It is my pleasure to acknowledge the contributions of Giovanni Dore, +% Davide Liessi, Grazia Messineo, Giuseppe Toscano, who spotted some bugs +% or conflicts with other packages, mainly |amsmath| and |icomma|, and +% with digits hidden inside macros or control sequences representing +% implicit characters. Testing by real users and their feedback is +% essential with open software such as the uncountable contributions +% to the \TeX\ system. Thank you very much. +% % \StopEventually{% % \begin{thebibliography}{1} % \bibitem{CBec} Beccari C., ``Computer Aided Hyphenation for @@ -235,6 +247,7 @@ % vol.~18, n.~1, pp.~39-48 (1997). % \end{thebibliography}} % +%\subsection{The commented code} % The macro |\LdfInit| takes care of preventing that this file is % loaded more than once, checking the category code of the % \texttt{@} sign, etc. @@ -726,7 +739,7 @@ % \end{macro} % \end{macro} % -% \section{Intelligent comma} +% \subsection{Intelligent comma}\label{ssec:comma} % % \begin{macro}{\IntelligentComma} % \begin{macro}{\NoINtellgentComma} @@ -778,18 +791,23 @@ % Then we need a command to set the comma as an active charter only % in math mode; the special |\mathcode| that classifies an active % character in math is the exadecimal value |"8000|. But we have -% to set this value only when the current lagguage is not English -% or one of its varieties. +% to set this value only when the current language is not English +% or one of its varieties. We avoid to do anything if at the end of +% the preamble is is found that the |icomma| package has been loaded. +% There is a conflict; so we assume that if the user wants to use the +% |icomma| package, he wants to do it, and does not want to make use +% of the functionality of this language description file. % \begin{macrocode} \AtEndOfPackage{% -\AtEndPreamble{% - \@ifpackageloaded{polyglossia}{% - \ifcsstring{xpg@main@language}{english}{\relax}{% - \mathcode`\,=\string"8000} - }{% - \ifcsstring{languagename}{english}{\relax}{% - \mathcode`\,=\string"8000} - } +\AtEndPreamble{\@ifpackageloaded{icomma}{\relax}{% + \@ifpackageloaded{polyglossia}{% + \ifcsstring{xpg@main@language}{english}{\relax}{% + \mathcode`\,=\string"8000} + }{% + \ifcsstring{languagename}{english}{\relax}{% + \mathcode`\,=\string"8000} + }% + }% }} % \end{macrocode} % \changes{italian-1.3a}{2013/10/02}{Repaired the bug of the intelligent @@ -798,16 +816,19 @@ % Math comma activation is done only after the preamble has % been completed, that is after the |\begin{document}| statement has been % completely executed. Now we must give a definition to the active comma: -% probably it is not necessary to pass through in intermediate robust command, but certainly it is not wrong to do it. +% probably it is not necessary to pass through in intermediate robust +% command, but certainly it is not wrong to do it. % \begin{macrocode} -\DeclareRobustCommand*\it@comma@def{\futurelet\let@token\m@thcomma}% +\DeclareRobustCommand*\it@comma@def{\futurelet\let@token\@@math@comma}% {\catcode `,=\active \gdef,{\it@comma@def}}% % \end{macrocode} % The real work shall be performed by |\it@comma@def|. In facts the -% above macro stores the token that immediately follows |\@math@comma| +% above macro stores the token that immediately follows |\@@math@comma| % into a temporary control sequence that behaves as an implicit character % if that token is a single character, even a space, or behaves as -% an alias of a control sequence otherwise. +% an alias of a control sequence otherwise. Actually at the end of the +% preamble this macro shall be |\let| to be an alias for the real +% |\@math@comma|. % % Is is important to remark that |\@math@comma| must be a command that % does not require arguments; this makes it robust when it is followed @@ -815,22 +836,90 @@ % of other macros or environments. Matter of fact the first version 1.3 % of this file in version 1.3 did accept an argument; and the result was % that the active comma would ``eat up'' the |&| in vertical math -% alignments and very hasty problem took place, especially within the -% |amsmath| defined ones. This macro |\@math@comma| without arguments +% alignments and very nasty errors took place, especially within the +% |amsmath| defined ones. This macro |\@@math@comma| without arguments % does not do any harm to the AMS environments and the actual intelligent % comma work shall be executed by other macros. - +% +% At this point the situation may become complicated: the comma character +% in the input file may be followed by a real digit, by an analphabetic +% character of category 12 (other character), by an implicit digit, by a +% macro defined to be a digit, by a macro that is not defined to be a +% digit, by a special character (for example a closed brace, an alignment +% command, et cetera); therefore it is necessary to distinguish all these +% situations; remember that an implicit digit cannot be used as a real +% digit, and a macro gets expanded when used with any |\if| clause unless +% it is a |\ifx| one or is prefixed with |noexpand|. The tests that are +% going to be made are therefore of different kinds, according to this +% scheme: +% \begin{itemize} +% \item the |\let@token| is tested against an asterisk to see it it is of +% category 12; this is true if the token is a real digit, or an implicit +% digit, or an analphabetic character; +% \begin{itemize} +% \item an implicit digit is represented by a control sequence; so we +% first check this feature; +% \item if it is a control sequence, we have to test its nature of a +% digit by testing if it represented one of the ten digits; +% \item otherwise it is an analphabetic character. +% \end{itemize} +% \item otherwise the |\let@token| is a special character or a +% macro/command; +% \item a test is made to see if it is a macro; in this case we check +% if has been defined to be a digit, +% \item it is not a macro, it must be some other kind of token for +% example a space or another special character. +% \end{itemize} +% Notice that if the token is a macro, we do not test if it is defined +% to be a single digit or a string made up of more digits and/or other +% charters. If the macro represents one digit the test is correct, +% otherwise funny results may tale place. For this reason it is alway +% better prefix a space before any macro, whatever its definition might +% be; if the macro represents a parameter defined to have a variable +% value in the range 0--9, then it may represent the fraction part of +% a (short) decimal value, and is correct to avoid prefixing it with a +% space; but the user is warned not to make use of numeric strings in +% the definition of parameters, unless he knows what he is doing. +% It may rather use a balanced brace comma grout |{,}| in the input file +% so that the macro will not be considered by the expansion of the +% active comma. For example if |\x| is defined to be the numerical +% string |89|, the source input |$2{,}\c$| wil be correctly typeset +% as 2,89; the input \verb*!$2, \c$! will be typeset as 2,\,89 (with +% an unbreakable thin space after the comma) while |$2,\c$| will be +% typeset as 29,89, obviously incorrectly. +% % So first we test if the comma must act intelligently; if the counter % |\Virgola| contains zero, we assume that the comma must always perform % as a punctuation mark; but if we want to distinguish if it must behave % as a decimal separator, we have to perform more delicate tests; this -% latter task is demanded to another macro with arguments |\@math@@comma|. +% latter task is demanded to other macros with arguments |\@math@@comma| +% and |\@@math@@comma|. In order to make the various tests robust we +% have to resort to the usual trick of the auxiliary macros |\@firstoftwo| +% and |\@secondoftwo| and various |\expandafter| commands so as to be +% sure that every |\if| clause is correctly exited without leaving any +% trace behind. % \begin{macrocode} \DeclareRobustCommand*\@math@comma{% - \ifnumequal{\Virgola}{\z@}{\virgola}{% - \unless\ifcat\noexpand\let@token*% - \expandafter\virgola\else - \expandafter\@math@@comma\fi}} + \ifnumequal{\Virgola}{\z@}{\virgola}{% + \ifcat\noexpand\let@token*% + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi{% \let@token is of category 12 + \@math@@comma + }{% test if \let@token is a macro + \ifcat\noexpand\let@token\noexpand\relax + \expandafter\@firstoftwo + \else + \expandafter\@secondoftwo + \fi{% it is a macro macro + \@@math@@comma + }{% it is something else. + \virgola + } + } + } +} % \end{macrocode} % % In particular this macro must test if the argument has category @@ -851,37 +940,34 @@ % the |\@math@@comma| macro which is not that simple, although the testing % macros have clear meanings: % \begin{macrocode} -\DeclareRobustCommand*\@math@@comma[1]{% - \ifcsundef{\expandafter\@gobble\string #1}{% +\DeclareRobustCommand*\@math@@comma[1]{% argument is certainly of category 12 + \ifcsundef{\expandafter\@gobble\string #1}{% test if it is a real digit \ifnumless{`#1}{`0}{\virgola}% {\ifnumgreater{`#1}{`9}{\virgola}% - {\virgoladecimale}}}{\virgola}#1} + {\virgoladecimale}}% + }{% it's an implicit character of category 12 + \let\@tempVirgola\virgola + \@tfor\@tempCifra:=0123456789\do{% + \expandafter\if\@tempCifra#1\let\@tempVirgola\virgoladecimale + \@break@tfor\fi}\@tempVirgola + }#1} + +\DeclareRobustCommand*\@@math@@comma[1]{% argument is a macro + \let\@tempVirgola\virgola + \@tfor\@tempCifra:=0123456789\do{% + \if\@tempCifra#1\let\@tempVirgola\virgoladecimale + \@break@tfor\fi}\@tempVirgola#1 +} % \end{macrocode} -% Notice that the argument |#1| is first changed to a string of category -% code 12 characters by means of the command |\string|; then |\@gobble| -% gobbles the first character in the listIf it was a single character -% the list remains empty, while int it was a control sequence, the -% backslash get stripped off. Then |ifcsundef| tests if the string is -% defined as a control sequence; of course it it has to check an empty -% string, that turns to be undefined, so we are facing a single character, -% while if the original string was a control sequence the tests turns -% out to be false. The particular testing macro returns the correct -% result |true| or |false| whiteout giving a false negative if the -% string was undefined, as |\ifcsname...\endcsname| would do in the -% same circumstances. In any case if the argument was a control sequence, -% the comma whould be a punctuation one, while if it was a single -% character, its ASCII code is testd to be in the range |`0--`9| and -% it it's actually in this range the comma has to be a decimal separator. -% -% Now the last two macro definitions rely on service macros that are +% The service macros |\ifcsundef|, |\ifnumless|, and |\ifnumgreater| are % provided by the |etoolbox| package, that shall be read at most at the -% end of the |babel| package processing; therefore only at the end point -% we can delay the code at ``end preamble'' time, since only at that time +% end of the |babel| package processing; therefore we must delay the code +% at ``end preamble'' time, since only at that time % it will be known if the main language is English, or any other one. % This is why we have to perform such a baroque definition as the % following one: % \begin{macrocode} -\AtEndOfPackage{\AtEndPreamble{\let\m@thcomma\@math@comma}} +\AtEndOfPackage{\AtEndPreamble{\let\@@math@comma\@math@comma}} % \end{macrocode} % This intelligent comma definition is pretty intelligent, but it requires % some kind of information from the context; this context does not @@ -893,8 +979,9 @@ % be absent the macro takes the following non blank token as a digit, % and since it actually is a digit, it would use the decimal comma, which % would be wrong. The control sequences |\dots| and |\infty| are -% tested to see if they are undefined, and since they are defined, the macro -% inserts a punctuation mark, instead of a decimal separator. +% tested to see if they are undefined, and since they are defined and +% do not represent digits, the macro inserts a punctuation mark, +% instead of a decimal separator. % % Notice that this macro may appear to be inconsistent with the contents % of a language description file. I don't agree: matter of facts even @@ -922,6 +1009,7 @@ % package. % \end{macro} % \end{macro} +% % \subsection{Accents}\label{s:itkbd} % Most of the other language description files introduce a number % of shortcuts for inserting accents and other language specific |