Text Formattinglettrine and newenvironment problem

Information and discussion about LaTeX's general text formatting features (e.g. bold, italic, enumerations, ...)
Post Reply
b.calmes
Posts: 4
Joined: Sat Nov 21, 2009 2:17 pm

lettrine and newenvironment problem

Post by b.calmes »

Hi,

Does anyone understand the weird behaviour of lettrine when used at the beginning of a newenvironment definition? It seems to put the letter in the margin, for a reason I don't understand. I've google a bit, without success. Here is a short example file demonstrating what I describe.

Any hints?

Code: Select all

\documentclass{article}\usepackage{lettrine}

\newenvironment{att}{\lettrine{A}{}}{}

\begin{document}
\begin{att}Lorem ipsum dolor sit amet, consectetur adipiscing elit.Vivamus tincidunt pharetra urna, consequat iaculis quam tempor in.
Donec ac justo est, sit amet tincidunt massa.
Nullam fringilla rhoncus mattis. Etiam at libero vitae lacus tempus lacinia.
Proin quis magna massa, eu euismod dolor. 
\end{att}
Integer vestibulum hendrerit ultricies. 
Maecenas egestas gravida felis ac mattis. 
Pellentesque hendrerit dictum augue, in bibendum lacus ullamcorper et. Nam et augue sapien, lacinia tempus ipsum. 
\end{document}

Recommended reading 2024:

LaTeXguide.org • LaTeX-Cookbook.net • TikZ.org

NEW: TikZ book now 40% off at Amazon.com for a short time.

And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p

localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

lettrine and newenvironment problem

Post by localghost »

Instead of using a search engine you'd better read the lettrine manual.


Best regards and welcome to the board
Thorsten¹
b.calmes
Posts: 4
Joined: Sat Nov 21, 2009 2:17 pm

lettrine and newenvironment problem

Post by b.calmes »

Instead of using a search engine you'd better read the lettrine manual.
Needless to say, I did that too, in the first place. But I cannot find any relevant information in the manual with respect to the problem mentioned above. Did you mention I should read the manual as a general comment, or do you actually mean that there is something specific in the manual that I missed? If it's the latter, I'd be very grateful if you could point it to me.

Of course, I could indeed go through the code of the whole lettrine package by hand, and figure out why it does this. Is that what you are actually suggesting?
User avatar
localghost
Site Moderator
Posts: 9202
Joined: Fri Feb 02, 2007 12:06 pm

lettrine and newenvironment problem

Post by localghost »

b.calmes wrote:Needless to say, I did that too, in the first place. But I cannot find any relevant information in the manual with respect to the problem mentioned above. Did you mention I should read the manual as a general comment, or do you actually mean that there is something specific in the manual that I missed? If it's the latter, I'd be very grateful if you could point it to me. [...]
Referencing the manual of a package has become a general suggestion of mine because most users waste their time with a search engine. In your case I couldn't know that you already took a look.
b.calmes wrote:[...] Of course, I could indeed go through the code of the whole lettrine package by hand, and figure out why it does this. Is that what you are actually suggesting?
Well, that's not what I would suggest because it would be once more waste of time. Here's an untested suggestion which should work.

Code: Select all

\newenvironment{att}{%
  \begin{minipage}{\linewidth}
    \lettrine{A}{}
}{\end{minipage}}
In case the length \parindent is different from zero, the new environment will be indented. You can prevent this indentation with a \noindent right before.
b.calmes
Posts: 4
Joined: Sat Nov 21, 2009 2:17 pm

Re: lettrine and newenvironment problem

Post by b.calmes »

Thanks for the suggestion.

It works, but I don't really want to use minipage, because minipage won't allow page breaks in the middle of the environment.

Thanks anyway.
b.calmes
Posts: 4
Joined: Sat Nov 21, 2009 2:17 pm

lettrine and newenvironment problem

Post by b.calmes »

Just to report back, a probably more "correct" solution, suggested to me by D. Flipo is to add the \par command at the end of the environment, as in:

Code: Select all

\newenvironment{att}{\lettrine{A}{}}{\par}
This is because of the \parshape command used in the code of lettrine. Of course, this forces the environment to end the current paragraph when it closes, but this is what you most of the time want with an environment.

N.B. Note that the original problem only arises when there is only one paragraph within the environment. If there are at least two, the first one is closed properly and there is no problem with lettrine.
Post Reply