
Ich bin nicht sicher, ob \titlesec
das geht, aber ich möchte es als Ersatz für \lettrine
+ \addtocontents
für dasselbe verwenden.
Was ich will, sollte so aussehen:
Es gibt kein Problem mit der Verwendung von \lettrine
, es ist nur viel mehr manueller Code, als mir lieb ist, wenn es nur für den gleichen, wiederholten Stil ist. Ich nehme an, ich könnte immer ein Makro erstellen, aber trotzdem.
Edit: Ich dachte, es wäre klar, aber zur Klarstellung: Sie haben die Nummer 1, die eine Kapitelnummer ist. Derzeit sieht das so aus:
\lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{1}}{}%
%
In the beginning God creäted the heaven and the earth.
%
$^{2}$And the earth was without form, and void;
%
and darkness \textit{was} upon the face of the deep.
%
And the Spirit of God moved upon the face of the waters.
Ich möchte jedoch \lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{1}}{}%
durch ersetzen \section{}
.
In der Titlesec-Dokumentation ist eines der Beispiele für Titel:
\titleformat{\section}[wrap]
{\normalfont\fontseries{b}\selectfont\filright}
{\thesection.}{.5em}{}
\titlespacing{\section}
{12pc}{1.5ex plus .1ex minus .2ex}{1pc}
Dadurch wird \section{}
der Text um den Abschnitt herum umbrochen und unten eine leere Zeile eingefügt. Ich möchte etwas Ähnliches tun wie das, was ich mit getan habe, \lettrine
bin mir aber nicht sicher, wie das geht.
Antwort1
Etwas wie das?
\documentclass{article}
\usepackage{lettrine}
\usepackage{titlesec}
\usepackage{xparse}
\titleformat{\section}[wrap]
{\normalfont\fontseries{b}\selectfont\filright}
{}{0pt}{}
\titlespacing{\section}
{12pc}{1.5ex plus .1ex minus .2ex}{1pc}
\NewDocumentCommand\mysection{ O{#2} m }{%
\section[#1]{#2}
\everypar\expandafter{%
\the\everypar
\lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{\thesection}}{}}
}
\begin{document}
\mysection{Title}
In the beginning God creäted the heaven and the earth.
$^{2}$And the earth was without form, and void;
and darkness \textit{was} upon the face of the deep.
And the Spirit of God moved upon the face of the waters.
In the beginning God creäted the heaven and the earth.
$^{2}$And the earth was without form, and void;
and darkness \textit{was} upon the face of the deep.
And the Spirit of God moved upon the face of the waters.
\end{document}
Aktualisieren: Mit den im Juni 2021 in LaTeX2e eingeführten Absatz-Hooks kann dies robuster erreicht werden (geringere Wahrscheinlichkeit einer Inkompatibilität mit anderen Paketen/Einstellungen). Möglicherweise möchten Sie für kleinere After-Sep-Werte festlegen \section
.
\documentclass{article}
\usepackage{lettrine}
\usepackage{titlesec}
%\usepackage{xparse} % since latex2e Oct 2020, xparse is part of the kernel
\titleformat{\section}[hang]
{\normalfont\fontseries{b}\selectfont\raggedright}
{}{0pt}{}
\titlespacing{\section}
{12pc}{1.5ex plus .1ex minus .2ex}{1pc}
\NewDocumentCommand\mysection{ O{#2} m }{%
\section[#1]{#2}
% need latex2e Jun 2021
\AddToHookNext{para/begin}{%
\lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{\thesection}}{}%
}%
}
\begin{document}
\mysection{Title}
In the beginning God creäted the heaven and the earth.
$^{2}$And the earth was without form, and void;
and darkness \textit{was} upon the face of the deep.
And the Spirit of God moved upon the face of the waters.
In the beginning God creäted the heaven and the earth.
$^{2}$And the earth was without form, and void;
and darkness \textit{was} upon the face of the deep.
And the Spirit of God moved upon the face of the waters.
\end{document}