diff options
author | Karl Berry <karl@freefriends.org> | 2015-09-01 21:52:57 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2015-09-01 21:52:57 +0000 |
commit | 75091deb3b48945ab52aad64b2a982ed76fc5e0e (patch) | |
tree | 0a2cab1dcf599f6d4f17e230cb545b49562b76d8 /Master/texmf-dist/source/latex/lettrine/lettrine.dtx | |
parent | 7a522185776d442b4d6576cced53c99d2ab1f6ad (diff) |
lettrine (1sep15)
git-svn-id: svn://tug.org/texlive/trunk@38268 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source/latex/lettrine/lettrine.dtx')
-rw-r--r-- | Master/texmf-dist/source/latex/lettrine/lettrine.dtx | 243 |
1 files changed, 176 insertions, 67 deletions
diff --git a/Master/texmf-dist/source/latex/lettrine/lettrine.dtx b/Master/texmf-dist/source/latex/lettrine/lettrine.dtx index b7f99480c1c..46391279324 100644 --- a/Master/texmf-dist/source/latex/lettrine/lettrine.dtx +++ b/Master/texmf-dist/source/latex/lettrine/lettrine.dtx @@ -1,5 +1,5 @@ % -% \CheckSum{525} +% \CheckSum{567} % % \iffalse meta-comment % @@ -30,7 +30,7 @@ \ProvidesFile{lettrine.dtx} %</dtx> %<*!cfg> - [2015/02/16 v1.8 (Daniel Flipo)] + [2015/08/31 v1.9 (Daniel Flipo)] %</!cfg> % % Lettrine package for LaTeX version 2e @@ -41,6 +41,7 @@ % %<*driver> \documentclass[a4paper]{ltxdoc} +\usepackage[utf8]{inputenc} \usepackage{lettrine} \GetFileInfo{lettrine.dtx} \RecordChanges @@ -85,8 +86,8 @@ % of the dropped capital and match the requirements described % in the books % \begin{itemize} -% \item ``Lexique des r\`egles typographiques en usage \`a -% l'Imprimerie nationale'' troisi\`eme \'edition (1994), +% \item ``Lexique des règles typographiques en usage à +% l'Imprimerie nationale'' troisième édition (1994), % ISBN-2-11-081075-0, % \item ``Mise en page et impression'' Yves~\textsc{Perrousseaux}, % ISBN-2-911220-01-3. @@ -165,6 +166,42 @@ % Consider enlarging |novskip| (or |\DiscardVskip|) to % prevent small vertical skips from being rounded up to % |\baselineskip| when using the `grid' option. +% +% \changes{lettrine-1.9}{2015/08/31}{New keyval option: `realheight' +% (true/false) and new global flag \cs{ifLettrineRealHeight}.} +% +% \item |realheight=|\emph{$<$true$>$} (new to version 1.9) will +% compute the default height of the lettrine so that the +% top of it is exactly aligned with the top of the text +% entered as second mandatory argument of |\lettrine| +% taking possible accents into account. +% Otherwise, the default height is computed using a +% customisable string |\LettrineSecondString| instead of +% the real argument. For backward compatibility, option +% |realheight| defaults to false and +% |\LettrineSecondString| to `x'. +% +% You probably don't need this option if you choose to +% typeset the second mandatory argument of |\lettrine| in +% small caps (the default). If you change +% |\LettrineTextFont| to |\relax| or |\upshape|, consider +% these two examples: +% \begin{description} +% \item |\lettrine{H}{ello}| you probably would like the +% top of the `L' to be aligned with the top of the `ll' +% rather than with the top of the `e', adding option +% |realheight| does the trick: +% |\lettrine[realheight]{H}{ello}|.\par +% Global variants : |\LettrineRealHeighttrue| or (without +% the |realheight| option) +% |\renewcommand{\LettrineSecondString}{l}|. +% \item |\lettrine{L}{a misère}| option |realheight=true| +% would align with the top of the `L' with the top of the +% grave accent, the default is probably better (top of +% the `L' aligned with the top of the non accented +% letters). +% \end{description} +% % \end{itemize} % % Example: |\lettrine[lines=4, lraise=0.1, nindent=0em, |% @@ -186,6 +223,9 @@ % on \file{lettrine.ins} to extract it), compile and print % \file{demo.tex} to see the possible usage of these parameters. % +% \changes{lettrine-1.9}{2015/08/31}{New customisable string +% \cs{LettrineSecondString} to tune the lettrine's height.} +% % The default settings can be customized either in a config file % \file{lettrine.cfg} (for a global usage), or on a per document % basis, in the preamble of each document. The following list @@ -193,10 +233,12 @@ % \begin{itemize} % \item |\setcounter{DefaultLines}{2}|, % \item |\setcounter{DefaultDepth}{0}|, -% \item |\renewcommand{\DefaultLoversize}{0}|, -% \item |\renewcommand{\DefaultLraise}{0}|, -% \item |\renewcommand{\DefaultLhang}{0}|, +% \item |\renewcommand*{\DefaultLoversize}{0}|, +% \item |\renewcommand*{\DefaultLraise}{0}|, +% \item |\renewcommand*{\DefaultLhang}{0}|, % \item |\LettrineImagefalse|, +% \item |\LettrineOnGridfalse|, +% \item |\LettrineRealHeightfalse|, % \item |\setlength{\DefaultFindent}{0pt}|, % \item |\setlength{\DefaultNindent}{0.5em}|, % \item |\setlength{\DefaultSlope}{0pt}|. @@ -226,7 +268,7 @@ % usually the current font in a (large) size, computed % automatically from the number of lines it will fill: % the font size is computed so that, a \emph{standard} dropped -% capital (say X, not \`A) when sitting on its baseline, gets +% capital (say X, not À) when sitting on its baseline, gets % its top aligned with the top of the following text (provided % $|loversize|=0$ and $|lines|\ge 2$). When $|lines|=1$, % size is computed as if |lines| was~2.\\ @@ -319,7 +361,7 @@ % % \changes{lettrine-1.2}{2002/03/13}{\cs{newlength} changed to % \cs{newdimen}, to correct a bug with seminar.cls (pointed out -% by Peter M\"unster).} +% by Peter Münster).} % % \changes{lettrine-1.6}{2004/05/22}{Added newif \cs{ifLettrineImage}.} % @@ -345,6 +387,7 @@ \setlength{\DiscardVskip}{0.2\p@} \newif\ifLettrineImage \newif\ifLettrineOnGrid +\newif\ifLettrineRealHeight % \end{macrocode} % % Then let's define the necessary internal counters, lengths, @@ -375,6 +418,7 @@ \newcommand*{\L@ante}{} \newif\ifL@image \newif\ifL@grid +\newif\ifL@realh % \end{macrocode} % % Provide commands for the fonts used to typeset the two @@ -392,11 +436,19 @@ % The default size for the dropped capital is computed so that the % top of it is exactly aligned with the top of the following text; % an extra height (positive or negative) may be added with -% |Defaultloversize| or an optional argument |loversize=|. +% |Defaultloversize| or with an optional argument |loversize=|. % If |lines=1|, the default size for the dropped capital is % computed as if |lines=2|. +% % |\Lettrine@height| computes the wished height for the dropped -% capital and stores it into |\L@height|. +% capital and stores it into |\L@height|. |\L@height| depends only +% on |L@lines|, |\L@oversize| and, in case option |realheight=true| +% on the height of |\L@tbox|. So options \emph{must} be read and +% |\L@tbox| must be properly initialised \emph{before} executing +% |\Lettrine@height| (see below in |\@lettrine| code). A default +% initialisation of |\L@tbox| is provided just in case +% |\LettrineFont| would be used outside |\lettrine|. +% % As |\baselineskip| might be a rubber length, we convert it into % a `dimen' using |\@tempdima|. % |\LettrineFontHook| enables to select another font for the @@ -414,20 +466,28 @@ % \cs{LettrineTestString} which defaults to % `ABCDEFGHIJKLMNOQPRSTUVWXYZ'. In previous versions height % computations were based on letter `X' which might not exist -% in some (rare) fonts. Pointed out by Rapha\"el Pinson.} +% in some (rare) fonts. Pointed out by Raphaël Pinson.} +% +% \changes{lettrine-1.9}{2015/08/31}{\cs{theL@lines} changed +% to \cs{value\{L@lines\}}. Needed for babel-hebrew which +% redefines \cs{@arabic}.} % % \begin{macrocode} \def\Lettrine@height{% \@tempdima=\baselineskip - \setlength{\L@height}{\theL@lines\@tempdima}% - \ifnum\theL@lines>1 + \setlength{\L@height}{\value{L@lines}\@tempdima}% + \ifnum\value{L@lines}>1 \addtolength{\L@height}{-\@tempdima}% \fi - \sbox{\L@tbox}{\LettrineTextFont x}% + \ifvoid\L@tbox + \sbox{\L@tbox}{\LettrineTextFont{\LettrineSecondString}}% + \fi \addtolength{\L@height}{\ht\L@tbox}% - \addtolength{\L@height}{\L@oversize\L@height}} + \addtolength{\L@height}{\L@oversize\L@height}% +} \newcommand*{\LettrineFontHook}{} \newcommand*{\LettrineTestString}{ABCDEFGHIJKLMNOQPRSTUVWXYZ} +\newcommand*{\LettrineSecondString}{x} \newcommand*{\LettrineFont}{% \Lettrine@height % \end{macrocode} @@ -440,13 +500,13 @@ % some special font, |\LettrineTestString| can be customised to any % non empty subset of capitals. % \begin{macrocode} - \sbox{\L@tbox}{\LettrineFontHook\fontsize{\L@height}{\L@height}% - \selectfont \LettrineTestString}% + \sbox{\@tempboxa}{\LettrineFontHook\fontsize{\L@height}{\L@height}% + \selectfont \LettrineTestString}% % \end{macrocode} % Arithmetic calculations convert the dimensions into integers % (in sp) and compute a (4 decimal accurate) scaling factor. % \begin{macrocode} - \@tempcntb=\ht\L@tbox + \@tempcntb=\ht\@tempboxa \@tempcnta=\L@height \multiply\@tempcnta by 100 \divide\@tempcntb by 100 @@ -481,7 +541,8 @@ % \begin{macrocode} \newcommand*{\LettrineFontEPS}{% \Lettrine@height\LettrineFontHook - \includegraphics[height=\L@height]} + \includegraphics[height=\L@height]% +} % \end{macrocode} % \end{macro} % @@ -499,6 +560,7 @@ \define@key{L}{slope}{\setlength{\L@slope}{#1}} \define@key{L}{image}[true]{\csname L@image#1\endcsname} \define@key{L}{grid}[true]{\csname L@grid#1\endcsname} +\define@key{L}{realheight}[true]{\csname L@realh#1\endcsname} \define@key{L}{novskip}{\setlength{\L@novskip}{#1}} % \end{macrocode} % @@ -532,10 +594,15 @@ % % \changes{lettrine-0.81}{1997/02/26}{\cs{DefaultLoversize} added.} % +% \changes{lettrine-1.9}{2015/08/31}{\cs{theDefaultLines} changed to +% \cs{value\{DefaultLines\}}, same with \cs{theDefaultDepth}. +% Needed for babel-hebrew which redefines \cs{@arabic}. +% Thanks to Ulrike Fischer for providing the fix.} +% % First reset the parameters to their default values: % \begin{macrocode} - \setcounter{L@lines}{\theDefaultLines}% - \setcounter{L@depth}{\theDefaultDepth}% + \setcounter{L@lines}{\value{DefaultLines}}% + \setcounter{L@depth}{\value{DefaultDepth}}% \renewcommand*{\L@hang}{\DefaultLhang}% \renewcommand*{\L@oversize}{\DefaultLoversize}% \renewcommand*{\L@raise}{\DefaultLraise}% @@ -546,10 +613,38 @@ \setlength{\L@novskip}{\DiscardVskip}% \ifLettrineImage\L@imagetrue\else\L@imagefalse\fi \ifLettrineOnGrid\L@gridtrue\else\L@gridfalse\fi + \ifLettrineRealHeight\L@realhtrue\else\L@realhfalse\fi +% \end{macrocode} +% +% |\LettrineFont| and |\LettrineFontEPS| both call +% |\Lettrine@height| to set |\L@height| which depends on +% |\L@tbox|. The content of |\L@tbox| depends on option +% |realheight|, so we have to read the lettrine's options +% and initialise the |\L@tbox| content now% +% \footnote{Now means before eventually reading the config file.}. +% +% \changes{lettrine-1.9}{2015/08/31}{Use the second mandatory +% argument of \cs{lettrine} or \cs{LettrineSecondString} (which +% defaults to `x') to compute \cs{L@height}. This is controlled by +% the `realheight' flag.} +% +% \begin{macrocode} + \setkeys{L}{#1}% + \sbox{\L@tbox}{\LettrineTextFont{\LettrineSecondString}}% + \ifL@realh + \def\@tempa{#3} + \ifx\@tempa\@empty + \PackageWarning{lettrine.sty}% + {Empty second argument,\MessageBreak + ignoring option `realheight';}% + \else + \sbox{\L@tbox}{\LettrineTextFont{#3}}% + \fi + \fi % \end{macrocode} % \changes{lettrine-1.5}{2003/08/18}{Added reading of an optional % config file \cs{DefaultOptionsFile}.} -% then try to read an optional file (its name is given by +% Then try to read an optional file (its name is given by % |\DefaultOptionsFile|), do this inside a group, and define a % global command |\l@LOKeys| which will expand to the list of % options given by |\LettrineOptionsFor| for the current lettrine @@ -599,17 +694,17 @@ \def\KV@prefix{KV@L@}% \let\@tempc\relax \expandafter\KV@do\l@LOKeys,\relax, - \fi % \end{macrocode} -% Finally read the optional argument: the |keyval| package will -% set the parameters mentioned calling |\define@key| (see above). +% As local options prevail on those held in the config file, we +% have to read local options again: % \begin{macrocode} - \setkeys{L}{#1}% + \setkeys{L}{#1}% + \fi % \end{macrocode} -% Save the two mandatory arguments of |\lettrine| into -% two boxes, this will help measuring their sizes. -% Depending on the boolean |image|, |\LettrineFont| or -% |\LettrineFontEPS| is used. +% Options and optional config file have be taken into account, we +% can now save the first mandatory argument of |\lettrine| properly +% scaled into |\L@lbox|. Depending on the boolean |image|, +% |\LettrineFont| or |\LettrineFontEPS| is used. % \begin{macrocode} \ifL@image \sbox{\L@lbox}{\LettrineFontEPS{#2}}% @@ -617,6 +712,8 @@ \sbox{\L@lbox}{\LettrineFont #2}% \fi % \end{macrocode} +% Height calculations done, let's reset |\L@tbox|'s content +% (mandatory in case |realheight=false|): % % \changes{lettrine-1.6}{2004/05/22}{Add braces around \#3 to allow % commands taking an argument (such as \cs{MakeLowercase}) in @@ -625,6 +722,7 @@ % \begin{macrocode} \sbox{\L@tbox}{\LettrineTextFont{#3}}% % \end{macrocode} +% % Start a new paragraph, skipping the necessary amount of space % if the dropped capital sticks out the top of paragraph. % We use |\L@first| to compute the amount of space to be skipped. @@ -643,52 +741,52 @@ % rubber length, we convert it to a dimen.} % % \begin{macrocode} - \@tempdima=\baselineskip - \ifnum\theL@lines=1 - \setlength{\L@first}{\ht\L@lbox}% - \addtolength{\L@first}{-\ht\L@tbox}% - \setlength{\L@lraise}{\z@}% - \else - \setlength{\L@first}{-\theL@lines\@tempdima}% - \addtolength{\L@first}{\@tempdima}% - \sbox{\@tempboxa}{\LettrineTextFont x}% - \addtolength{\L@first}{-\ht\@tempboxa}% + \@tempdima=\baselineskip + \ifnum\value{L@lines}=1 + \setlength{\L@first}{\ht\L@lbox}% + \addtolength{\L@first}{-\ht\L@tbox}% + \setlength{\L@lraise}{\z@}% + \else + \setlength{\L@first}{-\value{L@lines}\@tempdima}% + \addtolength{\L@first}{\@tempdima}% + \sbox{\@tempboxa}{\LettrineTextFont x}% + \addtolength{\L@first}{-\ht\@tempboxa}% % \end{macrocode} % Now, |\L@first| holds (the opposite of) the raw height of a % standard dropped capital (like~'X'), excluding the effect of % |\L@oversize|. This is the basis for |\L@raise| % (and |\L@oversize|, see |\LettrineFont|). % \begin{macrocode} - \setlength{\L@lraise}{-\L@raise\L@first}% - \addtolength{\L@first}{\L@lraise}% - \addtolength{\L@first}{\ht\L@lbox}% - \addtolength{\L@lraise}{-\theL@lines\@tempdima}% - \addtolength{\L@lraise}{\@tempdima}% - \fi - \par + \setlength{\L@lraise}{-\L@raise\L@first}% + \addtolength{\L@first}{\L@lraise}% + \addtolength{\L@first}{\ht\L@lbox}% + \addtolength{\L@lraise}{-\value{L@lines}\@tempdima}% + \addtolength{\L@lraise}{\@tempdima}% + \fi + \par % \end{macrocode} % |\L@first| now holds the height of the needed |\vskip|; if too % small it will be discarded. % \begin{macrocode} - \ifdim\L@first>\L@novskip + \ifdim\L@first>\L@novskip % \end{macrocode} % When the `grid' option is true, let's round up |\L@first| to the % next integer number of |\baselineskip|. % \begin{macrocode} - \ifL@grid - \@tempdima=\baselineskip - \@tempdimb=\@tempdima - \advance\@tempdimb by \L@novskip - \@tempcnta=1 - \loop\ifdim\L@first>\@tempdimb + \ifL@grid + \@tempdima=\baselineskip + \@tempdimb=\@tempdima + \advance\@tempdimb by \L@novskip + \@tempcnta=1 + \loop\ifdim\L@first>\@tempdimb \advance\@tempcnta by 1 \advance\L@first by -\@tempdima - \repeat - \vskip\@tempcnta\baselineskip - \else - \vskip\L@first - \fi - \fi + \repeat + \vskip\@tempcnta\baselineskip + \else + \vskip\L@first + \fi + \fi % \end{macrocode} % Again, we (mis)use the length |\L@first| to compute the width of % the text eventually coming before the dropped capital. It is @@ -730,6 +828,7 @@ % \end{macrocode} % \changes{lettrine-1.65}{2014/09/04}{Measure and store the lettrine's % final dimensions.} +% Store the lettrine's final dimensions: % \begin{macrocode} \setlength{\LettrineWidth}{\wd\L@lbox}% \setlength{\LettrineHeight}{\ht\L@lbox}% @@ -737,9 +836,13 @@ % \end{macrocode} % Now, set up the shape of the new paragraph (designed by % |\parshape|). +% +% \changes{lettrine-1.9}{2015/08/31}{\cs{theL@depth} changed to +% \cs{value\{L@depth\}}.} +% % \begin{macrocode} \addtocounter{L@lines}{1}% - \addtocounter{L@lines}{\the\c@L@depth}% + \addtocounter{L@lines}{\value{L@depth}}% \def\L@parshape{\c@L@lines \the\L@Pindent \the\L@first}% \@tempcnta=\tw@ \@whilenum \@tempcnta<\c@L@lines\do{% @@ -775,7 +878,7 @@ %</sty> % \fi % -% \section{Fichier de configuration} +% \section{Configuration file} % % \iffalse %<*cfg> @@ -791,11 +894,12 @@ %% your needs (see lettrine.dtx). %% %%\setcounter{DefaultLines}{2} +%%\setcounter{DefaultDepth}{0} %% %% These are *decimal* numbers: -%%\renewcommand{\DefaultLoversize}{0} -%%\renewcommand{\DefaultLraise}{0} -%%\renewcommand{\DefaultLhang}{0} +%%\renewcommand*{\DefaultLoversize}{0} +%%\renewcommand*{\DefaultLraise}{0} +%%\renewcommand*{\DefaultLhang}{0} %% %% These are *lengths* (don't forget the unit): %%\setlength{\DefaultFindent}{0pt} @@ -806,6 +910,11 @@ %% Theses are *flags* (value=true/false): %%\LettrineImagefalse %%\LettrineOnGridfalse +%%\LettrineRealHeightfalse +%% +%% Theses are *commands* (value=string, only its height matters): +%%\renewcommand*{\LettrineTestString}{ABCDEFGHIJKLMNOQPRSTUVWXYZ} +%%\renewcommand*{\LettrineSecondString}{x} %% %% In case you want to set parameters for some letters %% in file `optfile.cfl' @@ -844,5 +953,5 @@ %%% Local Variables: %%% fill-column: 70 -%%% coding: us-ascii +%%% coding: utf-8 %%% End: |