summaryrefslogtreecommitdiff
path: root/macros/latex/contrib/lettrine/lettrine.dtx
diff options
context:
space:
mode:
Diffstat (limited to 'macros/latex/contrib/lettrine/lettrine.dtx')
-rw-r--r--macros/latex/contrib/lettrine/lettrine.dtx98
1 files changed, 48 insertions, 50 deletions
diff --git a/macros/latex/contrib/lettrine/lettrine.dtx b/macros/latex/contrib/lettrine/lettrine.dtx
index 3c1a191780..4f17f5f6b6 100644
--- a/macros/latex/contrib/lettrine/lettrine.dtx
+++ b/macros/latex/contrib/lettrine/lettrine.dtx
@@ -106,7 +106,7 @@
\ProvidesFile{lettrine.dtx}
%</dtx>
%<*sty|dtx>
- [2023-07-04 v2.51 (Daniel Flipo)]
+ [2023-08-14 v2.52 (Daniel Flipo)]
%</sty|dtx>
% \fi
%
@@ -182,10 +182,21 @@
% this requires the |graphicx| package to be loaded in the preamble.
% |\lettrine[image=true]{A}{n exemple}|\quad or just\\
% |\lettrine[image]{A}{n exemple}|\\
-% will load |A.eps|, |A.jpg|, |A.png| or |A.pdf| instead of letter~A.\\
-% N.B.: Redefining |\LettrineFont| as |\LettrineFontEPS| is no longer
-% supported and |\LettrineFontEPS| has been renamed as
-% |\LettrineImage|.
+% will load |A.eps|, |A.jpg|, |A.png| or |A.pdf| instead of letter~A.
+%
+% \changes{v2.52}{2023/08/14}{New option`viewport’ to be passed to
+% \cs{includegraphics}.}
+%
+% \item \lopt{viewport=}\meta{llx lly urx ury} is passed to
+% |\includegraphics| (same four dimen parameters); when present,
+% |\lettrine| only considers the contents of the rectangle defined by
+% its lower left and upper right corners to compute the size of the
+% final image. It’s up to the user to deal with the rest of the
+% image… f.i.\ providing a |\vspace*{...}| in case a significant part
+% sticks out on top of the defined rectangle. This option may be
+% useful in some special cases, see
+% \url{https://tex.stackexchange.com/questions/693270/} or when the
+% image’s bounding box is inaccurate.
%
% \changes{v1.8}{2015/02/06}{Added two keyval options:
% `grid’ (true/false) and `novskip’ to override \cs{DiscardVskip}.}
@@ -276,8 +287,9 @@
% specified as options passed to the \pkg{lettrine} \emph{package}.
% These options are the same as those of the |\lettrine| command
% previously described%
-% \footnote{With the exception of \lopt{ante} which doesn’t make
-% sense for a global usage.}: f.i. |\usepackage[lines=3]{lettrine}|
+% \footnote{With the exception of \lopt{ante} and \lopt{viewport}
+% which do not make sense for a global usage.}:
+% f.i.\ |\usepackage[lines=3]{lettrine}|
% will set the default to three lines of text.
% Options passed to the \pkg{lettrine} package override the defaults
% set in the \file{lettrine.cfg} file (see below) and will be
@@ -333,7 +345,7 @@
%
% A hook |\LettrineFontHook| is provided to change the font
% used for the dropped capital, syntax follows LaTeX’s
-% low-level font interface (see LaTeX Companion, p.187--192),
+% low-level font interface (see LaTeX Companion III, section~I-9.3),
% the |\selectfont| command is issued by |\LettrineFont|:\\
% |\renewcommand{\LettrineFontHook}{\fontfamily{ppl}|\ignorespaces
% |\fontseries{bx}%|\\
@@ -354,7 +366,7 @@
% mention the cm-super fonts and the type1ec package by
% Vladimir Volovich.}
%
-% \vspace{\baselineskip}
+% \vspace{.5\baselineskip}
% \textbf{Important notice:}
% the sizing works fine with \emph{fully scalable} fonts (like the
% standard PostScript or OpenType fonts), but might not work well
@@ -386,7 +398,7 @@
% (Palatino, Times, Utopia…), or any OpenType font, they are
% fully scalable too!
%
-% \newpage
+% \vspace{.5\baselineskip}
% \textbf{Breaking change in version~2.50:} in order to improve the
% alignment of side by side parboxes starting with a dropped cap, the
% internals of the |\lettrine{}| command have changed. Formerly, the
@@ -404,6 +416,7 @@
% for an example. Using the rollback mechanism to switch back to
% version~2.40 is another option: |\usepackage{lettrine}[=v2.4]|.
%
+% \vspace{.5\baselineskip}
% \textbf{Known issues:}
% \begin{itemize}
% \item Nothing is done to prevent page-breaking in a paragraph
@@ -552,6 +565,7 @@
\newif\ifL@image
\newif\ifL@grid
\newif\ifL@realh
+\newcommand*{\L@viewport}{}
% \end{macrocode}
%
% \begin{macro}{\LettrineTestString}
@@ -606,7 +620,7 @@
image.if = LettrineImage ,
grid.if = LettrineOnGrid ,
realheight.if = LettrineRealHeight ,
- refstring.default:n = \l@initial ,
+ refstring.default:n = \L@initial ,
refstring.store = \LettrineTestString ,
optionsfile.store = \DefaultOptionsFile
}
@@ -629,10 +643,11 @@
slope.code = \setlength{\L@slope}{#1} ,
novskip.code = \setlength{\L@novskip}{#1} ,
image.if = L@image ,
+ viewport.store = \L@viewport ,
grid.if = L@grid ,
realheight.if = L@realh ,
- refstring.default:n = \l@initial ,
- refstring.store = \l@refstring
+ refstring.default:n = \L@initial ,
+ refstring.store = \L@refstring
}
% \end{macrocode}
%
@@ -770,10 +785,10 @@
% In most cases, the default is a better choice .
% \begin{macrocode}
\def\compute@fontsize{%
- \ifx\l@refstring\@empty
+ \ifx\L@refstring\@empty
\def\Lettrine@RefString{\LettrineTestString}%
\else
- \def\Lettrine@RefString{\l@refstring}%
+ \def\Lettrine@RefString{\L@refstring}%
\fi
\sbox{\@tempboxa}{\LettrineFontHook
\fontsize{\L@height}{\L@height}\selectfont
@@ -803,30 +818,6 @@
% \end{macrocode}
% \end{macro}
%
-% \changes{v0.9}{1998/03/13}{\cs{LettrineFontEPS} added.}
-%
-% \changes{v2.21}{2018/08/28}{\cs{LettrineFontEPS} renamed as
-% \cs{LettrineImage}.}
-%
-% \begin{macro}{\LettrineImage}
-% The following definition is for use with dropped capitals defined
-% as images: EPS, PDF, JPG, PNG files (see examples in
-% lettrine-demo-fr.tex).
-% Its requires the |graphicx| package to be loaded in the
-% preamble with |\usepackage{graphicx}|. The image’s height is
-% computed just as in the standard case and passed to
-% |\includegraphics|.
-%
-% \changes{v1.6}{2004/05/22}{Added \cs{LettrineFontHook}
-% to \cs{LettrineFontEPS}. This is needed for color options.}
-%
-% \begin{macrocode}
-\newcommand*{\LettrineImage}{%
- \LettrineFontHook\includegraphics[height=\L@height]%
-}
-% \end{macrocode}
-% \end{macro}
-%
% \begin{macro}{\setupL@lbox}
% The next (internal) command computes the requested size for the
% initial (letter or image) and prepares a box |\L@lbox| holding it.
@@ -834,10 +825,17 @@
\def\setupL@lbox{%
\computeL@height
\ifL@image
- \sbox{\L@lbox}{\LettrineImage{\l@initial}}%
+ \ifx\L@viewport\@empty
+ \sbox{\L@lbox}{\includegraphics[height=\L@height]{\L@initial}}%
+ \else
+ \sbox{\L@lbox}{%
+ \expanded{\noexpand\includegraphics%
+ [viewport=\L@viewport, height=\L@height]{\L@initial}%
+ }}%
+ \fi
\else
\compute@fontsize
- \sbox{\L@lbox}{\LettrineFont \l@initial}%
+ \sbox{\L@lbox}{\LettrineFont \L@initial}%
\fi
}
% \end{macrocode}
@@ -854,18 +852,18 @@
%
% \begin{macrocode}
\newcommand*{\LettrineOptionsFor}[2]{%
- \edef\l@tmpa{#1}%
+ \edef\L@tmpa{#1}%
% \end{macrocode}
% Gobble potential color commands for the initial.
% \begin{macrocode}
\begingroup
- \def\color##1##{\l@color{##1}}%
- \let\l@color\@gobbletwo
- \def\textcolor##1##{\l@textcolor{##1}}%
- \def\l@textcolor##1##2##3{##3}%
- \xdef\l@tmpb{\l@initial}%
+ \def\color##1##{\L@color{##1}}%
+ \let\L@color\@gobbletwo
+ \def\textcolor##1##{\L@textcolor{##1}}%
+ \def\L@textcolor##1##2##3{##3}%
+ \xdef\L@tmpb{\L@initial}%
\endgroup
- \ifx\l@tmpa\l@tmpb \SetKeys[LettrineLocal]{#2}\fi
+ \ifx\L@tmpa\L@tmpb \SetKeys[LettrineLocal]{#2}\fi
}
% \end{macrocode}
% \end{macro}
@@ -876,7 +874,7 @@
% \begin{macrocode}
\def\lettrine{\@ifnextchar[\@lettrine{\@lettrine[]}}
\def\@lettrine[#1]#2#3{%
- \def\l@initial{#2}\let\l@refstring\@empty
+ \def\L@initial{#2}\def\L@refstring{}\def\L@viewport{}%
% \end{macrocode}
%
% \changes{v1.9}{2015/08/31}{\cs{theDefaultLines} changed to
@@ -930,7 +928,7 @@
% config file \cs{DefaultOptionsFile}.}
% 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
+% global command |\L@LOKeys| which will expand to the list of
% options given by |\LettrineOptionsFor| for the current initial
% (defined by |#2|)…
%