summaryrefslogtreecommitdiff
path: root/Master/texmf-dist/source/latex/lettrine/lettrine.dtx
blob: 13b9b7990e0586a392a1efe6ade1134fe285f4fd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
1001
1002
1003
1004
1005
1006
1007
1008
1009
1010
1011
1012
1013
1014
1015
%
% \CheckSum{596}
%
% \iffalse meta-comment
%
% Copyright © 1999-2018 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".
%
% \fi
%
% \iffalse
%
%<*sty>
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\ProvidesFile{lettrine.sty}
%</sty>
%<*dtx>
\ProvidesFile{lettrine.dtx}
%</dtx>
%<*!cfg>
             [2018/07/21 v2.0 (Daniel Flipo)]
%</!cfg>
%
%    Lettrine package for LaTeX version 2e
%
%    Copyright © 1999-2018 by Daniel Flipo
%
%    Please report errors to: daniel.flipo at free.fr
%
%<*driver>
\documentclass[a4paper]{ltxdoc}
\usepackage{unicode-math}
\setmainfont{Latin Modern Roman}
\setmathfont{XITS Math}
\usepackage[expansion=true,protrusion=true]{microtype}
\usepackage{url}
\usepackage[numbered]{hypdoc}
\hypersetup{colorlinks,urlcolor=blue,unicode}
\usepackage{lettrine}
%
\RecordChanges
\AtEndDocument{%
   \section{Change History}%
   \GlossaryPrologue{}%
   Changes are listed in reverse order (latest first) from version~1.0
   \PrintChanges
}
%
\newcommand*\file[1]{\texttt{#1}}
\renewcommand\meta[1]{\textit{<#1>}} % no math mode (see doc.sty)
%
\setlength{\parindent}{0pt}
\setlength{\parskip}{.3\baselineskip}
\begin{document}
\GetFileInfo{lettrine.dtx}
\begin{center}
  \textbf{\Large Typesetting dropped capitals in \LaTeXe{} documents}
  \\[.2\baselineskip]^^A\]
  {\large Daniel Flipo}\\
  \texttt{daniel.flipo@free.fr}
\end{center}
\DocInput{lettrine.dtx}
\end{document}
%</driver>
%
%\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.
%
%    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.
%
%    Various parameters are provided 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 David Carlisle's
%    \texttt{keyval.sty} syntax:
%    \begin{itemize}
%      \item |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 |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 |lhang=|\meta{decimal} ($0\le|lhang|\le1$) sets
%            how much of the dropped capital's width should hang into
%            the margin (default=0);
%      \item |loversize=|\meta{decimal} ($-1<|loversize|\le1$)
%            enlarges the dropped capital's height: with
%            |loversize=0.1| its height is enlarged by 10\% so that
%            it raises above the top paragraph's line (default=0);
%      \item |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 |findent=|\meta{dimen} (positive or negative)
%            controls the horizontal gap between the dropped capital
%            and the indented block of text (default=0pt);
%      \item |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 |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 |lines=2|,
%            default=0pt);
%      \item |ante=|\meta{text} can be used to typeset \meta{text}
%            \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 |image=|\meta{true} (new to version 1.6) will force
%            |\lettrine| to replace the letter normally used as
%            dropped capital by an image in eps format (latex) or
%            in pdf, jpg, etc.\ format (pdflatex); this needs the
%            |graphicx| package to be loaded in the preamble of course.
%            |\lettrine[image=true]{A}{n exemple}| or just
%            |\lettrine[image]{A}{n exemple}| will load |A.eps|
%            or |A.pdf| instead of letter~A.  This was suggested
%            by Bill Jetzer.  Redefining \verb+\LettrineFont+ as
%            \verb+\LettrineFontEPS+ still works for compatibility
%            but is deprecated.
%
% \changes{v1.8}{2015/02/06}{Added two keyval options:
%    `grid' (true/false) and `novskip' to override \cs{DiscardVskip}.}
%
%      \item |grid=|\meta{true} (new to version 1.8) 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.
%      \item |novskip=|\meta{dimen} (new to version 1.8)
%            overrides |\DiscardVskip| (default=0.2pt).  In some cases
%            (see options |lraise|, |loversize| or accentuated dropped
%            capitals,\dots) 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 |realheight=|\meta{true} (new to version 1.9) 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
%            |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 `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
%              |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, |%
%                        |slope=-.5em]%|\\
%    \mbox{}\phantom{\tt Example: lettrine}%
%                        |{V}{oici} un exemple |\dots
%
%    Coloured initials are possible 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, |\LettrineWidth|, |\LettrineHeight| and
%    |\LettrineDepth|, store the final size of the initial.
%
%    Once \file{lettrine.sty} will be installed (run \texttt{latex}
%    on \file{lettrine.ins} to extract it), compile and print
%    \file{demo.tex} 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.}
%
%    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
%    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 |\LettrineImagefalse|,
%      \item |\LettrineOnGridfalse|,
%      \item |\LettrineRealHeightfalse|,
%      \item |\setlength{\DefaultFindent}{0pt}|,
%      \item |\setlength{\DefaultNindent}{0.5em}|,
%      \item |\setlength{\DefaultSlope}{0pt}|.
%      \item |\setlength{\DiscardVskip}{0.2pt}|.
%    \end{itemize}
%
%    Instead of giving optional parameters to the |\lettrine| command,
%    it is possible, from version 1.5, to set them on a per character
%    basis in a second config file (suggested by Pascal Kockaert):
%    |\renewcommand{\DefaultOptionsFile}{|\textit{filename}|}|
%    in the preamble (or anywhere in the document) will
%    force each call to |\lettrine| to read the file \textit{filename}.
%    See examples of such config files in the subdirectory
%    \file{contrib}.
%
%    The dimensional parameters |findent|, |nindent| and |slope|,
%    can be set in \textit{filename} relative to |\LettrineWidth| if
%    needed.  The settings read from this file will be overridden by
%    the optional arguments eventually given to |\lettrine|.
%
%    |\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|).
%
%    |\LettrineFont| 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 $|lines|=1$,
%    size is computed as if |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, p.187--192),
%    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.\\
%    |\LettrineFontHook| can also be used to change the colour of
%    all lettrines in a (part of) document:
%    |\renewcommand{\LettrineFontHook}{\color[gray]{0.5}}| \\
%    will colour the initials following this command in grey.
%
% \changes{v1.3}{2002/08/23}{Correct the documentation to
%    mention the cm-super fonts and the type1ec package by
%    Vladimir Volovich.}
%
%    \vspace{\baselineskip}
%    \textbf{Important notice:}
%    the sizing works fine with \emph{fully scalable} fonts (like the
%    standard PostScript 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 now 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\dots), or any OpenType font, they are
%    fully scalable too!
%
%    \vspace{\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 |\lettrine| works within `quote' `quotation', `abstract'
%      environments but does not work within `center' environments
%      (except with option \texttt{[lines=1]});
%    \item |\lettrine| does not work within lists;
%    \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 changing |\LettrineTestString|:\\
%      |\renewcommand*{\LettrineTestString}{|\meta{letter}|}|\\
%      where \meta{letter} is the used dropped capital \emph{without
%      accent}.  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;
%      to achieve strict backward compatibility with previous versions,
%      please look at the end of \file{lettrine.cfg}.
%    \end{itemize}
%
% \StopEventually{}
%
%    \section{\TeX{}nical details}
%
%    This package only runs with \LaTeXe{} and requires keyval.sty
% \iffalse
%<*sty>
% \fi
%
%    \begin{macrocode}
\NeedsTeXFormat{LaTeX2e}[1999/12/01]
\RequirePackage{keyval}
%    \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.}
%
%    \begin{macrocode}
\newcounter{DefaultLines}
\setcounter{DefaultLines}{2}
\newcounter{DefaultDepth}
\newcommand*{\DefaultOptionsFile}{\relax}
\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}{0.2\p@}
\newif\ifLettrineImage
\newif\ifLettrineOnGrid
\newif\ifLettrineRealHeight
%    \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}.}
%
%    \begin{macrocode}
\newsavebox{\L@lbox}
\newsavebox{\L@tbox}
\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
\newcommand*{\L@file}{}
\newcommand*{\L@hang}{}
\newcommand*{\L@oversize}{}
\newcommand*{\L@raise}{}
\newcommand*{\L@ante}{}
\newif\ifL@image
\newif\ifL@grid
\newif\ifL@realh
%    \end{macrocode}
%
%    Provide commands for the fonts used to typeset the two
%    mandatory arguments of |\lettrine|.
%
% \begin{macro}{\LettrineTextFont}
%    In French, small caps usually follow the dropped capital.
%    \begin{macrocode}
\newcommand*{\LettrineTextFont}{\scshape}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\LettrineFontHook}
% \begin{macro}{\LettrineFont}
%    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 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 targeted height for the dropped
%    capital and stores it into |\L@target@tht| which depends only
%    on |L@lines| and 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|.
%
%    |\L@height| is set to |\L@target@tht| raised by the |\L@oversize|
%    factor.
%
% \changes{v0.9}{1998/02/23}{Size of the dropped capital
%    changed when `lines' value is 1 (was \cs{Huge}).}
% \changes{v0.9}{1998/03/13}{\cs{Lettrine@height} added.}
% \changes{v0.9}{1998/03/13}{\cs{LettrineFontHook} added.}
% \changes{v1.2}{2002/03/13}{\cs{baselineskip} may be a
%    rubber length, we convert it to a dimen.}
%
% \changes{v1.63}{2012/07/20}{Added command
%    \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ël Pinson.}
%
% \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}{\cs{LettrineTestString} changed
%    from `ABCDEFGHIJKLMNOQPRSTUVWXYZ' to `EFTZ' as
%    some capitals like C, G, O, Q or X might be slightly taller
%    (possible optical correction).}
%
% \changes{v2.0}{2018/07/21}{Store targeted dimensions of the
%    dropped capital (ht, dp, tht) for further use.}
%
%    \begin{macrocode}
\def\Lettrine@height{%
   \ifvoid\L@tbox
     \sbox{\L@tbox}{\LettrineTextFont{\LettrineSecondString}}%
   \fi
   \global\setlength{\L@target@ht}{\ht\L@tbox}%
%    \end{macrocode}
%    As |\baselineskip| might be a rubber length, let’s convert it
%    into a `dimen' using |\@tempdima|.
%    \begin{macrocode}
   \@tempdima=\baselineskip
   \global\setlength{\L@target@dp}{\value{L@lines}\@tempdima}%
   \ifnum\value{L@lines}>1
     \global\addtolength{\L@target@dp}{-\@tempdima}%
   \else
     \global\addtolength{\L@target@ht}{\L@target@dp}%
     \global\setlength{\L@target@dp}{0pt}%
   \fi
   \global\setlength{\L@target@tht}{\L@target@ht}%
   \global\addtolength{\L@target@tht}{\L@target@dp}%
   \setlength{\L@height}{\L@target@tht}%
   \addtolength{\L@height}{\L@oversize\L@target@tht}%
}
%    \end{macrocode}
%
%    |\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}{}
\newcommand*{\LettrineTestString}{EFTZ}
\newcommand*{\LettrineSecondString}{x}
\newcommand*{\LettrineFont}{%
   \Lettrine@height
%    \end{macrocode}
%    |\L@height| now holds the exact height required for the dropped
%    capital, let’s compute the matching |\fontsize|’s value:
%    we divide |\L@height| (converted into sp) by the ``standard’’
%    capitals’ height (see the list in |\LettrineTestString|) to get
%    a scaling factor (always $\ge1$).
%    All capitals in |\LettrineTestString| are expected to have the
%    same height, in case this assumption would be wrong for some
%    special font, |\LettrineTestString| can be customised to any
%    non empty subset of capitals, the maximal height of these
%    capitals will be taken into account.
%    Mind that some fonts apply optical correction to capitals C, G,
%    O, or Q (they are slightly taller than `T’ or `Z’), that’s why
%    they are not part of |\LettrineTestString|.
%    \begin{macrocode}
   \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.
%
% \changes{v2.0}{2018/07/21}{Change factors 100/100 to 50/200
%    to reach larger sizes (height up to 600pt).}
%
%    \begin{macrocode}
   \@tempcntb=\ht\@tempboxa
   \@tempcnta=\L@height
   \multiply\@tempcnta by 50
   \divide\@tempcntb by 200
   \divide\@tempcnta by \@tempcntb
   \advance\@tempcnta by -9999
   \ifnum\@tempcnta>0
     \def\@tempa{1.\the\@tempcnta}%
   \else
     \def\@tempa{1}%
   \fi
   \LettrineFontHook
   \fontsize{\@tempa\L@height}{\@tempa\L@height}%
   \selectfont
}
%    \end{macrocode}
% \end{macro}
% \end{macro}
%
% \changes{v0.9}{1998/03/13}{\cs{LettrineFontEPS} added.}
%
% \begin{macro}{\LettrineFontEPS}
%    The following definition is for use with dropped capitals defined
%    as images: EPS, PDF, JPG, PNG files (see examples in demo.tex).
%    Its use requires the |graphicx| package to be loaded in the
%    preamble with |\usepackage{graphicx}|.  The required size is
%    computed just as in the standard case, |\includegraphics|
%    prints the EPS file at this size.
%
% \changes{v1.6}{2004/05/22}{Added \cs{LettrineFontHook}
%    to \cs{LettrineFontEPS}.  This is needed for color options.}
%
%    \begin{macrocode}
\newcommand*{\LettrineFontEPS}{%
   \Lettrine@height\LettrineFontHook
   \includegraphics[height=\L@height]%
}
%    \end{macrocode}
% \end{macro}
%
%    Set up keyval initializations.
%
%    \begin{macrocode}
\define@key{L}{lines}{\setcounter{L@lines}{#1}}
\define@key{L}{depth}{\setcounter{L@depth}{#1}}
\define@key{L}{lhang}{\renewcommand*{\L@hang}{#1}}
\define@key{L}{loversize}{\renewcommand*{\L@oversize}{#1}}
\define@key{L}{lraise}{\renewcommand*{\L@raise}{#1}}
\define@key{L}{ante}{\renewcommand*{\L@ante}{#1}}
\define@key{L}{findent}{\setlength{\L@Findent}{#1}}
\define@key{L}{nindent}{\setlength{\L@Nindent}{#1}}
\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}
%
% \changes{v1.5}{2003/08/18}{\cs{LettrineOptionsFor} and
%    \cs{LettrineWidth} added.}
%
% \begin{macro}{\LettrineOptionsFor}
%    This command is to be used in an optional config file (the name
%    of which is found in |\DefaultOptionsFile|) to set the values
%    of parameters on a per character basis, for instance:\\
%    |\LettrineOptionsFor{A}{slope=0.6em, findent=-1em, nindent=0.6em}|\\
%    creates an internal command (|\l@A-keys| in this example),
%    which expands to the options given as second argument of
%    |\LettrineOptionsFor| for letter `A'.
%
%    \begin{macrocode}
\newcommand*{\LettrineOptionsFor}[2]{\@namedef{l@#1-keys}{#2}}
%    \end{macrocode}
% \end{macro}
%
% \begin{macro}{\lettrine}
%    Now let's define |\lettrine|.
%
%    \begin{macrocode}
\def\lettrine{\@ifnextchar[\@lettrine{\@lettrine[]}}
\def\@lettrine[#1]#2#3{%
%    \end{macrocode}
%
% \changes{v0.81}{1997/02/26}{\cs{DefaultLoversize} added.}
%
% \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}{}%
  \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
  \ifLettrineRealHeight\L@realhtrue\else\L@realhfalse\fi
%    \end{macrocode}
%
%    |\LettrineFont| and |\LettrineFontEPS| both execute
%    |\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 |\lettrine|'s optional argument
%    and initialise the |\L@tbox| content now%
%    \footnote{Now means before eventually reading the config file.}.
%
% \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{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{v1.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
%    |\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 initial
%    (defined by |#2|)\dots
%    \begin{macrocode}
  \if\DefaultOptionsFile\relax
  \else
    \begingroup
    \InputIfFileExists{\DefaultOptionsFile}%
      {}%
      {\PackageWarning{lettrine.sty}%
         {File \DefaultOptionsFile\space not found}%
      }%
%    \end{macrocode}
%    Gobble the colour commands, just keep the letter argument.
%    \begin{macrocode}
    \def\color##1##{\l@color{##1}}%
    \let\l@color\@gobbletwo
    \def\textcolor##1##{\l@textcolor{##1}}%
    \def\l@textcolor##1##2##3{##3}%
%    \end{macrocode}
%    Save the list of options relevant to the letter in |#2|
%    in |\l@LOKeys| (list is empty eventually).
%    \begin{macrocode}
    \expandafter\ifx\csname l@#2-keys\endcsname\relax
                  \gdef\l@LOKeys{}%
                \else
                  \xdef\l@LOKeys{\csname l@#2-keys\endcsname}%
                \fi
    \endgroup
%    \end{macrocode}
%    Now apply these options (the following code executes
%    |\setkeys{L}{\l@LOKeys}}| where |\l@LOKeys| is expanded,
%    see \file{keyval.sty}).
%    \begin{macrocode}
    \def\KV@prefix{KV@L@}%
    \let\@tempc\relax
    \expandafter\KV@do\l@LOKeys,\relax,
%    \end{macrocode}
%    As some parameters' values |findent|, |nindent| and |slope|
%    ---which do not influence the initial’s size--- may be given
%    relative to |\LettrineWidth|, this has to be done again after
%    measuring the lettrine for |\LettrineWidth| to be set properly.
%    \begin{macrocode}
    \sbox{\L@lbox}{\LettrineFont #2}%
    \setlength{\LettrineWidth}{\wd\L@lbox}%
    \def\KV@prefix{KV@L@}%
    \let\@tempc\relax
    \expandafter\KV@do\l@LOKeys,\relax,
%    \end{macrocode}
%    As local options prevail on those held in the config file, we
%    have to read local options again:
%    \begin{macrocode}
    \setkeys{L}{#1}%
  \fi
%    \end{macrocode}
%    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}}%
  \else
     \sbox{\L@lbox}{\LettrineFont #2}%
  \fi
%    \end{macrocode}
%
% \changes{v1.65}{2014/09/04}{Measure and store the initial's
%    final dimensions.}
%    Store the initial’s final dimensions,
%    \begin{macrocode}
  \setlength{\LettrineWidth}{\wd\L@lbox}%
  \setlength{\LettrineHeight}{\ht\L@lbox}%
  \setlength{\LettrineDepth}{\dp\L@lbox}%
%    \end{macrocode}
%
% \changes{v2.0}{2018/07/21}{Add informations about targeted
%    and actual height of the initial to the .log file.}
%
%    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
     (no accent, loversize=0),\MessageBreak
     Lettrine height = \the\LettrineHeight\space (#2)%
     \ifdim\@tempdima=\z@\else\space loversize=\L@oversize\fi;%
     \MessageBreak reported}%
  \endgroup
%    \end{macrocode}
%    and reset |\L@tbox|'s content (mandatory in case
%    |realheight=false|):
%
% \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.}
%
%    \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 of the top of paragraph.
%    We use |\L@first| to compute the amount of space to be skipped.
%
% \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'.}
%
% \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}
  \setlength{\L@first}{\LettrineHeight}%
  \setlength{\L@lraise}{\L@raise\L@target@tht}%
  \addtolength{\L@first}{\L@lraise}%
  \ifnum\value{L@lines}=1
    \addtolength{\L@first}{-\ht\L@tbox}%
  \else
    \addtolength{\L@first}{-\L@target@tht}%
    \addtolength{\L@lraise}{-\L@target@dp}%
  \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
%    \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
         \advance\@tempcnta by 1
         \advance\L@first by -\@tempdima
      \repeat
      \L@first=\@tempcnta\baselineskip
    \fi
    \vskip\L@first
  \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
%    reset later on to hold the first line's length.
%    \begin{macrocode}
  \setlength{\L@Pindent}{\wd\L@lbox}%
  \addtolength{\L@Pindent}{-\L@hang\wd\L@lbox}%
  \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\dots{} 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}.}
%
%    This is for quotation, quote, abstract\dots{} environments:
%    |\linewidth| is set by these environments, all we have to do
%    is to shift our text left by |\rightmargin| (amount of space
%    locally added to |\leftmargin| in these environments).
%    \begin{macrocode}
  \addtolength{\L@Pindent}{\rightmargin}%
  \addtolength{\L@Nindent}{\rightmargin}%
%    \end{macrocode}
%    Now, set up the shape of the new paragraph (designed by
%    |\parshape|).
%
% \changes{v1.9}{2015/08/31}{\cs{theL@depth} changed to
%    \cs{value\{L@depth\}}.}
%
%    \begin{macrocode}
  \addtocounter{L@lines}{1}%
  \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{%
     \edef\L@parshape{\L@parshape \the\L@Nindent \the\L@next}%
     \addtolength{\L@Nindent}{\L@slope}%
     \addtolength{\L@next}{-\L@slope}%
     \advance\@tempcnta\@ne}%
  \edef\L@parshape{\L@parshape \rightmargin \the\linewidth}%
  \noindent
  \parshape=\L@parshape\relax
%    \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.}
%    Write the dropped capital into the left margin, and wrap
%    the rest of paragraph around it.
%    \begin{macrocode}
  \smash{\llap{\mbox{\L@ante}\raisebox{\L@lraise}{\usebox{\L@lbox}}%
         \hskip \the\L@Findent}}%
  \usebox{\L@tbox}%
}
%    \end{macrocode}
% \end{macro}
%    This ends the definition of |\lettrine|.
%
%    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}
% \iffalse
%</sty>
% \fi
%
%  \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}{0.2pt}
%%
%% Theses are *flags* (value=true/false):
%%\LettrineImagefalse
%%\LettrineOnGridfalse
%%\LettrineRealHeightfalse
%%
%% Theses are *commands* (value=string, only height matters):
%%\renewcommand*{\LettrineTestString}{EFTZ}
%%\renewcommand*{\LettrineSecondString}{x}
%% For backward compatibility with versions 1.63 to 1.9:
%%\renewcommand*{\LettrineTestString}{ABCDEFGHIJKLMNOQPRSTUVWXYZ}
%% For backward compatibility with versions up to 1.62:
%%\renewcommand*{\LettrineTestString}{X}
%%
%% In case you want to set parameters for some letters
%% in file `optfile.cfl'
%% \renewcommand{\DefaultOptionsFile}{optfile.cfl}
%    \end{macrocode}
% \iffalse
%</cfg>
% \fi
%
% \iffalse
%<*dtx>
% \fi
%%
%% \CharacterTable
%%  {Upper-case    \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
%%   Lower-case    \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
%%   Digits        \0\1\2\3\4\5\6\7\8\9
%%   Exclamation   \!     Double quote  \"     Hash (number) \#
%%   Dollar        \$     Percent       \%     Ampersand     \&
%%   Acute accent  \'     Left paren    \(     Right paren   \)
%%   Asterisk      \*     Plus          \+     Comma         \,
%%   Minus         \-     Point         \.     Solidus       \/
%%   Colon         \:     Semicolon     \;     Less than     \<
%%   Equals        \=     Greater than  \>     Question mark \?
%%   Commercial at \@     Left bracket  \[     Backslash     \\
%%   Right bracket \]     Circumflex    \^     Underscore    \_
%%   Grave accent  \`     Left brace    \{     Vertical bar  \|
%%   Right brace   \}     Tilde         \~}
%%
% \iffalse
%</dtx>
% \fi
%
% \Finale
\endinput

%%% Local Variables:
%%% fill-column: 70
%%% coding: utf-8
%%% End: