Как использовать `\titlesec` для создания разделов с буквицами?

Как использовать `\titlesec` для создания разделов с буквицами?

Я не уверен, \titlesecможно ли это сделать, но я бы хотел использовать это вместо использования \lettrine+ \addtocontentsдля того же самого.

То, что я хочу, должно выглядеть так:

Изображение

Нет никаких проблем с использованием \lettrine, просто это намного больше ручного кода, чем мне бы хотелось, если это просто для того же, повторяющегося стиля. Полагаю, я всегда мог бы сделать макрос, но все же.

Редактировать: Я думал, что это ясно, но для ясности, у вас есть номер 1, который является номером главы. В настоящее время это выглядит так:

            \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.

Однако мне хотелось бы заменить \lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{1}}{}%его на \section{}.

В документации titlesec одним из примеров заголовков является:

\titleformat{\section}[wrap]
        {\normalfont\fontseries{b}\selectfont\filright}
        {\thesection.}{.5em}{}
\titlespacing{\section}
        {12pc}{1.5ex plus .1ex minus .2ex}{1pc}

Это изменяет \section{}так, что он оборачивает текст вокруг раздела и помещает пустую строку внизу. Я хотел бы сделать что-то похожее на то, что я сделал с , \lettrineхотя я не уверен, как это сделать.

решение1

Что-то вроде этого?

\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}

введите описание изображения здесь

Обновлять: С хуками абзацев, представленными в LaTeX2e в июне 2021 г., это может быть достигнуто более надежно (меньше шансов быть несовместимым с другими пакетами/настройками). Вы можете захотеть установить меньший after-sep для \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}

введите описание изображения здесь

Связанный контент