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. –  tohecz Oct 3 '12 at 20:56
add comment

1 Answer

up vote 9 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
    
I have forgotten one thing: the initial is only stretched to fit the \baselineskip + the height of the small caps text or it is rescaled to have the right proportions? –  FormlessCloud Oct 4 '12 at 15:16
show 2 more comments

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.