¿Cómo se usaría `\titlesec` para crear secciones con letras mayúsculas?

¿Cómo se usaría `\titlesec` para crear secciones con letras mayúsculas?

No estoy seguro de \titlesecpoder hacer esto, pero me gustaría usarlo para reemplazar el uso de \lettrine+ \addtocontentspara lo mismo.

Lo que quiero debería verse así:

Una imagen

No hay ningún problema con el uso \lettrine, simplemente es mucho más código manual del que me gustaría, si es solo para el mismo estilo repetido. Supongo que siempre podría hacer una macro, pero aún así.

Editar: pensé que estaba claro, pero para aclarar, tienes el número 1, que es un número de capítulo. Actualmente, esto se ve así:

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

Sin embargo, lo que me gustaría hacer es reemplazarlo \lettrine[lines=2,nindent=0pt,findent=2pt]{\textbf{1}}{}%con \section{}.

En la documentación de titlesec, uno de los ejemplos de títulos es:

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

Esto modifica el \section{}texto para que ajuste el texto alrededor de la sección y coloque una línea vacía en la parte inferior. Me gustaría hacer algo similar a lo que he hecho \lettrineaunque no estoy seguro de cómo hacerlo.

Respuesta1

¿Algo como esto?

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

ingrese la descripción de la imagen aquí

Actualizar: Con los ganchos de párrafo introducidos en LaTeX2e de junio de 2021, esto se puede lograr de manera más sólida (menos posibilidades de ser incompatible con otros paquetes/configuraciones). Es posible que desees establecer un after-sep más pequeño para \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}

ingrese la descripción de la imagen aquí

información relacionada