2

I have this package lettrex.sty

\NeedsTeXFormat{LaTeX2e}
%
\RequirePackage{%
lettrine,%
ifthen,%
}
%
\setcounter{DefaultLines}{3}
\renewcommand{\DefaultLoversize}{0.07}
%
\DeclareOption{Libertine-Initials}{%
%X \renewcommand{\DefaultOptionsFile}{Libertine-Initials-Lettrinex.cfg}%
  \let\OldLettrine\lettrine%
  \renewcommand{\lettrine}[3][]{%
     \OldLettrine[#1]{\libertineInitialGlyph{#2}}{\MakeLowercase{#3}}%
  }%
}

\ProcessOptions\relax%
\endinput

and this config file Libertine-Initials-Lettrinex.cfg

    \LettrineOptionsFor{A}{findent=-0.8em,nindent=0.5em,loversize=0.07,slope=0.6em}

When I compile pdflatex testL-In.tex

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{blindtext}

\usepackage[Libertine-Initials]{lettrex}

\begin{document}
\lettrine{A}{is a letter of our alphabet}. \blindtext
\end{document}

then all seems OK. But when I remove the %X in lettrex.sty to enable the options for letter 'A', I get this error:

(./testL-In.aux) (./Libertine-Initials-Lettrinex.cfg)
! Missing \endcsname inserted.
<to be read again> 
                   \protect 
l.16 \lettrine{A}{is a letter of our alphabet}
                                              . \blindtext
? 

(/zfs/texlive/2022/texmf-dist/tex/latex/libertine/T1LinuxLibertineInitialsT-LF.
fd)
! Extra \endcsname.
\@lettrine ...er \ifx \csname l@#2-keys\endcsname 
                                                  \relax \gdef \l@LOKeys {}\...
l.16 \lettrine{A}{is a letter of our alphabet}
                                              . \blindtext
? 

Overfull \hbox (7.46712pt too wide) in paragraph at lines 16--17
[][]\T1/LinuxLibertineT-TLF/m/n/12 . Lorem ip-sum do-lor sit amet, con-sectetue
r
[1{/zfs/texlive/2022/texmf-var/fonts/map/pdftex/updmap/pdftex.map}]
(./testL-In.aux) ){/zfs/texlive/2022/texmf-dist/fonts/enc/dvips/libertine/lbtn_
ncsllp.enc}{/zfs/texlive/2022/texmf-dist/fonts/enc/dvips/libertine/lbtn_vsrqlo.
enc}{/zfs/texlive/2022/texmf-dist/fonts/enc/dvips/libertine/lbtn_76gpa5.enc}</z
fs/texlive/2022/texmf-dist/fonts/type1/public/libertine/LinLibertineIT.pfb></zf
s/texlive/2022/texmf-dist/fonts/type1/public/libertine/LinLibertineT.pfb>
Output written on testL-In.pdf (1 page, 119263 bytes).
Transcript written on testL-In.log.

Finally it does give me the Initial, but what is done wrong here?

2
  • you are changing the second argument to \libertineInitialGlyph{#2}, and that means that lettrine doesn't look up a configuration for A with \csname l@A-keys\endcsname but tries to find \csname l@\libertineInitialGlyph{A}-keys\endcsname and that explodes. Dec 30, 2022 at 11:20
  • Thanks Ulrike. As this goes beyond my TeX-kownledge: Is there a (hopefully simple) solution for this? Is there a way to access the libertine Initials other than by \libertineInitialGlyph in pdflatex?
    – Jack
    Dec 30, 2022 at 22:45

3 Answers 3

2

There is no need to patch \lettrine, you can use the hooks provided by lettrine:

\begin{filecontents}{Libertine-Initials-Lettrinex.cfg}
\LettrineOptionsFor{A}{findent=-0.8em,nindent=0.5em,loversize=0.07,slope=0.6em}
\end{filecontents}

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{blindtext}

\usepackage[optionsfile=Libertine-Initials-Lettrinex.cfg]{lettrine}
\renewcommand\LettrineFontHook{\libertineInitial}
\renewcommand\LettrineTextFont{\MakeLowercase}
\begin{document}

\lettrine{A}{IS A LETTER OF OUR ALPHABET}. %uppercase for demo
\blindtext
\end{document}

enter image description here

1

The problem is that the second argument is used to check whether the particular initial is associated to some code in the .cfg file and passing it \libertineInitialGlyph{<letter>} breaks.

You need to patch something else, namely \setupL@lbox, where the typeset initial is stored.

I don't think you really want \MakeLowercase for the second argument.

\NeedsTeXFormat{LaTeX2e}

\RequirePackage{lettrine}

\setcounter{DefaultLines}{3}
\renewcommand{\DefaultLoversize}{0.07}

\DeclareOption{Libertine-Initials}{%
  \renewcommand{\DefaultOptionsFile}{Libertine-Initials-Lettrinex.cfg}%
  \def\setupL@lbox{%
    \computeL@height
    \ifL@image
      \sbox{\L@lbox}{\LettrineImage{\l@initial}}%
    \else
      \compute@fontsize
      \sbox{\L@lbox}{\LettrineFont\libertineInitialGlyph{\l@initial}}%
    \fi
  }%
}

\ProcessOptions\relax

\endinput

enter image description here

Probably you can remove \LettrineFont.

0

You do not need to patch anything, just change your lettrex.sty file:

\begin{filecontents}{Libertine-Initials.cfg}
\LettrineOptionsFor{A}{findent=-0.8em,
    nindent=0.5em,loversize=0.07,slope=0.6em}
\end{filecontents}

\begin{filecontents}{lettrex.sty}
\NeedsTeXFormat{LaTeX2e}

\RequirePackage{%
  lettrine,%
  iftex,%
}

\setcounter{DefaultLines}{3}
\renewcommand{\DefaultLoversize}{0.07}

\DeclareOption{Libertine-Initials}{%
\renewcommand{\LettrineFontHook}{%
              \fontfamily{LinuxLibertineInitialsT-LF}}
\renewcommand{\DefaultOptionsFile}{Libertine-Initials.cfg}
}
\ifpdftex
  \DeclareOption{Libertine-Initials}{%
  \renewcommand\LettrineFontHook{%
               \fontfamily{LinuxLibertineInitialsT-LF}}
  \renewcommand{\DefaultOptionsFile}{Libertine-Initials.cfg}
  }
\else
  \DeclareOption{Libertine-Initials}{%
  \renewcommand\LettrineFontHook{\fontspec{LinLibertine_I.otf}}
  \renewcommand{\DefaultOptionsFile}{Libertine-Initials.cfg}
 }
\fi

\ProcessOptions\relax
\endinput
\end{filecontents}

\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage{libertine}
\usepackage{blindtext}
\usepackage[Libertine-Initials]{lettrex}

\begin{document}
\lettrine{A}{is a letter of our alphabet}. \blindtext
\end{document}

produces no error message and outputs

enter image description here

If you don't want small caps for the second argument of \lettrine, just add \renewcommand{\LettrineTextFont}{\relax}

5
  • Thanks Daniel, this is the simple solution I was looking for. I have a related question though: When I want Old Style Figures, and do \usepackage[osf]{libertine} then the Initials font is not found anymore. Is there a (simple?) way of combining osf with libertine-initials while using the package lettrex?
    – Jack
    Jan 2 at 8:39
  • The libertine package wrongly forwards the osf option to the LinuxLibertineInitials font. I have patched my answer to overcome this glitch. Jan 3 at 10:03
  • Note that the patch is not necessary if you compile with a "modern" engine luatex or xetex. Jan 3 at 10:08
  • Thanks again. I know, but I'm building a small package and want to support pdflatex as well. I think still a lot of people do use that, due to its compiling speed, which is superior to the newer engines. That at least is the main reason I still use pdflatex
    – Jack
    Jan 3 at 16:28
  • The above code works for both pdflatex and lualatex, so you will be still able to use it if you ever change your mind ;-) Note that the way of calling LinuxLibertineInitials differs for pdflatex against lualatex/xeltex. Jan 3 at 18:08

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .