summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2025-01-31 22:08:28 +0000
committerKarl Berry <karl@freefriends.org>2025-01-31 22:08:28 +0000
commite9a61b1e3ecb83332a7a086ed8593995b0aa7575 (patch)
tree4143e04e4fb1ed0f39e19f0101fc93b832d41882 /Master/texmf-dist/source
parent3fb7b66f6de36cc0e912e465927c725e1ed603db (diff)
lettrine (31jan25)
git-svn-id: svn://tug.org/texlive/trunk@73660 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/source')
-rw-r--r--Master/texmf-dist/source/latex/lettrine/lettrine.dtx112
1 files changed, 84 insertions, 28 deletions
diff --git a/Master/texmf-dist/source/latex/lettrine/lettrine.dtx b/Master/texmf-dist/source/latex/lettrine/lettrine.dtx
index 93c7b201364..6393b735a6d 100644
--- a/Master/texmf-dist/source/latex/lettrine/lettrine.dtx
+++ b/Master/texmf-dist/source/latex/lettrine/lettrine.dtx
@@ -1,6 +1,6 @@
% \iffalse meta-comment
%
-% Copyright © 1999-2024 Daniel Flipo.
+% Copyright © 1999-2025 Daniel Flipo.
%
% This program can be distributed and/or modified under the terms
% of the LaTeX Project Public License either version 1.3c of this
@@ -107,7 +107,7 @@
\ProvidesFile{lettrine.dtx}
%</dtx>
%<*sty|dtx>
- [2024-11-14 v2.70 (Daniel Flipo)]
+ [2025-01-30 v2.80 (Daniel Flipo)]
%</sty|dtx>
% \fi
%
@@ -208,6 +208,17 @@
% paragraph starting with |\lettrine| to be rounded up to an integer
% number of |\baselineskip|. This option is meant for grid
% typesetting.
+%
+% \changes{v2.80}{2025/01/30}{New keyval option:
+% `nextpage’ (true/false), default is false.}
+%
+% \item \lopt{nextpage[=true]}; if a paragraph starting with a dropped
+% cap begins too low on a page to fit in, a warning is issued; this
+% flag controls whether the whole paragraph should be moved to the
+% top of next page or not. This option is not recommended, there are
+% often better fixes for such situations: reducing the dropped cap’s
+% height, shortening some previous paragraph, enlarging the page…
+%
% \item \lopt{novskip=}\meta{dimen} overrides |\DiscardVskip|
% (default=1pt). In some cases (see options \lopt{lraise},
% \lopt{loversize} or accentuated dropped capitals,…) the top of
@@ -313,6 +324,7 @@
% \item |\setlength{\DiscardVskip}{1pt}|,
% \item |\LettrineImagefalse|,
% \item |\LettrineOnGridfalse|,
+% \item |\LettrineMoveAtEOPfalse|,
% \item |\LettrineRealHeightfalse|.
% \end{itemize}
%
@@ -462,12 +474,18 @@
% \vspace{.5\baselineskip}
% \textbf{Known issues:}
% \begin{itemize}
-% \item Nothing is done to prevent page-breaking in a paragraph
-% starting with a dropped capital; when it happens to hang
-% into the footer, page-breaking has to be done manually.
+% \item Starting with version~2.80, the \pkg{lettrine} package
+% issues a warning in case a paragraph starting with a dropped
+% capital occurs at the end of some page thus requiring manual
+% page-breaking; it’s up to the user to figure out how to best
+% fix the issue (enlarging the page, shortening some previous
+% paragraph…). A new option \lopt{nextpage} has also been added,
+% when set to \lopt{true}, the whole paragraph is moved to the top
+% of next page… leaving a blank at the end of the previous page.
% \item |\lettrine| works within `quote’ `quotation’, `abstract’
-% environments but does not work within `center’ environments
-% except with option \texttt{[lines=1]}.
+% environments but does not work within `verse’ environments.
+% It doesn’t work either in `center’ environments except with
+% option \texttt{[lines=1]}.
% \item |\lettrine| does not work within lists.
% \item If |\lettrine| is used inside any environment, it is
% \emph{mandatory} to end the paragraph starting with the dropped
@@ -580,6 +598,7 @@
\newif\ifLettrineImage
\newif\ifLettrineOnGrid
\newif\ifLettrineRealHeight
+\newif\ifLettrineMoveAtEOP
% \end{macrocode}
%
% Then let’s define the necessary internal counters, lengths,
@@ -604,13 +623,14 @@
\newdimen\L@slope
\newdimen\L@height
\newdimen\L@novskip
-\newdimen\L@ruleht
\newdimen\L@target@ht
\newdimen\L@target@dp
\newdimen\L@target@tht
\newdimen\LettrineWidth
\newdimen\LettrineHeight
\newdimen\LettrineDepth
+\newdimen\L@finalht
+\newdimen\L@finaldp
\newcommand*{\L@file}{}
\newcommand*{\L@hang}{}
\newcommand*{\L@oversize}{}
@@ -618,6 +638,7 @@
\newcommand*{\L@ante}{}
\newif\ifL@image
\newif\ifL@grid
+\newif\ifL@nextpage
\newif\ifL@realh
\let\ifL@RTL\iffalse
\newcommand*{\L@viewport}{}
@@ -674,6 +695,7 @@
novskip.code = \setlength{\DiscardVskip}{#1} ,
image.if = LettrineImage ,
grid.if = LettrineOnGrid ,
+ nextpage.if = LettrineMoveAtEOP ,
realheight.if = LettrineRealHeight ,
refstring.default:n = \L@initial ,
refstring.store = \LettrineTestString ,
@@ -700,6 +722,7 @@
image.if = L@image ,
viewport.store = \L@viewport ,
grid.if = L@grid ,
+ nextpage.if = L@nextpage ,
realheight.if = L@realh ,
refstring.default:n = \L@initial ,
refstring.store = \L@refstring
@@ -803,14 +826,15 @@
% \draw[dashed] (1.5,2.3) -- (9,2.3);
% \draw[dashed] (1.5,1.2) -- (9,1.2);
% \draw[dashed] (0,0.1) -- (9,0.1);
-% \draw[<->] (0,0.1) -- (0,3.9);
-% \node[left] at (0,2.1) {tht};
+% \draw[<->] (-0.3,0.1) -- (-0.3,3.9);
+% \node[left] at (-0.3,2.1) {tht};
% \draw[<->] (1.3,0.1) -- (1.3,3.4);
-% \node[left] at (1.3,1.8) {dp};
+% \node[left] at (1.3,1.8) {finaldp};
% \draw[<->] (1,3.4) -- (1,3.9);
-% \node[left] at (1,3.7) {ht};
+% \node[left] at (1,3.7) {finalht};
% \end{tikzpicture}
-% \caption{Initial’s targeted dimensions ($\mbox{\cs{lines}}=4$)}
+% \caption{Initial’s targeted dimensions
+% ($\mbox{\cs{lines}}=4$, $\mbox{\cs{lraise}}=0$)}
% \label{fig:target}
% \end{figure}
%
@@ -850,7 +874,7 @@
\addtolength{\L@target@dp}{-\@tempdima}%
\else
\addtolength{\L@target@ht}{\L@target@dp}%
- \setlength{\L@target@dp}{0pt}%
+ \setlength{\L@target@dp}{\z@}%
\fi
\setlength{\L@target@tht}{\L@target@ht}%
\addtolength{\L@target@tht}{\L@target@dp}%
@@ -976,6 +1000,7 @@
\setlength{\L@novskip}{\DiscardVskip}%
\ifLettrineImage\L@imagetrue\else\L@imagefalse\fi
\ifLettrineOnGrid\L@gridtrue\else\L@gridfalse\fi
+ \ifLettrineMoveAtEOP\L@nextpagetrue\else\L@nextpagefalse\fi
\ifLettrineRealHeight\L@realhtrue\else\L@realhfalse\fi
% \end{macrocode}
%
@@ -1043,9 +1068,10 @@
\sbox{\L@tbox}{{\LettrineTextFont{#3}}}%
% \end{macrocode}
%
-% Start a new paragraph and compute in |\L@ruleht| the height of
-% the top part of the dropped capital which raises above the
-% paragraph’s first baseline.
+% Start a new paragraph and compute in |\L@finalht| the height of
+% the top part of the dropped capital which finally raises above
+% the paragraph’s first baseline and in |\L@finaldp| the final
+% depth of the dropped capital.
%
% \changes{v0.9}{1998/02/23}{Calculations of length
% \cs{L@first} changed. Do not `vskip’ small lengths ($<$0.2pt),
@@ -1055,29 +1081,30 @@
% vskips is now customisable through \cs{DiscardVskip} and option
% `novskip’.}
%
-% \changes{v1.2}{2002/03/13}{\cs{baselineskip} may be a
-% rubber length, we convert it to a dimen.}
-%
% The basis for |\L@raise| (and |\L@oversize|, see
% |\LettrineFont|) is |\L@target@tht|.
%
% \begin{macrocode}
\par
- \setlength{\L@ruleht}{\LettrineHeight}%
+ \setlength{\L@finalht}{\LettrineHeight}%
\setlength{\L@lraise}{\L@raise\L@target@tht}%
- \addtolength{\L@ruleht}{\L@lraise}%
+ \addtolength{\L@finalht}{\L@lraise}%
\ifnum\value{L@lines}>\@ne
\@tempcnta=\value{L@lines}%
\advance\@tempcnta \m@ne
- \addtolength{\L@ruleht}{-\@tempcnta\baselineskip}%
- \addtolength{\L@lraise}{-\L@target@dp}%
- \fi
+ \@tempdima=\@tempcnta\baselineskip
+ \addtolength{\L@finalht}{-\@tempdima}%
+ \setlength{\L@finaldp}{\@tempdima}%
+ \addtolength{\L@finaldp}{-\L@lraise}%
+ \addtolength{\L@finaldp}{\LettrineDepth}%
+ \addtolength{\L@lraise}{-\@tempdima}%
+ \fi
% \end{macrocode}
-% When |\L@ruleht| is larger than |\baselineskip - \L@novskip| and
+% When |\L@finalht| is larger than |\baselineskip - \L@novskip| and
% the \lopt{grid} option is \lopt{true}, let’s skip an integer number
% of |\baselineskip| (and smash the dropped cap, see below).
% \begin{macrocode}
- \@tempdima=\L@ruleht
+ \@tempdima=\L@finalht
\advance\@tempdima \L@novskip
\@tempdimb=\baselineskip
\ifdim\@tempdima>\@tempdimb
@@ -1182,6 +1209,34 @@
\else
\edef\L@parshape{\L@parshape \@totalleftmargin \the\linewidth}%
\fi
+% \end{macrocode}
+%
+% \changes{v2.80}{2025/01/30}{Move the paragraph to next page if the
+% dropped cap doesn’t fit in the current one.}
+%
+% Compute the remaining vertical space left on the current page
+% using TeX lengths |\pagetotal| and |\pagegoal|; always warn if
+% the remaining space is less than the depth of the dropped cap’
+% depth |\L@finaldp|.
+% Move the whole paragraph to next page if \lopt{nextpage=true}
+% (default is false).
+% \begin{macrocode}
+ \@tempdima=\pagegoal
+ \advance\@tempdima by -\pagetotal
+ \advance\@tempdima by -\baselineskip
+ \ifdim\@tempdima < \L@finaldp
+ \@tempdimb=\L@finaldp
+ \advance\@tempdimb by -\@tempdima
+ \PackageWarning{lettrine}{%
+ *** ATTENTION REQUIRED ***\MessageBreak
+ The dropped cap #2 doesn't fit on page \thepage.%
+ \MessageBreak Missing vertical space: \the\@tempdimb.
+ \MessageBreak
+ \ifL@nextpage The whole paragraph will be moved to
+ next page.\MessageBreak \fi
+ Reported}%
+ \ifL@nextpage \newpage \fi
+ \fi
\noindent
\parshape=\L@parshape\relax
% \end{macrocode}
@@ -1203,7 +1258,7 @@
% the rest of paragraph around it.
% \begin{macrocode}
\llap{\smash{\mbox{\L@ante}\raisebox{\L@lraise}{\usebox{\L@lbox}}}%
- \ifL@grid\else\rule{0pt}{\L@ruleht}\fi
+ \ifL@grid\else\rule{0pt}{\L@finalht}\fi
\hskip \the\L@Findent}%
\unhcopy\L@tbox\relax
% \end{macrocode}
@@ -1277,6 +1332,7 @@
%%\LettrineImagefalse
%%\LettrineOnGridfalse
%%\LettrineRealHeightfalse
+%%\LettrineMoveAtEOPfalse
%%
%% This is a *command*, define it as \relax if you dont want the second
%% mandatory argument of \lettrine[]{}{} to be typset in small caps.