Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

How can I modify the following macro to automatically have the initial with the height indicated in the picture?

\documentclass{article}

\makeatletter

\RequirePackage{tikz}

\newlength\CLett% Nuova dimensione

 \newcommand*\capolettera[2]{% #1 lettera da ingrandire #2 testo in maiuscoletto
\par\noindent\setbox\z@\hbox{%
             \scalebox{1.35}{%
                            \huge#1}%
                            }%
\CLett=\wd\z@\hangindent\CLett\hangafter-2\relax%
\raisebox{-\baselineskip}[0pt][0pt]{\llap{\box\z@\kern1pt}}\textsc{#2}}

\makeatother

\begin{document}

\capolettera{L}{orem ipsum} at nusquam appellantur his, ut eos erant homero
concludaturque. Albucius appellantur deterruisset id eam, vivendum
partiendo dissentiet ei ius. Vis melius facilisis ea, sea id convenire
referrentur, takimata adolescens ex duo. Ei harum argumentum per. Eam
vidit exerci appetere ad, ut vel zzril intellegam interpretaris.

\end{document}

enter image description here

share|improve this question
    
Not sure I understand what you mean by "have an initial"? –  Peter Grill Oct 3 '12 at 20:52
    
@PeterGrill I have updated my question –  FormlessCloud Oct 3 '12 at 20:55
1  
it should be \dimexpr\baselineskip+1ex\relax but I'm not 100% sure. –  yo' Oct 3 '12 at 20:56
1  
@FormlessCloud Don't change answered questions to add new requests; rather ask a followup question. –  egreg Jul 4 at 13:36

2 Answers 2

up vote 11 down vote accepted

enter image description here

I used \resizebox rather than \scalebox to force the initial to \baselineskip + the height of the small caps text.

\documentclass{article}

\makeatletter

\RequirePackage{tikz}

\newlength\CLett% Nuova dimensione

 \newcommand*\capolettera[2]{% #1 lettera da ingrandire #2 testo in maiuscoletto
\par\noindent
 \setbox8\hbox{\textsc{#2}}%
 \setbox\z@\hbox{%
             \resizebox{!}{\dimexpr\baselineskip+\ht8\relax}{%
                            \huge#1}%
                            }%
\CLett=\wd\z@\hangindent\CLett\hangafter-2\relax%
\raisebox{-\baselineskip}[0pt][0pt]{\llap{\box\z@\kern1pt}}{\box8}}

\makeatother

\begin{document}

\capolettera{L}{orem ipsum} at nusquam appellantur his, ut eos erant homero
concludaturque. Albucius appellantur deterruisset id eam, vivendum
partiendo dissentiet ei ius. Vis melius facilisis ea, sea id convenire
referrentur, takimata adolescens ex duo. Ei harum argumentum per. Eam
vidit exerci appetere ad, ut vel zzril intellegam interpretaris.

\end{document}
share|improve this answer
    
thanks ! I get an OverFull \hbox at the line 23 is it normal? –  FormlessCloud Oct 3 '12 at 21:07
    
did you get one before in the original mwe? (I'll check) –  David Carlisle Oct 3 '12 at 21:20
    
yes the original MWE was the same, it's just an artifact of typesetting latin with english hyphenation patterns. So it can't set the paragraph text, not related to the drop cap. –  David Carlisle Oct 3 '12 at 21:23
    
in fact if I use \usepackage[italian]{babel} I haven't it anymore. Thanks again ;) ! –  FormlessCloud Oct 3 '12 at 21:30
1  
@FormlessCloud as egreg commented it's best not to alter old questions in that way but anyway changing \huge#1}% to \huge#1}\kern1in% would add some space I would assume –  David Carlisle Jul 4 at 13:47

I like this a lot. I made a couple of small changes: 1) I introduced an optional argument to tell the macro how many lines to drop the cap (2 being the default); 2) I used \unhbox8 so that the spacing between the words in small caps is consistent with the rest of the line.

\documentclass{article}

\makeatletter

\usepackage{graphicx}

\newlength\CLett% Nuova dimensione

 \newcommand*\capolettera[3][2]{% #1 lettera da ingrandire #2 testo in maiuscoletto
    \par
    \noindent
    \setbox8\hbox{\textsc{#3}}%
    \setbox\z@\hbox{%
        \resizebox{!}{\dimexpr#1\baselineskip-\baselineskip+\ht8\relax}{\huge#2}%
    }%
    \CLett=\wd\z@%
    \hangindent\CLett
    \hangafter-#1\relax
    \raisebox{\dimexpr-#1\baselineskip+\baselineskip\relax}[0pt][0pt]%
        {\llap{\box\z@\kern1pt}}{\unhbox8}%
}

\makeatother

\begin{document}

\capolettera[4]{L}{orem ipsum} at nusquam appellantur his, ut eos erant homero
concludaturque. Albucius appellantur deterruisset id eam, vivendum
partiendo dissentiet ei ius. Vis melius facilisis ea, sea id convenire
referrentur, takimata adolescens ex duo. Ei harum argumentum per. Eam
vidit exerci appetere ad, ut vel zzril intellegam interpretaris.

\end{document}

4-line drop cap.

One of the reasons this is so nice is that you can do things like this:

\capolettera[4]{\textbf{L}}{\kern-6pt orem ipsum}

enter image description here

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.