我不确定是否\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 Jun 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}