diff options
author | Karl Berry <karl@freefriends.org> | 2013-10-03 22:23:59 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2013-10-03 22:23:59 +0000 |
commit | 5d4297843624b424a9d56ffbebba3b3766566b9c (patch) | |
tree | 5645743de748dca27246fa7d28f7acd80b7cba99 /Master/texmf-dist/source/generic/babel-italian/italian.dtx | |
parent | 17c26f8a0e90231c7f95311cd8270fcd345002e4 (diff) |
babel-italian (3oct13)
git-svn-id: svn://tug.org/texlive/trunk@31823 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/generic/babel-italian/italian.dtx')
-rw-r--r-- | Master/texmf-dist/source/generic/babel-italian/italian.dtx | 151 |
1 files changed, 92 insertions, 59 deletions
diff --git a/Master/texmf-dist/source/generic/babel-italian/italian.dtx b/Master/texmf-dist/source/generic/babel-italian/italian.dtx index 3e0a6059e20..377d413b1ac 100644 --- a/Master/texmf-dist/source/generic/babel-italian/italian.dtx +++ b/Master/texmf-dist/source/generic/babel-italian/italian.dtx @@ -1,10 +1,5 @@ % \iffalse meta-comment % -% Copyright 1989-2004 Johannes L. Braams and any individual authors -% listed elsewhere in this file. All rights reserved. -% -% This file is part of the Babel system. -% -------------------------------------- % % It may be distributed and/or modified under the % conditions of the LaTeX Project Public License, either version 1.3 @@ -27,7 +22,7 @@ % and covered by LPPL is defined by the unpacking scripts (with % extension .ins) which are part of the distribution. % \fi -% \CheckSum{611} +% \CheckSum{622} % \iffalse % Tell the \LaTeX\ system who we are and write an entry on the % transcript. @@ -37,16 +32,10 @@ %<code>\ProvidesLanguage{italian} %\fi %\ProvidesFile{italian.dtx} - [2013/09/27 v1.3 Italian support from the babel system] + [2013/10/02 v1.3a Italian support from the babel system] %\iffalse -%% File `italian.dtx' -%% Babel package for LaTeX version 2e -%% Copyright (C) 1989 - 2004 -%% by Johannes Braams, TeXniek -% %% Italian support for the babel package -%% Copyright (C) 2013 -%% by Claudio Beccari +%% Copyright (C) 2013 by Claudio Beccari %% %% Please report errors to: claudio dot beccari at gmail dot com % @@ -111,7 +100,8 @@ % \changes{italian-1.3}{2-13/09/30}{Command \cs{unit} is disabled if packages % units, SIunits, or siunitx have been loaded; this control is now deferred % at the end of the preamble, when all packages have already been loaded} -% +% \changes{italian-1.3a}{2013/10/02}{Eliminated conflict with the amsmath +% package} % \section{The Italian language} % % \textbf{Important notice:} This language description file relies on @@ -802,87 +792,130 @@ } }} % \end{macrocode} +% \changes{italian-1.3a}{2013/10/02}{Repaired the bug of the intelligent +% comma when used within the AMS alignment environments} +% % 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. % \begin{macrocode} -{\catcode `,=\active \gdef,{\futurelet\let@token\m@thcomma}}% +\DeclareRobustCommand*\it@comma@def{\futurelet\let@token\m@thcomma}% +{\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| +% 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. +% +% 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 +% by other characters that may play special r\^oles within the arguments +% 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 +% does not do any harm to the AMS environments and the actual intelligent +% comma work shall be executed by other macros. + +% 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|. +% \begin{macrocode} +\DeclareRobustCommand*\@math@comma{% + \ifnumequal{\Virgola}{\z@}{\virgola}{% + \unless\ifcat\noexpand\let@token*% + \expandafter\virgola\else + \expandafter\@math@@comma\fi}} % \end{macrocode} -% The real work shall be performed by |\m@thcomma|. This follows after -% a few words of explanation; the above statement stores the token that -% follows the |\m@thcomma| macro 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 macro otherwise. 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. -% -% In particular we must test if the next char has category code 12, -% that is ``other character'', not a letter, nor other special signs, -% as the space for example. In this case the comma must act as a -% punctuation mark; but if it has category code 12, it might be a -% digit, or another character; so we have to test the nature of a -% digit; the simplest way I found to test if a token is a digit is -% to test its ASCII code against the ASCII codes of `0' (zero) and 9. +% +% In particular this macro must test if the argument has category +% code 12, that is ``other character'', not a letter, nor other +% special signs, as |&| for example. In case the category code is +% not 12, the comma must act as a punctuation mark; but if it is, +% it might be a digit, or another character, an asterisk, for example; +% so we have to test its digit nature; the simplest that was found +% to test if a token is a digit, is to test its ASCII code against +% the ASCII codes of `0' (zero) and 9. % The typesetting engines give the backtick, |`|, the property that % when a number is required, it yields the ASCII code if the following % token in an explicit character or a macro argument; this is why we % can't use the temporary implicit token we just tested, but we must -% examine the first non blank token that follows the |\m@thcomma| +% examine the first non blank token that follows the |\@math@@comma| % macro. Only if the token is a digit, we use the decimal comma, % otherwise the punctuation mark. This is therefore the definition of -% the |\m@thcomma| macro which is not that simple, although the testing +% the |\@math@@comma| macro which is not that simple, although the testing % macros have clear meanings: % \begin{macrocode} -\AtEndOfPackage{% -\AtEndPreamble{% -\gdef\m@thcomma#1{% -\ifnumequal{\Virgola}{\z@}{\virgola#1}{% - \unless\ifcat\noexpand\let@token*% - \virgola - \else +\DeclareRobustCommand*\@math@@comma[1]{% \ifcsundef{\expandafter\@gobble\string #1}{% \ifnumless{`#1}{`0}{\virgola}% {\ifnumgreater{`#1}{`9}{\virgola}% - {\virgoladecimale}% - }% - }{\virgola}% - \fi#1}}% -}} + {\virgoladecimale}}}{\virgola}#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 +% 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 +% 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}} % \end{macrocode} -% This definition is pretty intelligent, but the context does not -% give enough informations to this `intelligence' in just one case: +% This intelligent comma definition is pretty intelligent, but it requires +% some kind of information from the context; this context does not +% give enough bits of information to this `intelligence' in just one case: % when the comma plays the r\^ole of a serial separator in expressions % such as $i=1, 2, 3,\dots,\infty$, entered as % \verb*?$i=1, 2, 3,\dots,\infty$?. In this case and only in this -% case the comma must be followed by an explicit space, otherwise -% the macro takes the following non blank token as a digit, and -% actually it is a digit, and uses the decimal comma instead, which +% case the comma must be followed by an explicit space; should this space +% 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. % -% Notice the this macro appears to be inconsistent with the contents +% 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 -% math is part of typesetting a text in a certain language; does this -% set of macros influence other language description files? May be, -% but I think that the clever use of the macros |\IntelligentComma| +% math is part of typesetting a text in a certain language. +% Does this set of macros influence other language description files? +% May be, but I think that the clever use of macros |\IntelligentComma| % and |\NoIntellingentComma| may solve any interference; they allow to % use the proper mark even if the Italian language is not the main -% language, the important point is to turn the switch on and off. +% language, the important point is to turn the switch on and/or off. % By default it is off, so there should not be any interference even % with legacy documents typeset in Italian. % % Notice that there are other packages that contain facilities for % using the decimal comma as the correct decimal separator; for -% example |siunitx| defines a command |\num| that not only correctly +% example |SIunitx| defines a command |\num| that not only correctly % spaces the decimal separator, but also can change the input glyph % with another one, so that it is possible to copy and paste numbers % from texts in English (with the decimal point) and paste them % into the argument of the |\num| macro in an Italian document where % the decimal point is changed automatically into a decimal comma. Of -% course |siunitx| does much more than that; if it's being loaded, +% course |SIunitx| does much more than that; if it's being loaded, % then the default |\NoIntelligentComma| declaration disables the % functionality defined in this language description file and the % user can do what he desires with the many functionalities of that |