0

I'm relatively new to LaTeX, and I'm typesetting a friend's coloring-in book. I'm using the "memoir" class. I want to include "Medieval" looking text under the pictures, so I'm using the lettrine package, but having to use lettrine within a Tikz environment (because of how I'm inserting the illustrations).

My issue is that within the Tikz node, the lettrine isn't working properly (that is, the text after the dropcap isn't aligning properly, but in a funny way as shown in the minimal working example).

What I really want is to get the text to wrap around properly after the dropcap instead of all aligning "underneath" the rest of the writing as in the minimal working example.

\documentclass[12pt]{memoir}

%%%%%%Here the packages %%%%%%%%%%%%% \usepackage{graphicx} \usepackage{tikz-cd} \usepackage{lettrine} \usepackage{Carrickc} \usepackage[absolute]{textpos}

\begin{document}

\begin{textblock} {\paperwidth}(0mm,0mm) \begin{figure} \centering \begin{tikzpicture} \node[] at (0,0) {\includegraphics[width=0.71\textwidth]{picture.png}}; \node[text width=8cm] at (0.45,-2.3) {\renewcommand\LettrineFontHook{\Carrickc} \setlength{\DefaultNindent}{0pt} \lettrine[lines=2]{O}{n}ce long ago there was some random text, and I am writing it here now to make a minimal working example. Thanks for your help!}; \end{tikzpicture} \end{figure} \end{textblock}

\end{document}

This is the result of the above code that shows my issue

I don't know what other details might be important---I'm compiling with LuaLaTeX, and using TexWorks!

Thank you immensely in advance for any advice or assistance! It's deeply appreciated.

  • Have you seen this post? https://tex.stackexchange.com/questions/250474/how-to-use-fancy-dropcaps-with-pdflatex – Sebastiano Feb 27 '24 at 19:34
  • You say you need the lettrine in the picture because of how you're doing things, but what you've shown seems like would be better as a picture and then the text afterward. BTW, the usual practice for lettrine is \lettrine{O}{nce} so that the rest of the first word is in small caps, not just the next letter. – Teepeemm Feb 27 '24 at 19:41
  • Please remove all packages (and perhaps other lines of code) which aren't needed to show you problem. Thank you. – MS-SPO Feb 27 '24 at 20:02
  • 1
    Thank you so much everyone for your input and help! I have edited to remove the unnecessary packages. – KR_Henninger Feb 28 '24 at 18:35

1 Answers1

2

Here is a way to do it. Some remarks:

  • I use a \def for the long text, as \newcommand doesn't seem to cooperate with Tikz too frequently
  • the first example is normal LaTeX text, using the text twice
  • with Tikz, the argument inside {} can be regular LaTeX text
  • you need a \parbox to make lettrine behave correctly
  • see Ch. 17.4.3 in the pgfmanual to learn about manual and automatic breaks
  • potential problems may arise from setting both widths of node text and \parbox to the same value

P.S.: Using a style definition like mine is the way to go, when you pass a text of unknown width to a node in Tikz.

However, using \parbox inside already determines the text width, and Tikz adjust the nodes height.

So style mine is obsolete and \node {\parbox{..}{whatever}}; is enough.

result

\documentclass{article}
\usepackage{lettrine,tikz}

% ~~~ shortcuts ~~~~~~~~~~~~~~~ \def\nce{nce long ago there was some random text, and I am writing it here now to make a minimal working example. Thanks for your help!}

% ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ \begin{document}

\noindent \lettrine[lines=2,realheight=true]{O}{}\nce{} O\nce{} \bigskip\bigskip

\begin{tikzpicture}[ mine/.style={text width=5cm,align=flush left}, ] \node[mine] at (0,-2) { \parbox{5cm}{ \lettrine[lines=2,realheight=true]{O}{}\nce{} } }; \end{tikzpicture}

\end{document}

MS-SPO
  • 11,519
  • After \newcommand{\nce}{...} you get *exactly* the same as with \def\nce{...}, with the only difference that the name is checked at definition time. So if your \def works, also \newcommand will. And it's bad policy to recommend \def for wrong reasons. – egreg Feb 27 '24 at 22:43
  • Sure, \newcommand is the better approach.It may work here, and failed often with other Tikz code to my observation. However, my P.S. is more important here. – MS-SPO Feb 28 '24 at 06:11
  • @MS-SPO: You have before advocated for the use of \def over \newcommand. I believe that is what you are using, so I am very interested in what circumstances you have observed \newcommand fail!? (Myself is a complete noob - and just stick to \newcommand because I read it somewhere once.) – hpekristiansen Feb 28 '24 at 09:09
  • 1
    @hpekristiansen, honestly, it's too long ago; if I recall correctly I tried replacing a value in a foreach loop or so, which failed. So if \newcommand works for you, stick with it. Should if fail with Tikz, both of us can and perhaps should raise it as a new question here. – MS-SPO Feb 28 '24 at 09:40
  • 1
    Thank you MS-SPO! I can't tell you how delighted I am to have this problem resolved! Hooray. – KR_Henninger Feb 28 '24 at 18:36
  • Great. Keep on latexing – MS-SPO Feb 28 '24 at 19:43