% \iffalse meta-comment
%
% 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
% license or (at your option) any later version.
% The latest version of this license is in
%    http://www.latex-project.org/lppl.txt
% and version 1.3c or later is part of all distributions of LaTeX
% version 2005/12/01 or later.
%
% This file has the LPPL maintenance status "maintained".
%
%<*batch>
%<*gobble>
\ifx\jobname\relax\let\documentclass\undefined\fi
\ifx\documentclass\undefined
\csname fi\endcsname
%</gobble>
\input docstrip.tex
\keepsilent
\let\MetaPrefix\relax
\preamble
\endpreamble
\postamble
\endpostamble
\let\MetaPrefix\DoubleperCent
\askforoverwritefalse
\generate{\file{lettrine.sty}{\from{lettrine.dtx}{sty}}
          \nopreamble
          \file{lettrine.cfg}{\from{lettrine.dtx}{cfg}}
         }
\endbatchfile
%</batch>
%<*gobble>
\fi
\expandafter\ifx\csname @currname\endcsname\empty
\csname fi\endcsname
%</gobble>
%<*driver>
\DocumentMetadata{pdfstandard=UA-2, lang=en-GB}
\documentclass[a4paper,british]{ltxdoc}
\usepackage{babel,varioref}
\usepackage[dvipsnames]{xcolor}
\usepackage{unicode-math}
\setmainfont{erewhon}
\setsansfont{Cabin}[Scale=MatchLowercase]
\setmonofont{Inconsolatazi4}[Scale=MatchLowercase, Color=Sepia,
                             HyphenChar=None,StylisticSet={2,3},
                            ]
\setmathfont{Erewhon-Math.otf}
\usepackage{fourier-orns}
\usepackage[expansion=true,protrusion=true]{microtype}
\usepackage{url}
\usepackage[numbered]{hypdoc}
\hypersetup{pdftitle={Lettrine User’s Guide},
            pdfauthor={Daniel FLIPO},
            colorlinks
            }
\usepackage{lettrine}
\usepackage{tikz}
\usetikzlibrary{shapes.arrows}
\renewcommand{\labelitemi}{\starredbullet}
%
\RecordChanges
\AtEndDocument{%
  \clearpage
  \section{Change History}%
   \GlossaryPrologue{}%
   Changes are listed in reverse order (latest first) from version~1.5
   \PrintChanges
}
%
\newcommand*\file[1]{\texttt{#1}}
\newcommand*\lopt[1]{\texttt{#1}}
\renewcommand\meta[1]{\textit{\color{Sepia}<#1>}} % no math mode (see doc.sty)
%
\setlength{\parindent}{0pt}
\setlength{\parskip}{.3\baselineskip}
\begin{document}
\GetFileInfo{lettrine.sty}
\begin{center}
  \textbf{\Large Typesetting dropped capitals with LaTeX}
  \\[.5\baselineskip]^^A\]
  {\large Daniel Flipo}\\
  \texttt{daniel.flipo@free.fr}
\end{center}
\DocInput{lettrine.dtx}
\end{document}
%</driver>
%<*gobble>
\fi
%</gobble>
% \fi
%
% \iffalse
%
%<*sty>
%% IMPORTANT NOTICE:
%% For the copyright see the source file `lettrine.dtx’.
%%
\NeedsTeXFormat{LaTeX2e}[2022-06-01]
\ProvidesFile{lettrine.sty}
%</sty>
%<*dtx>
\ProvidesFile{lettrine.dtx}
%</dtx>
%<*sty|dtx>
             [2025-12-06 v2.83 (Daniel Flipo)]
%</sty|dtx>
% \fi
%
%  \section{Introduction}
%
%    The file \file{\filename}\footnote{The file described in this
%    section has version number \fileversion\ and was last revised on
%    \filedate.}, provides a command |\lettrine| which requires two
%    mandatory arguments, and an optional one.
%
% \changes{v2.23}{2020/03/14}{Documentation cleanup.}
%
%    Adding |\usepackage{lettrine}| in the preamble of a document
%    defines the command |\lettrine|, the simplest use of which is
%    |\lettrine{|\meta{letter}|}{|\meta{text}|}|.
%    It produces a dropped capital \meta{letter} (2 lines high),
%    followed by \meta{text} typeset in small caps, and the rest
%    of the paragraph is wrapped around the dropped capital.
%
%    The |\lettrine[|\meta{options}|]{|\meta{letter}|}{|\meta{text}|}|
%    command accepts various optional arguments to control the size and
%    layout of the dropped capital and match the requirements described
%    in the books
%    \begin{itemize}
%    \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~Perrousseaux,
%           ISBN-2-911220-01-3.
%    \end{itemize}
%    The parameters can be set using the \texttt{key=value} syntax:
%    \begin{itemize}
%      \item \lopt{lines=}\meta{integer} sets how many lines the
%            dropped capital will occupy (default=2);
%
% \changes{v1.7}{2014/09/16}{New counter to add lines for
%    dropped capitals with positive depth, like Q.}
%
%  \item \lopt{depth=}\meta{integer} sets the number of lines to be
%    reserved under the baseline, this is meant for dropped capital with
%    positive depth, like Q (default=0);
%  \item \lopt{lhang=}\meta{decimal} ($0\le|lhang|\le1$) sets how much
%    of the dropped capital’s width should hang into the margin
%    (default=0);
%  \item \lopt{loversize=}\meta{decimal} ($-1<\lopt{loversize}\le1$)
%    enlarges the dropped capital’s height: with \lopt{loversize=0.1}
%    its height is enlarged by 10\% so that it raises above the top
%    paragraph’s line (default=0);
%  \item \lopt{lraise=}\meta{decimal} does not affect the dropped
%    capital’s height, but moves it up (if positive), down (if
%    negative); useful with capitals like |J| or |Q| which have
%    a positive depth, (default=0);
%  \item \lopt{findent=}\meta{dimen} (positive or negative) controls the
%    horizontal gap between the dropped capital and the indented block
%    of text (default=0pt);
%  \item \lopt{nindent=}\meta{dimen} shifts all indented lines, starting
%    from the second one, horizontally by \meta{dimen} (this shift is
%    relative to the first line, default=0.5em);
%  \item \lopt{slope=}\meta{dimen} can be used with dropped capitals
%    like |A| or |V| to add \meta{dimen} (positive or negative) to the
%    indentation of each line starting from the third one (no effect if
%    \lopt{lines=2}, default=0pt);
%  \item \lopt{ante=}\meta{string} can be used to typeset \meta{string}
%    \emph{before} the dropped capital (typical use is for French
%    guillemets starting the paragraph).
%
% \changes{v1.6}{2004/05/22}{Add a flag to switch to
%    images in eps or pdf format.  Suggested by Bill Jetzer.}
%
%  \item \lopt{image[=true]} will force |\lettrine| to replace the
%    letter normally used as dropped capital by an image in eps format
%    (latex) or in pdf, jpg, png, etc.\ format (pdflatex, xelatex,
%    lualatex); this requires the |graphicx| package to be loaded in the
%    preamble.
%    For instance |\lettrine[image=true]{A}{n exemple}|\hfil or\hfil just\\
%    |\lettrine[image]{A}{n exemple}| will load |A.eps|,
%    |A.jpg|, |A.png| or |A.pdf| instead of letter~A.
%    The string |A|  will be used as ``actualtext’’ for PDF tagging
%    purposes. If your image is meant to be read as ``A’’ but is loaded
%    under another name, you should add \lopt{actualtext=A} as an option
%    to |\lettrine|.
%
% \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 scaling
%    ratio (which will apply to the whole image).  It’s up to the user to
%    ensure that the rest of the image will not overwrite the
%    surrounding text, f.i.\ providing a |\vspace*{...}| in case
%    a significant part sticks out on top of the defined rectangle.
%    This option may be useful in case the letter covers only a limited
%    part of the image,
%    see \url{https://tex.stackexchange.com/questions/693270/} for an
%    example, 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}.}
%
%  \item \lopt{grid[=true]} will force the vertical skip added above the
%    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
%    the dropped capital will raise above the top of following text
%    (usually in small caps), this will trigger a corresponding vertical
%    skip above the paragraph starting with |\lettrine|, \emph{only if}
%    this skip exceeds |\DiscardVskip|.  Consider enlarging |novskip|
%    (or |\DiscardVskip|) to prevent small vertical skips from being
%    rounded up to |\baselineskip| when using the `grid’ option.
%
% \changes{v1.9}{2015/08/31}{New keyval option: `realheight’
%    (true/false) and new global flag \cs{ifLettrineRealHeight}.}
%
%   \item \lopt{realheight[=true]} will compute the default height of the
%     initial 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 \lopt{realheight} defaults to
%     \lopt{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 might like the top of the
%       `H’ 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 \lopt{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}
%
%   \item \lopt{refstring} with no value, is meant for fancy initials
%     with irregular heights (i.e.\ taken in fonts like Yinit (OpenType),
%     \file{cfr-initials},…).  Option \lopt{refstring} forces the
%     |\fontsize| computations to be run on the initial given as
%     |\lettrine|’s first mandatory argument instead of the reference
%     string |\LettrineTestString|.  In most cases, this option should
%     \emph{not} be used: think of accentuated initials or capitals with
%     optical correction.\par
%     \lopt{refstring}=\meta{string} can be used to override
%     |\LettrineTestString|, the default reference string
%     (option \emph{seldom useful}).
%
%    \end{itemize}
%
%    Example: |\lettrine[lines=4, lraise=0.1, nindent=0em, |%
%                        |slope=-.5em]%|\\
%    \mbox{}\phantom{\tt Example: lettrine}%
%                        |{V}{oici} un exemple |…
%
%    Coloured initials are available in conjonction with package
%    \file{color}, examples: \\
%    |\lettrine{\textcolor{red}{A}}{n} example|\quad or\\
%    |\lettrine{\textcolor[gray]{0.5}{A}}{nother} one| \\
%    see package \file{color} for the syntax of colour commands.
%    Another possibility to colour initials globally is described
%    below, see |\LettrineFontHook|.
%
%    Three dimensions, |\LettrineHeight|, |\LettrineDepth| and
%    |\LettrineWidth| hold the final size of the initial
%    (\textit{height} and \textit{depth} being measured from
%    the paragraph’s  $n$-th baseline if |lines=|$n$.
%
%    Have a look at files \file{lettrine-demo-fr.tex} and
%    \file{lettrine-demo-lua.tex} and at the resulting PDFs in the
%    \file{doc} folder to see the possible usage of these parameters.
%
% \changes{v1.9}{2015/08/31}{New customisable string
%    \cs{LettrineSecondString} to tune the initial’s height.}
%
%    Starting with version~2.30, the default settings can easily be
%    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} 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
%    overriden by options passed to the |\lettrine| command.
%
%    The default settings can also be customized in a config file
%    \file{lettrine.cfg} (backward compatibility).  The following list
%    shows the syntax to set them and their default values:
%    \begin{itemize}
%      \item |\setcounter{DefaultLines}{2}|,
%      \item |\setcounter{DefaultDepth}{0}|,
%      \item |\renewcommand{\DefaultLoversize}{0}|,
%      \item |\renewcommand{\DefaultLraise}{0}|,
%      \item |\renewcommand{\DefaultLhang}{0}|,
%      \item |\setlength{\DefaultFindent}{0pt}|,
%      \item |\setlength{\DefaultNindent}{0.5em}|,
%      \item |\setlength{\DefaultSlope}{0pt}|.
%      \item |\setlength{\DiscardVskip}{1pt}|,
%      \item |\LettrineImagefalse|,
%      \item |\LettrineOnGridfalse|,
%      \item |\LettrineMoveAtEOPfalse|,
%      \item |\LettrineRealHeightfalse|.
%    \end{itemize}
%
%    Instead of giving optional parameters to the |\lettrine| command,
%    it is possible to set them on a per character basis
%    in a second config file (suggested by Pascal Kockaert):
%    |\renewcommand{\DefaultOptionsFile}{|\meta{filename}|}|
%    in the preamble will force this file to be read `AtBeginDocument’.
%    Alternatively, |\usepackage[optionsfile=|\meta{filename}|]{lettrine}|
%    produces the same effect.
%    See examples of such config files in the subdirectory \file{contrib}.
%
%    The idea is to provide settings for specific fonts, or to define
%    suitable parameters for some initials like A or V, for instance\\
%    |\LettrineOptionsFor{A}{slope=0.5em, findent=-1.5em, nindent=.7em}|\\
%    Options passed this way are meant to fine tune how the text will be
%    wrapped around the initial; for convenience \emph{inside}
%    |\LettrineOptionsFor| \emph{only}, |\LettrineWidth| can be used
%    instead of~|em| as a unit length.
%
%    Since version~2.70, these commands are also allowed in the document’s
%    preamble.  Mixing |\LettrineOptionsFor| commands in the preamble
%    and in an external config file is not recommended: remember that
%    if an options file is declared, the settings it holds will be taken
%    into account `AtBeginDocument’ thus possibly overriding
%    |\LettrineOptionsFor| commands in the preamble.
%
%    Anyway, the settings read from this file will be overridden by the
%    optional arguments eventually given to the |\lettrine| command.
%
%    More customisation possibilities are offered by the next four
%    commands:
%    \begin{itemize}
%      \item |\renewcommand{\LettrineFontHook}{}|,
%      \item |\renewcommand{\LettrineTextFont}{\scshape}|,
%      \item |\renewcommand{\LettrineTestString}{EFTZ}|,
%      \item |\renewcommand{\LettrineSecondString}{x}|,
%    \end{itemize}
%    |\LettrineTextFont| sets the font used for the second argument
%    of |\lettrine|, its default definition is
%    |\newcommand{\LettrineTextFont}{\scshape}| (second argument in
%    small caps), this can be changed using |\renewcommand|.
%
%    |\LettrineTestString| and |\LettrineSecondString| provide
%    reasonable defaults for Latin scripts (|EFTZ| and |x|).
%    For other scripts they \emph{should be changed} respectively to
%    uppercase and lowercase letters of the given script, as the
%    dropped cap’s height computation is based on these strings;
%    another possibility is to use the previously described
%    \lopt{refstring} and \lopt{realheight} options.
%
%    |\LettrineFont| \emph{is not customisable} see |\LettrineFontHook|
%    below, it sets the font used for the dropped capital, 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 Z, 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
%    \lopt{lines=1}, size is computed as if \lopt{lines} was~2.
%
%    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 III, section~I-9.3),
%    the |\selectfont| command is issued by |\LettrineFont|:\\
%    |\renewcommand{\LettrineFontHook}{\fontfamily{ppl}|\ignorespaces
%    |\fontseries{bx}%|\\
%    |                                 \fontshape{sl}}|\\
%    selects Palatino bold expanded slanted for the dropped capital.
%
%    With LuaLaTeX or XeLaTeX changing the lettrine’s font is
%    even easier, simply use the |\fontspec| command:\\
%    |\renewcommand{\LettrineFontHook}{\fontspec{LinLibertine_I.otf}}|\\
%    will switch to Linux Libertine Initials.
%
%    |\LettrineFontHook| can also be used to change the colour of
%    all initials in a (part of) document:
%    |\renewcommand{\LettrineFontHook}{\color[gray]{0.5}}| \\
%    will colour the initials following this command in grey.
%    A |\color| command can be added in |\LettrineTextHook| if the text
%    following the dropped cap requires the same or another colour.
%
% \changes{v1.3}{2002/08/23}{Correct the documentation to
%    mention the cm-super fonts and the type1ec package by
%    Vladimir Volovich.}
%
%    \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
%    with CM/EC fonts which have two limitations: only a limited number
%    of sizes is available by default (precise adjustments are
%    impossible), and the largest size (25pt or 35pt) is often too
%    small.  The CM fonts are available in PostScript type1 format
%    for free (courtesy of BlueSky/Y\&Y), to make them fully scalable,
%    it is mandatory to add |\usepackage{type1cm}| in the preamble
%    of your document.
%    The EC fonts are also available in type1 format for free
%    (thanks to Vladimir Volovich, they are called cm-super), and
%    adding |\usepackage{type1ec}|\footnote{This package, available on
%    CTAN, was first released on 2002/07/30.}
%    in the preamble will make them fully scalable too.
%    So, if you want \file{lettrine.sty} to work properly with CM
%    or EC fonts, you will need \emph{PostScript versions} of these
%    fonts \emph{and} one of the packages |type1cm.sty| or
%    |type1ec.sty|.
%
%    The LM fonts are a good replacement for both CM and EC fonts they
%    are fully scalable, so you should use them instead of CM or EC
%    fonts.  |\usepackage{lmodern}| is the command to switch them on
%    (add |\usepackage[T1]{fontenc}| when composing in one of the
%    western languages other than English in order to get proper
%    hyphenation).
%
%    You can also consider using one of the standard PostScript fonts
%    (Palatino, Times, Utopia…), or any OpenType font, they are
%    fully scalable too!
%
%    \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
%    initial was completely smashed (\textit{height}=0,
%    \textit{depth}=0) and a |\vskip| was added in case the initial
%    sticked out too much above the paragraph’s first baseline. From
%    version~2.50 on, the initial gets a null \textit{depth} and its
%    proper \textit{height} (measured from the paragraph’s first
%    baseline, please note that it is different from |\LettrineHeight|).
%    This change has the following side effect: in multicolumn
%    typesetting, when a dropped cap starts a column and sticks out
%    significantly above the baseline, it might be necessary to `smash’
%    the dropped cap and eventually to add a |\vspace{}| before
%    the multicolumn environment. See \file{lettrine-demo-fr.pdf} p.~4
%    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{New in version~2.60:} the |\lettrine| command is now
%    compatible with right to left typesetting, with LuaLaTeX and
%    XeLaTeX (+\pkg{babel} or \pkg{polyglossia}).  With XeLaTeX, file
%    \file{lettrine-xetex-bidi.def} (v0.8 [2022/11/06]) is automatically
%    loaded by the \pkg{bidi} package; it redefines the |\@lettrine|
%    command based on version~2.30 of \pkg{lettrine}.  This code is
%    \emph{incompatible} with versions~2.50 and newer, you can safely
%    remove \file{lettrine-xetex-bidi.def} when installing v2.60 or
%    newer of \pkg{lettrine}.

%    \vspace{.5\baselineskip}
%    \textbf{Known issues:}
%    \begin{itemize}
%    \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 `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
%      capital \emph{inside} the environment; adding a |\par| command
%      before the end of environment usually fixes placement issues.
%    \item The LaTeX |\raggedright| command doesn’t work well with the
%      TeX |\parshape| command used internally by |\lettrine|.
%      Please use the |\RaggedRight| command from the \pkg{ragged2e}
%      package together with appropriate settings, f.i. \\
%      |\setlength{\RaggedRightRightskip}{0pt plus .1\hsize}|. \\
%      See \url{https://tex.stackexchange.com/questions/97808/} for
%      details.
%    \item If a \emph{list} has to be included in a paragraph starting
%      with |\lettrine|, it is necessary to add the command
%      |\parshape=0| just after the end of the list (starting a new
%      paragraph  just before or just after the list works too).
%      Remember that `quote’, `quotation’, `abstract’ environments
%      are implemented as \emph{lists} in LaTeX.
%    \item If you are facing some slight height inaccuracy for a
%      dropped capital, you can try option \lopt{refstring};
%      this option is meant for fancy (unaccented) initials.
%      Informations about targeted and effective initial’s
%      height are available in the \file{.log} file.  Using LuaTeX
%      or XeTeX engines with OpenType fonts may be an option
%      (some TFM files for Type1 fonts are slightly inaccurate).
%    \item |\LettrineTestString|’s value has changed over the time;
%      these changes may result in slight size differences for the
%      initial.  Starting with version~2.2, the lettrine package takes
%      advantage of the rollback facilities recently introduced by
%      the LaTeX Team\footnote{A LaTeX kernel dated 2018-04-01 or
%      newer is required.}.  Three rollback versions are provided in
%      order to produce exactly the same output as with former
%      versions: you can request
%      |\usepackage{lettrine}[=v1.6]|\footnote{Don’t forget the
%      \texttt{=} sign!} for 1999-2012 documents or\\
%      |\usepackage{lettrine}[=v1.9]| (documents from 2012 to July 2018)
%      or\\ |\usepackage{lettrine}[=v2.0]| (August 2018).
%      Using any date in ISO format works too:
%      |\usepackage{lettrine}[=2014-03-15]| will load v1.9.
%    \end{itemize}
%
% \StopEventually{}
%
%    \newpage
%    \section{\TeX{}nical details}
%
% \iffalse
%<*sty>
% \fi
%
% \changes{v2.2}{2018/08/25}{Rollback mechanism used for recovering
%    older versions.}
%
% \changes{v2.40}{2023/04/18}{lettrine.dtx auto-generates lettrine.sty
%    and lettrine.cfg (lettrine.ins deleted).}
%
%    The lettrine package uses the rollback mechanism
%    introduced by the LaTeX Team to provide easier backward
%    compatibility.  The current release requires a LaTeX version
%    not older than 2022-06-01 (kernel packages \pkg{ltkeys} and
%    \pkg{xfp} are required).
%    \begin{macrocode}
\DeclareRelease{v1.6}{1999-03-03}{lettrine-2006-03-17.sty}
\DeclareRelease{v1.9}{2012-07-20}{lettrine-2015-08-31.sty}
\DeclareRelease{v2.0}{2018-07-21}{lettrine-2018-08-18.sty}
\DeclareRelease{v2.3}{2022-09-25}{lettrine-2022-09-25.sty}
\DeclareRelease{v2.4}{2023-04-18}{lettrine-2023-04-18.sty}
\DeclareCurrentRelease{}{2025-11-25}
%    \end{macrocode}
%
%    Default initializations: define the necessary counters, lengths,
%    and commands to hold the default settings and set these default
%    settings.  They can be overwritten in file |lettrine.cfg|.
%
% \changes{v1.2}{2002/03/13}{\cs{newlength} changed to
%    \cs{newdimen}, to correct a bug with seminar.cls (pointed out
%    by Peter Münster).}
%
% \changes{v1.6}{2004/05/22}{Added newif \cs{ifLettrineImage}.}
%
% \changes{v1.8}{2015/02/06}{Added newif \cs{ifLettrineOnGrid}
%    and new dimen \cs{DiscardVskip}, default (0.2pt) set for
%    compatibility with previous releases.}
%
% \changes{v2.1}{2018/08/14}{Newif \cs{ifLettrineVone} and
%    new option `Vone’ (removed in v2.2, rollback prefered).}
%
% \changes{v2.1}{2018/08/14}{New option `refstring’.}
%
% \changes{v2.50}{2023/05/30}{\cs{DiscardVskip} default value enlarged
%    from 0.2pt to 1pt.}
%
%    \begin{macrocode}
\newcounter{DefaultLines}
\setcounter{DefaultLines}{2}
\newcounter{DefaultDepth}
\newcommand{\DefaultOptionsFile}{}
\newcommand{\DefaultLoversize}{0}
\newcommand{\DefaultLraise}{0}
\newcommand{\DefaultLhang}{0}
\newdimen\DefaultFindent
\setlength{\DefaultFindent}{\z@}
\newdimen\DefaultNindent
\setlength{\DefaultNindent}{0.5em}
\newdimen\DefaultSlope
\setlength{\DefaultSlope}{\z@}
\newdimen\DiscardVskip
\setlength{\DiscardVskip}{1pt}
\newif\ifLettrineImage
\newif\ifLettrineOnGrid
\newif\ifLettrineRealHeight
\newif\ifLettrineMoveAtEOP
%    \end{macrocode}
%
%    Then let’s define the necessary internal counters, lengths,
%    and commands.
%
% \changes{v1.6}{2004/05/22}{Added newif \cs{ifL@image}.}
%
% \changes{v1.6}{2015/02/06}{Added newif \cs{ifL@grid}.}
%
% \changes{v2.81}{2025/11/25}{Added \cs{L@actual} and keyval option
%    `actualtext’ for image tagging.}
%
%    \begin{macrocode}
\newsavebox{\L@lbox}
\newcounter{L@lines}
\newcounter{L@depth}
\newdimen\L@Pindent
\newdimen\L@Findent
\newdimen\L@Nindent
\newdimen\L@lraise
\newdimen\L@first
\newdimen\L@next
\newdimen\L@slope
\newdimen\L@height
\newdimen\L@novskip
\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}{}
\newcommand*{\L@raise}{}
\newcommand*{\L@ante}{}
\newcommand*{\L@actual}{}
\newif\ifL@image
\newif\ifL@grid
\newif\ifL@nextpage
\newif\ifL@realh
\let\ifL@RTL\iffalse
\newcommand*{\L@viewport}{}
%    \end{macrocode}
%
% \begin{macro}{\LettrineTestString}
%    As some font designers apply optical correction to capitals C, G,
%    O, or Q (they are slightly taller than `T’ or `Z’), they are better
%    left out of |\LettrineTestString|. |EFTZ| should be a good default
%    for most fonts.
%
% \changes{v1.63}{2012/07/20}{(new) it 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ël Pinson.}
%
% \changes{v2.0}{2018/07/21}{changed from `ABCDEFGHIJKLMNOQPRSTUVWXYZ’
%    to `EFTZ’ as some capitals like C, G, O, Q or X might be slightly
%    taller (possible optical correction).}
%
%    \begin{macrocode}
\newcommand*{\LettrineTestString}{EFTZ}
%    \end{macrocode}
% \end{macro}
%
%    Load a local config file if present in LaTeX’s search path.
%    \begin{macrocode}
\InputIfFileExists{lettrine.cfg}
   {\typeout{Loading lettrine.cfg}}
   {\typeout{lettrine.cfg not found, using default values}}
%    \end{macrocode}
%
% \changes{v2.30}{2022/09/23}{Added global options to package
%    \pkg{lettrine}.}
%
% \changes{v2.40}{2023/04/18}{Package options and \cs{lettrine} options
%    no longer depend on \pkg{xkeyval}, they are based on ltkeys.dtx.}
%
%    Global package options enable to override the default values given
%    above to generic parameters. These may be overriden again by
%    options passed to the |\lettrine[]{}{}| command.
%    This code is based on \pkg{ltkeys.dtx}.
%    \begin{macrocode}
\DeclareKeys[LettrineGlobal]
  {
    lines.code        = \setcounter{DefaultLines}{#1}   ,
    depth.code        = \setcounter{DefaultDepth}{#1}   ,
    lhang.store       = \DefaultLhang                   ,
    loversize.store   = \DefaultLoversize               ,
    lraise.store      = \DefaultLraise                  ,
    findent.code      = \setlength{\DefaultFindent}{#1} ,
    nindent.code      = \setlength{\DefaultNindent}{#1} ,
    slope.code        = \setlength{\DefaultSlope}{#1}   ,
    novskip.code      = \setlength{\DiscardVskip}{#1}   ,
    image.if          = LettrineImage                   ,
    grid.if           = LettrineOnGrid                  ,
    nextpage.if       = LettrineMoveAtEOP               ,
    realheight.if     = LettrineRealHeight              ,
    actualtext.store  = \L@actual                       ,
    refstring.default:n = \L@initial                    ,
    refstring.store   = \LettrineTestString             ,
    optionsfile.store = \DefaultOptionsFile
  }
\ProcessKeyOptions[LettrineGlobal]
%    \end{macrocode}
%
%    Ditto for the |\lettrine| command’s options.
%
%    \begin{macrocode}
\DeclareKeys[LettrineLocal]
  {
    lines.code        = \setcounter{L@lines}{#1}         ,
    depth.code        = \setcounter{L@depth}{#1}         ,
    lhang.store       = \L@hang                          ,
    loversize.store   = \L@oversize                      ,
    lraise.store      = \L@raise                         ,
    ante.store        = \L@ante                          ,
    findent.code      = \setlength{\L@Findent}{#1}       ,
    nindent.code      = \setlength{\L@Nindent}{#1}       ,
    slope.code        = \setlength{\L@slope}{#1}         ,
    novskip.code      = \setlength{\L@novskip}{#1}       ,
    image.if          = L@image                          ,
    viewport.store    = \L@viewport                      ,
    grid.if           = L@grid                           ,
    nextpage.if       = L@nextpage                       ,
    realheight.if     = L@realh                          ,
    actualtext.store  = \L@actual                        ,
    refstring.default:n = \L@initial                     ,
    refstring.store   = \L@refstring
 }
%    \end{macrocode}
%
%\changes{v2.70}{2024/11/14}{Read the config file only once, its
%   content is added to token register \cs{Lettrine@tweaks}.}
%
%    Read the per letter options file `AtBeginDocument’.
%    \begin{macrocode}
\AtBeginDocument{%
  \ifx\DefaultOptionsFile\@empty
  \else
    \InputIfFileExists{\DefaultOptionsFile}%
      {\PackageWarning{lettrine.sty}%
         {File \DefaultOptionsFile\space loaded!}%
      }%
      {\PackageWarning{lettrine.sty}%
         {File \DefaultOptionsFile\space not found!}%
      }%
  \fi}
%    \end{macrocode}
%
% \changes{v1.5}{2003/08/18}{\cs{LettrineOptionsFor} and
%    \cs{LettrineWidth} added.}
%
% \begin{macro}{\LettrineOptionsFor}
%    This command sets the values of parameters on a per character
%    basis, for instance:\\
%    |\LettrineOptionsFor{A}{slope=0.6em, findent=-1em, nindent=0.6em}|
%
%    \begin{macrocode}
\newtoks\Lettrine@tweaks
\newcommand*{\LettrineOptionsFor}[2]{%
  \Lettrine@tweaks=\expandafter{\the\Lettrine@tweaks
                                \@lettrine@optionsfor{#1}{#2,}}}
%    \end{macrocode}
%    The internal |\@lettrine@optionsfor| checks if its first argument
%    matches the current initial, if so it passes the options (second
%    argument) to |\SetKeys|.
%    \begin{macrocode}
\newcommand*{\@lettrine@optionsfor}[2]{%
  \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}%
  \endgroup
  \ifx\L@tmpa\L@tmpb \SetKeys[LettrineLocal]{#2}\fi
  }
%    \end{macrocode}
% \end{macro}
%
% \changes{v2.21}{2018/08/28}{Code clean up, new commands
%    \cs{computeL@height}, \cs{compute@fontsize}, \cs{setupL@lbox}.}
%
% \begin{macro}{\LettrineTextFont}
%    In French, small caps usually follow the initial.
%    \begin{macrocode}
\newcommand*{\LettrineTextFont}{\scshape}
\newcommand*{\LettrineSecondString}{x}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LettrineFontHook}
%    |\LettrineFontHook| enables to select another font for the
%    dropped capital.  Its default definition is empty (the current
%    text font is used).
%    \begin{macrocode}
\newcommand*{\LettrineFontHook}{}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\computeL@height}
%    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 globally by
%    redefining |\Defaultloversize| or locally using optional
%    argument \lopt{loversize=}.
%    If \lopt{lines=1}, the default size for the dropped capital is
%    computed as if \lopt{lines=2}.
%    \begin{figure}[ht]
%      \centering
%      \begin{tikzpicture}[>=stealth]
%      \node[font=\fontfamily{lmr}\fontsize{160}{160}\mdseries]
%            at (3,2) {F} ;
%      \node[right, font=\fontfamily{lmr}\fontsize{20}{20}\bfseries]
%           at (4.6,3.65) {IRST};
%      \node[right, font=\fontfamily{lmr}\fontsize{28}{28}\bfseries]
%           at (5,2.63) {bla bla};
%      \node[right, font=\fontfamily{lmr}\fontsize{28}{28}\bfseries]
%            at (5,1.53) {bla bla};
%      \node[right, font=\fontfamily{lmr}\fontsize{28}{28}\bfseries]
%           at (5,0.43) {bla bla};
%      \draw[dotted] (0,3.9) -- (9,3.9);
%      \draw         (1,3.4) -- (9,3.4);
%      \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.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) {finaldp};
%      \draw[<->] (1,3.4) -- (1,3.9);
%      \node[left] at (1,3.7) {finalht};
%      \end{tikzpicture}
%      \caption{Initial’s targeted dimensions
%               ($\mbox{\cs{lines}}=4$, $\mbox{\cs{lraise}}=0$)}
%      \label{fig:target}
%    \end{figure}
%
%    |\computeL@height| computes the targeted height for the
%    dropped capital and stores it into |\L@target@tht|.  This height
%    only depends on |L@lines| and |\L@target@ht| (the height of the
%    following text, see fig.~\ref{fig:target}).  So options \emph{must}
%    be read and |\L@target@ht| be  properly initialised \emph{before}
%    executing |\computeL@height| (see below in |\lettrine| code).
%    |\L@height| is set to |\L@target@tht| raised by the |\L@oversize|
%    factor.
%
% \changes{v1.2}{2002/03/13}{\cs{baselineskip} may be a
%    rubber length, we convert it to a dimen.}
%
% \changes{v1.9}{2015/08/31}{\cs{theL@lines} changed
%    to \cs{value\{L@lines\}}.  Needed for babel-hebrew which
%    redefines \cs{@arabic}.}
%
% \changes{v2.0}{2018/07/21}{Store targeted dimensions of the
%    dropped capital (ht, dp, tht) for further use.}
%
% \changes{v2.1}{2018/08/01}{Height computations moved out of
%    \cs{LettrineFont}: \cs{global} settings no longer required.}
%
%    \begin{macrocode}
\def\computeL@height{%
%    \end{macrocode}
%    As |\baselineskip| might be a rubber length, let’s convert it
%    into a `dimen’ using |\@tempdima|.
%    \begin{macrocode}
  \@tempdima=\baselineskip
  \setlength{\L@target@dp}{\value{L@lines}\@tempdima}%
  \ifnum\value{L@lines}>1
    \addtolength{\L@target@dp}{-\@tempdima}%
  \else
    \addtolength{\L@target@ht}{\L@target@dp}%
    \setlength{\L@target@dp}{\z@}%
  \fi
  \setlength{\L@target@tht}{\L@target@ht}%
  \addtolength{\L@target@tht}{\L@target@dp}%
  \setlength{\L@height}{\L@target@tht}%
  \addtolength{\L@height}{\L@oversize\L@target@tht}%
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\compute@fontsize}
%    After executing |\computeL@height|, |\L@height| holds the exact
%    height required for the dropped capital, nothing more is needed if
%    the initial is a picture, otherwise we need to compute the matching
%    |\fontsize|’s value.  This is done by measuring the height of
%    a ``reference’’ capital (i.e.\ either listed in
%    |\LettrineTestString| or the initial itself).
%    This command compares the height of a ``reference’’ capital scaled
%    by |\fontsize| with argument |\L@height|, to |\L@height| (the
%    required height for the initial) to compute a ratio |\L@factor|
%    (decimal number). Then, the initial will be scaled by
%    |\L@factor\L@height|. Starting with v2.40, |\L@factor| is computed
%    by |\fpeval| which is now part of LaTeX kernel.
%
% \changes{v2.1}{2018/08/14}{Computation of \cs{L@factor} for
%    \cs{fontsize} done by the minifp package.}
%
% \changes{v2.22}{2018/09/14}{Warn if \cs{fontsize} computation fails
%    due to division by 0.}
%
% \changes{v2.40}{2023/04/18}{Computation of \cs{L@factor} for
%    \cs{fontsize} done by the xfp package.}
%
%    If the option \lopt{refstring} is set in the |\lettrine| command
%    the initial itself is taken as reference to compute |\fontsize|,
%    this can be handy when working with fancy fonts
%    (i.e.\ cfr-initials, Yinit).
%    In most cases, the default is a better choice.
%    \begin{macrocode}
\def\compute@fontsize{%
  \ifx\L@refstring\@empty
    \def\Lettrine@RefString{\LettrineTestString}%
  \else
    \def\Lettrine@RefString{\L@refstring}%
  \fi
  \settoheight{\@tempdima}{\LettrineFontHook
                    \fontsize{\L@height}{\L@height}\selectfont
                    \Lettrine@RefString}%
  \ifdim\@tempdima=\z@
    \PackageWarning{lettrine}{Unable to compute \protect\fontsize!%
    \MessageBreak \protect\LettrineTestString\space empty? reported}%
    \def\L@factor{1}%
  \else
    \def\L@factor{\fpeval{\the\L@height/\the\@tempdima}}%
  \fi
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LettrineFont}
%    |\fontsize|’s argument providing the requested |\L@height| is
%    |\L@factor\L@height|.
%    \begin{macrocode}
\newcommand*{\LettrineFont}{%
   \LettrineFontHook
   \fontsize{\L@factor\L@height}{\L@factor\L@height}%
   \selectfont
}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\setupL@lbox}
% \begin{macro}{\computeL@dimens}
%
% \changes{v2.82}{2025/11/27}{Stop using \cs{L@lbox} to compute
%    the initial’s dimens (solves tagging issues with images).}
%
%    The next (internal) command computes the width, height and depth
%    requested for the initial (letter or image) and stores them in
%    |\LettrineWidth|, |\LettrineHeight| and |\LettrineDepth|.
%    \begin{macrocode}
\def\computeL@dimens{%
  \computeL@height
  \ifL@image
    \ifx\L@viewport\@empty
      \settowidth{\LettrineWidth}{%
        \includegraphics[height=\L@height]{\L@initial}}%
    \else
      \settowidth{\LettrineWidth}{%
        \expanded{\noexpand\includegraphics%
                  [viewport=\L@viewport, height=\L@height]{\L@initial}}%
                    }%
    \fi
    \setlength{\LettrineHeight}{\L@height}%
    \setlength{\LettrineDepth}{\z@}%
  \else
    \compute@fontsize
    \settowidth{\LettrineWidth}{\LettrineFont \L@initial}%
    \settoheight{\LettrineHeight}{\LettrineFont \L@initial}%
    \settodepth{\LettrineDepth}{\LettrineFont \L@initial}%
  \fi
}
%    \end{macrocode}
%    The next command actually stores the dropped cap in the |\L@lbox|
%    box, it will be executed (only once) in horizontal mode to prevent
%    tagging issues.
%    \begin{macrocode}
\def\setupL@lbox{%
  \ifL@image
    \ifx\L@actual\@empty \edef\L@actual{\L@initial}\fi
    \ifx\L@viewport\@empty
      \sbox{\L@lbox}{\includegraphics%
               [height=\L@height, actualtext=\L@actual]{\L@initial}%
                    }%
    \else
      \sbox{\L@lbox}{%
        \expanded{\noexpand\includegraphics%
          [viewport=\L@viewport, height=\L@height,
                                 actualtext=\L@actual]{\L@initial}}%
                    }%
    \fi
  \else
    \compute@fontsize
    \sbox{\L@lbox}{\LettrineFont \L@initial}%
  \fi
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \begin{macro}{\lettrine}
%  \changes{v2.83}{2025/12/06}{now defined using
%     \cs{NewDocumentCommand}.}
%
%    Now let’s define the |\lettrine| command.
%    \begin{macrocode}
\NewDocumentCommand\lettrine{ O{} m m }{%
  \def\L@initial{#2}\def\L@refstring{}\def\L@viewport{}%
%    \end{macrocode}
%
% \changes{v1.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}{\value{DefaultLines}}%
  \setcounter{L@depth}{\value{DefaultDepth}}%
  \renewcommand*{\L@hang}{\DefaultLhang}%
  \renewcommand*{\L@oversize}{\DefaultLoversize}%
  \renewcommand*{\L@raise}{\DefaultLraise}%
  \renewcommand*{\L@ante}{}%
  \renewcommand*{\L@actual}{}%
  \setlength{\L@Findent}{\DefaultFindent}%
  \setlength{\L@Nindent}{\DefaultNindent}%
  \setlength{\L@slope}{\DefaultSlope}%
  \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}
%
%    Take the local options passed to |\lettrine| into account
%    to compute |\L@target@ht| which depends on option |realheight|,
%    before eventually reading the per character config file.
%
% \changes{v1.6}{2004/05/22}{Add braces around \#3 to allow
%    commands taking an argument (such as \cs{MakeLowercase}) in
%    \cs{LettrineTextFont}.  Suggested by Philipp Lehman.}
%
% \changes{v1.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[LettrineLocal]{#1}%
  \settoheight{\L@target@ht}{\LettrineTextFont{\LettrineSecondString}}%
  \ifL@realh
    \def\@tempa{#3}%
    \ifx\@tempa\@empty
      \PackageWarning{lettrine.sty}%
        {Empty second argument,\MessageBreak
         ignoring option `realheight';}%
    \else
      \settoheight{\L@target@ht}{{\LettrineTextFont{#3}}}%
    \fi
  \fi
%    \end{macrocode}
%
% \changes{v2.40}{2023/04/18}{Options from the per letter config file
%    are now handled by LaTeX command \cs{SetKeys}.}
%
%    Take the per character options into account if any. For these
%    options some parameters’ values \lopt{findent}, \lopt{nindent} and
%    \lopt{slope} ---which do not influence the initial’s size--- may
%    be given relative to |\LettrineWidth|, which needs to be computed
%    before.
%    \begin{macrocode}
  \edef\@tempa{\the\Lettrine@tweaks}%
  \ifx\@tempa\@empty
  \else
    \computeL@dimens
    \the\Lettrine@tweaks
%    \end{macrocode}
%    As local options always prevail, read again the optionnal
%    argument of |\lettrine|.
%    \begin{macrocode}
    \SetKeys[LettrineLocal]{#1}%
  \fi
%    \end{macrocode}
% \changes{v1.65}{2014/09/04}{Measure and store the initial’s
%    final dimensions.}
%    Compute the final values of |\LettrineWidth|, |\LettrineHeight|
%    and |\LettrineDepth|:
%    \begin{macrocode}
  \computeL@dimens
%    \end{macrocode}
%
%    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),
%    they are just rounding errors.}
%
% \changes{v1.8}{2015/02/06}{The 0.2pt limit for discarded
%    vskips is now customisable through \cs{DiscardVskip} and option
%    `novskip’.}
%
%    The basis for |\L@raise| (and |\L@oversize|, see
%    |\LettrineFont|) is |\L@target@tht|.
%
%    \begin{macrocode}
  \par
  \setlength{\L@finalht}{\LettrineHeight}%
  \setlength{\L@lraise}{\L@raise\L@target@tht}%
  \addtolength{\L@finalht}{\L@lraise}%
  \ifnum\value{L@lines}>\@ne
    \@tempcnta=\value{L@lines}%
    \advance\@tempcnta \m@ne
    \@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}
%
%   Print some informations about accuracy to the log file,
%    \begin{macrocode}
  \begingroup
  \def\IeC##1{##1}%
  \@tempdima=\L@oversize pt\relax
  \PackageInfo{lettrine.sty}%
    {Targeted height = \the\L@target@tht\MessageBreak
     (for loversize=0, accent excluded),\MessageBreak
     Lettrine height = \the\LettrineHeight\space (#2)%
     \ifdim\@tempdima>\z@\space loversize=\L@oversize\fi;%
     \MessageBreak reported}%
  \endgroup
%    \end{macrocode}
%
%    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@finalht
  \advance\@tempdima \L@novskip
  \@tempdimb=\baselineskip
  \ifdim\@tempdima>\@tempdimb
    \ifL@grid
      \@tempcnta=\z@
      \loop\ifdim\@tempdima>\@tempdimb
         \advance\@tempcnta \@ne
         \advance\@tempdima -\@tempdimb
      \repeat
      \vskip\@tempcnta\baselineskip
    \fi
  \fi
%    \end{macrocode}
%
% \changes{v2.0}{2018/07/21}{Add informations about targeted
%    and actual height of the initial to the .log file.}
%
% \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
%    \end{macrocode}
%
%    We (mis)use the length |\L@first| to compute the width of
%    the text eventually coming before the dropped capital.  It is
%    reset later on to hold the first line’s length.
%    \begin{macrocode}
  \setlength{\L@Pindent}{\LettrineWidth}%
  \addtolength{\L@Pindent}{-\L@hang\LettrineWidth}%
  \settowidth{\L@first}{\L@ante}%
  \addtolength{\L@Pindent}{\L@first}%
  \addtolength{\L@Pindent}{\L@Findent}%
  \setlength{\L@first}{\linewidth}%
  \addtolength{\L@first}{-\L@Pindent}%
%    \end{macrocode}
%    Now let’s compute |\L@Nindent| and |\L@next| for the next lines.
%    \begin{macrocode}
  \addtolength{\L@Nindent}{\L@Pindent}%
  \setlength{\L@next}{\linewidth}%
  \addtolength{\L@next}{-\L@Nindent}%
%    \end{macrocode}
%
% \changes{v1.1}{1999/08/18}{Add \cs{rightmargin} to
%    \cs{L@Pindent} for \cs{Lettrine} to work properly in quote,
%    quotation, abstract environments… but do not change
%    \cs{linewidth} which is set by these environments.}
%
% \changes{v1.4}{2002/10/26}{\cs{lettrine} still didn’t
%    work properly in quote, quotation, abstract environments,
%    pointed out by Matthias C.\ Schmidt.  \cs{rightmargin} was added
%    too early to \cs{L@Nindent}, thus making \cs{\L@next} too short
%    by \cs{rightmargin}.}
%
% \changes{v2.22}{2019/04/04}{\cs{@totalleftmargin} is the correct
%    indentation for quote, quotation and abstract environments.}
%
%    This is for quotation, quote, abstract… environments:
%    |\linewidth| is set by these environments, all we have to do
%    is to shift our text left by |\@totalleftmargin|.
%    \begin{macrocode}
  \addtolength{\L@Pindent}{\@totalleftmargin}%
  \addtolength{\L@Nindent}{\@totalleftmargin}%
%    \end{macrocode}
%    Now, set up the shape of the new paragraph (designed by
%    |\parshape|).  It obiously depends on the text direction,
%    the code previously available in \file{lettrine-xetex-bidi.def}
%    for right to left scripts is integrated here now.
%
% \changes{v1.9}{2015/08/31}{\cs{theL@depth} changed to
%    \cs{value\{L@depth\}}.}
%
% \changes{v2.60}{2024/01/20}{\cs{L@parshape} compatible with
%    xetex bidi RTL typesetting.}
%
%    \begin{macrocode}
  \addtocounter{L@lines}{1}%
  \addtocounter{L@lines}{\value{L@depth}}%
  \ifL@RTL
    \def\L@parshape{\c@L@lines \z@ \the\L@first}%
  \else
    \def\L@parshape{\c@L@lines \the\L@Pindent \the\L@first}%
  \fi
  \@tempcnta=\tw@
  \@whilenum \@tempcnta<\c@L@lines\do{%
     \ifL@RTL
       \edef\L@parshape{\L@parshape \z@ \the\L@next}%
     \else
       \edef\L@parshape{\L@parshape \the\L@Nindent \the\L@next}%
     \fi
     \addtolength{\L@Nindent}{\L@slope}%
     \addtolength{\L@next}{-\L@slope}%
     \advance\@tempcnta\@ne}%
  \ifL@RTL
    \edef\L@parshape{\L@parshape \z@ \the\linewidth}%
  \else
    \edef\L@parshape{\L@parshape \@totalleftmargin \the\linewidth}%
  \fi
%    \end{macrocode}
%
%  \changes{v2.83}{2025/12/06}{Remove unnecessary usage of \cs{L@tbox}
%     (safer for tagging).}
%
%  \changes{v2.81}{2025/11/25}{Reset \cs{L@lbox} and \cs{L@tbox}
%     after starting the new paragraph as suggested by Ulrike Fischer
%     for tagging.}
%
%    Set the |\L@lbox| box in horizontal mode for tagging, see
%    \url{https://github.com/latex3/tagging-project/issues/481}.
%    \begin{macrocode}
  \noindent
  \parshape=\L@parshape\relax
  \setupL@lbox
%    \end{macrocode}
% \changes{v1.64}{2013/03/14}{Remove \$ around \cs{smash}
%    and add \cs{relax}.  Bug pointed out by David Monniaux.
%    Correction by Enrico Gregorio.}
%
% \changes{v2.40}{2023/04/18}{Replace \cs{usebox} by \cs{unhcopy}
%    for box \cs{L@tbox} to allow footnote calls and microtype action.}
%
% \changes{v2.50}{2023/07/02}{Remove the top \cs{vskip}, smash the
%   dropped cap, add a \cs{rule} to mimic its height above the baseline
%   instead.}
%
% \changes{v2.61}{2024/06/26}{Include the `ante’ box into the \cs{smash}
%    command in case it is shifted down.}
%
%    Write the dropped capital into the left margin, and wrap
%    the rest of paragraph around it.
%    \begin{macrocode}
  \llap{\smash{\mbox{\L@ante}\raisebox{\L@lraise}{\usebox{\L@lbox}}}%
        \ifL@grid\else\rule{\z@}{\L@finalht}\fi
        \hskip \the\L@Findent}%
  {\LettrineTextFont{#3}}%
%    \end{macrocode}
%
% \changes{v2.22}{2019/03/30}{\cs{parshape} reset added in lists.}
%
%    A |\parshape| reset is required in abstract, quote and quotation
%    environments beginning with |\lettrine| and spreading over several
%    paragraphs.  When the list ends, |\parshape| returns to~|0|.
%    \begin{macrocode}
  \ifnum\@listdepth>0 \Lreset@listparshape \fi
}
%    \end{macrocode}
% \end{macro}
%    This ends the definition of |\lettrine|; |\Lreset@listparshape|
%    adds the parshape reset to the first occurence of |\everypar|
%    following the |\lettrine| command.
%    \begin{macrocode}
\newtoks\Llist@everypar
\def\Lreset@listparshape{%
  \let\Lnew@everypar\everypar
  \Llist@everypar=\expandafter{\the\everypar}%
  \Lnew@everypar={\the\Llist@everypar
                  \parshape=\@ne \@totalleftmargin \linewidth \relax
                  \let\everypar\Llist@everypar
                 }%
}
%    \end{macrocode}
%    Compatibility with the \pkg{bidi} package (loaded \emph{after}
%    \pkg{lettrine}).
%    \begin{macrocode}
\AtBeginDocument{%
  \IfPackageLoadedTF{bidi}{\eqnewif{\ifL@RTL}{\if@RTL}}{}%
}
%    \end{macrocode}
%
% \iffalse
%</sty>
% \fi
% \clearpage
%  \section{Configuration file}
%
% \iffalse
%<*cfg>
% \fi
%    \begin{macrocode}
%% lettrine.cfg: configuration file for lettrine.sty
%%
%% If you want to customize lettrine, please *do not* hack into the
%% code, copy this file to your working directory and customize the
%% copy as you like.
%%
%% Uncomment any of these lines and change the parameters’ values
%% to fit your needs (see lettrine.dtx).
%%
%%\setcounter{DefaultLines}{2}
%%\setcounter{DefaultDepth}{0}
%%
%% These are *decimal* numbers:
%%\renewcommand{\DefaultLoversize}{0}
%%\renewcommand{\DefaultLraise}{0}
%%\renewcommand{\DefaultLhang}{0}
%%
%% These are *lengths* (don't forget the unit):
%%\setlength{\DefaultFindent}{0pt}
%%\setlength{\DefaultNindent}{0.5em}
%%\setlength{\DefaultSlope}{0mm}
%%\setlength{\DiscardVskip}{1pt}
%%
%% Theses are *flags* (value=true/false):
%%\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.
%%\renewcommand*{\LettrineTextFont}{\scshape}|
%%
%% Theses are *commands* (value=string, only height matters):
%%\renewcommand{\LettrineTestString}{EFTZ}
%%\renewcommand{\LettrineSecondString}{x}
%%
%% In case you want to set parameters for some letters
%% in file `optfile.cfl'
%%\renewcommand{\DefaultOptionsFile}{optfile.cfl}
%    \end{macrocode}
% \iffalse
%</cfg>
% \fi
%
% \Finale
\endinput

%%% Local Variables:
%%% fill-column: 72
%%% coding: utf-8
%%% TeX-engine: luatex
%%% End:
