Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fails with lettrine and bidi #13

Closed
4 tasks
wujastyk opened this issue Oct 14, 2022 · 4 comments
Closed
4 tasks

fails with lettrine and bidi #13

wujastyk opened this issue Oct 14, 2022 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@wujastyk
Copy link

Brief outline of the issue

Check/indicate

Minimal example showing the issue


bidi's documentation says it supports lettrine, but I'm having trouble.

MWE:

% !TeX TS-program = xelatex
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{lettrine}% position 1
\usepackage{bidi}
%\usepackage{lettrine} % position 2

\begin{document}
	\lettrine{H}{ere is a nice beginning} to a paragraph.  The current document contains no 
	words, but we need some phrases as a base to create the random text from. The current 
	document contains no words, but we need some phrases as a base to create the random 
	text from.  
\end{document}

When lettrine is invoked at position 1, I get

Package bidi Error: Oops! you have loaded package lettrine after bidi package on your document again. 
\begin{document}

And at position 2, I get

Undefined control sequence. \lettrine{H}{ere is a nice beginning}
@wujastyk wujastyk added the bug Something isn't working label Oct 14, 2022
@EliseyP
Copy link

EliseyP commented Oct 18, 2022

Apropos - lualatex compile it.

@kvafa kvafa closed this as completed in d104cf3 Nov 6, 2022
@kvafa
Copy link
Owner

kvafa commented Nov 6, 2022

Brief outline of the issue

Check/indicate

Minimal example showing the issue


bidi's documentation says it supports lettrine, but I'm having trouble.

MWE:

% !TeX TS-program = xelatex
% !TeX encoding = UTF-8
\documentclass{article}
\usepackage{lettrine}% position 1
\usepackage{bidi}
%\usepackage{lettrine} % position 2

\begin{document}
	\lettrine{H}{ere is a nice beginning} to a paragraph.  The current document contains no 
	words, but we need some phrases as a base to create the random text from. The current 
	document contains no words, but we need some phrases as a base to create the random 
	text from.  
\end{document}

When lettrine is invoked at position 1, I get

Package bidi Error: Oops! you have loaded package lettrine after bidi package on your document again. 
\begin{document}

And at position 2, I get

Undefined control sequence. \lettrine{H}{ere is a nice beginning}

Thanks for your bug report and my apologies for the delay. I have fixed it and pushed the new version to CTAN.

@kvafa
Copy link
Owner

kvafa commented Nov 6, 2022

Apropos - lualatex compile it.

That is irrelevant here.

@EliseyP
Copy link

EliseyP commented Jan 29, 2024

After update at jan 24, I have this log strings by compile this (same as above) MWE:

xelatex -synctex=1 -interaction=nonstopmode "lettrine-test-2024".tex

This is XeTeX, Version 3.141592653-2.6-0.999995 (TeX Live 2023) (preloaded format=xelatex)
<...>
* bidi package (Bidirectional typesetting in
<...>
* v39.8 (Release Donald Ervin Knuth), 2023/08/02
<...>
! Undefined control sequence.
<argument> \LettrineFont \L@initial 
                                    
l.9 ^^I\lettrine{H}{ere is a nice beginning}
                                             to a paragraph.  The current do...

Problem solved by editing line 42 in texlive/current/texmf-dist/tex/xelatex/bidi/lettrine-xetex-bidi.def
\def\l@initial{#2}\let\l@refstring\l@initial ->
\def\L@initial{#2}\let\L@refstring\L@initial.

At lettrine-2023-04-18.sty:[84,104] we have
refstring.default:n = \l@initial
But in 2024-01-20 v2.60 (Daniel Flipo) lettrine.sty:[90,111] we have
refstring.default:n = \L@initial

UPD:

Options lines=n - not working too. We get error:

Package xkeyval Error: `lines' undefined in families `L'.

Problem imho in lettrine-xetex-bidi.def:56
\setkeys{L}{#1}%
(last version lettrine.sty use \SetKeys)
I tried to get code lines from previous versions of lettrine-2022-09-25.sty:
\define@key{L}{lines}{\setcounter{L@lines}{#1}}
and other. It solve this part of problem.

Note: I tried to delete lettrine-xetex-bidi.def as I read in lettrine documentation:

you can safely remove lettrine-xetex-bidi.def when installing v2.60 of lettrine.

but I get error: File "lettrine-xetex-bidi.def" not found.

So, with edited lettrine-xetex-bidi.def in my texmf-local all work fine.

Added keys definitions and all l@ -> L@ in \@lettrine macros:

\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}}
\define@key{L}{refstring}[\l@initial]{\L@selfreftrue
                                      \def\l@refstring{#1}}
\def\@lettrine[#1]#2#3{%
  \def\L@initial{#2}\let\L@refstring\L@initial
  \setcounter{L@lines}{\value{DefaultLines}}%
  \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
  \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
  \if\DefaultOptionsFile\relax
  \else
    \begingroup
    \InputIfFileExists{\DefaultOptionsFile}%
      {}%
      {\PackageWarning{lettrine.sty}%
         {File \DefaultOptionsFile\space not found}%
      }%
    \def\color##1##{\L@color{##1}}%
    \let\L@color\@gobbletwo
    \def\textcolor##1##{\L@textcolor{##1}}%
    \def\L@textcolor##1##2##3{##3}%
    \expandafter\ifx\csname L@#2-keys\endcsname\relax
                  \gdef\L@LOKeys{}%
                \else
                  \xdef\L@LOKeys{\csname L@#2-keys\endcsname}%
                \fi
    \endgroup
    \def\KV@prefix{KV@L@}%
    \let\@tempc\relax
    \expandafter\KV@do\L@LOKeys,\relax,
    \setupL@lbox
    \setlength{\LettrineWidth}{\wd\L@lbox}%
    \def\KV@prefix{KV@L@}%
    \let\@tempc\relax
    \expandafter\KV@do\L@LOKeys,\relax,
    \setkeys{L}{#1}%
  \fi
 \setupL@lbox
  \setlength{\LettrineWidth}{\wd\L@lbox}%
  \setlength{\LettrineHeight}{\ht\L@lbox}%
  \setlength{\LettrineDepth}{\dp\L@lbox}%
  \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@\else\space loversize=\L@oversize\fi;%
     \MessageBreak reported}%
  \endgroup
  \sbox{\L@tbox}{\LettrineTextFont{#3}}%
  \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
  \ifdim\L@first>\L@novskip
    \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
  \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}%
  \addtolength{\L@Nindent}{\L@Pindent}%
  \setlength{\L@next}{\linewidth}%
  \addtolength{\L@next}{-\L@Nindent}%
  \addtolength{\L@Pindent}{\@totalleftmargin}%
  \addtolength{\L@Nindent}{\@totalleftmargin}%
  \addtocounter{L@lines}{1}%
  \addtocounter{L@lines}{\value{L@depth}}%
  \if@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{%
    \if@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}%
  \if@RTL
    \edef\L@parshape{\L@parshape \z@ \the\linewidth}%
  \else
    \edef\L@parshape{\L@parshape \@totalleftmargin \the\linewidth}%
  \fi
  \noindent
  \parshape=\L@parshape\relax
  \smash{\llap{\mbox{\L@ante}\raisebox{\L@lraise}{\usebox{\L@lbox}}%
         \hskip \the\L@Findent}}%
  \usebox{\L@tbox}%
  \ifnum\@listdepth>0 \Lreset@listparshape \fi
}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

3 participants