I'm setting a novel using memoir and markdown with simple Markdown supplied by the author. This workflow is working surprisingly well and yields professional results.
Now, as the icing on the cake, I'd like to automatically \lettrine the first word of a chapter. There are recipes to be found here on this site, but none of them fits my problem. What I'm basically looking for is a way to feed the first word of a chapter to a command. From there I can use some Lua code to decide on when and how to employ a drop cap.
Here is a stripped-down example of the environment I use:
\documentclass{memoir}
\chapterstyle{thatcher}
\usepackage{fontspec}
\setmainfont{TeX Gyre Pagella}
\usepackage[english]{babel}
\usepackage[babel, strict]{csquotes}
\MakeOuterQuote{"}
\MakeInnerQuote{´}
\usepackage[inlineFootnotes, smartEllipses, fencedCode]{markdown}
\markdownSetup{
renderers = {
ellipsis = {\dots},
tilde = ~
}
}
\begin{document}
\markdownInput{test.md}
\end{document}
And this is an example test.md:
# First chapter
Some italic text as often seen in introductions.
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Second chapter
"This one starts with a quote." That's where the Lua code will decide how to set it~...
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
Third chapter
Just normal text.
Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat. Quis aute iure reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint obcaecat cupiditat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
I'm not that familiar with Tex, unfortunately, and would appreciate any help. If this should not be solvable, it is also not so bad. As said, it would just be the icing on the cake.
Thanks, Flössie
markdownbut nevertheless it seems to me that you are asking for LaTeX to recognise a "word". What is a word? Is it a group of alphabetic characters followed by a space or punctuation mark. What if the characters are preceeded by something, perhaps like " or, say #? – Peter Wilson Jan 14 '22 at 18:37\lettrine? As I've not come this far yet I can't provide you with an implementation, but it would basically be a first a check, if the first letter is a quotation mark which is either omitted or set asanteinlettrine, and then a table lookup of the first (if it wasn't a quotation mark) or second (if it was) letter as key andlettrineparameters as value, because each letter might have a differentslopeorimageetc. – Flössie Jan 23 '22 at 09:47\directluawhich is defined in a seperate file. I've sample code for that, if that's what you're asking for? Thanks for your interest in my problem, by the way! – Flössie Jan 23 '22 at 09:53