I'm preparing a very simple, but also very long document for someone who is providing me with many dozens of tex files being included using \input{}. In part, so the original author still has clean tex files, I am trying to make use of some previously posted code to automate the action of the lettrine package.
Automatic dropcaps for the first letter of a chapter
Their content is very simple so I'm not too worried about exceptions.
Unfortunately I'm unable to use the automation code I've found in previous questions because I have so many files with line breaks in the tex files in between the \chapter{} and the paragraph of text.
I've tried a few approaches (commented out in the MWE below) to no avail. To get this document to compile properly, simply remove the line after the chapter, or insert a %.
Is there anyway to reset the code following \chapter{} to do this?
MWE with gobble par code that isn't yet working:
\documentclass{report}
%https://tex.stackexchange.com/questions/205364/automatic-dropcaps-for-the-first-letter-of-a-chapter
%https://tex.stackexchange.com/questions/769/how-can-i-create-documents-in-latex-using-a-calligraphic-first-letter-for-chapte
\usepackage[x11names]{xcolor}
\usepackage{lipsum}
\usepackage{environ}
\usepackage{xstring}
\usepackage{lettrine}
\usepackage{GoudyIn}
%\usepackage[x11names]{xcolor}
\renewcommand{\LettrineFontHook}{\color{VioletRed4}\GoudyInfamily{}}
\LettrineTextFont{\itshape}
\setcounter{DefaultLines}{3}%
%http://phaseportrait.blogspot.ca/2011/08/using-gobblepars-to-prevent-latex-from.html
\makeatletter
\newcommand\gobblepars{%
\@ifnextchar\par%
{\expandafter\gobblepars\@gobble}%
{}}
\makeatother
%https://tex.stackexchange.com/questions/179016/ignore-spaces-and-pars-after-an-environment
\def\useignorespacesandallpars#1\ignorespaces\fi{%
#1\fi\ignorespacesandallpars}
\makeatletter
\def\ignorespacesandallpars{%
\@ifnextchar\par
{\expandafter\ignorespacesandallpars\@gobble}%
{}%
}
\makeatother
\makeatletter
\let\ltx@@chapter\@chapter
\def\@chapter[#1]#2 #3 {%
\ltx@@chapter[#1]{#2}
\the\ch@pterpreamble
\ch@pterpreamble{}
\StrLeft{#3}{1}[\@tempa]
\ifcat\@tempa a
\lettrine{\StrLeft{#3}{1}}{\@gobble#3}
\else
#3
\fi
}
\newtoks\ch@pterpreamble
\NewEnviron{chapterpreamble}{\global\ch@pterpreamble=\expandafter{\BODY}}
\makeatother
%\let\unskippedchapter\chapter
%\renewcommand{\chapter}[1]{\unskippedchapter{#1}\gobblepars}
\begin{document}
\chapter{Demo}
%
The quick brown dog jumped over the lazy brown fox.
The quick brown dog jumped over the lazy brown fox.
The quick brown dog jumped over the lazy brown fox.
The quick brown dog jumped over the lazy brown fox.
The quick brown dog jumped over the lazy brown fox.
The quick brown dog jumped over the lazy brown fox.
\end{document}
