如何更改 \subsection 以使文本紧随其后?

如何更改 \subsection 以使文本紧随其后?

考虑这个例子:

\documentclass[10pt,a4paper,oneside]{article}
\begin{document}
\section{Xavier functions}  
\subsection{} %% \textbf{1.1} 
We define the \textit{Xavier functions} for a complex value $z$ as
\[ \chi(z) = \exp(z). \]
\end{document}

问题是:如何在小节编号之后立即开始小节的文本?

在此处输入图片描述

(您可以通过将上面代码中的 \subsection{} 替换为 \textbf{1.1} 来模拟这一点。)

答案1

类似这样?。但正如前面提到的,如果你使用超出 1 级的目录,这将不太美观。当然,你可以在 \subsection{} 中包含一小段标题或文本开头

\documentclass[10pt,a4paper,oneside]{article}

\usepackage[explicit]{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{#1}
\titleformat{\subsection}[runin]{\normalsize\sffamily\bfseries}{\thesubsection}{1em}{#1} 

\begin{document}
\section{Xavier functions}  
\subsection{}
We define the \textit{Xavier functions} for a complex value $z$ as
\[ \chi(z) = \exp(z). \]

\subsection{Here is another}
starting with a title. 

\end{document}

在此处输入图片描述

我猜你也可以通过在可选标签中输入内容来使用目录,例如:

\documentclass[10pt,a4paper,oneside]{article}

\usepackage[explicit]{titlesec}
\titleformat{\section}{\normalfont\Large\bfseries}{\thesection}{1em}{#1}
\titleformat{\subsection}[runin]{\normalsize\sffamily\bfseries}{\thesubsection}{1em}{#1} 

\begin{document}

\tableofcontents

\section{Xavier functions}  
\subsection[The world defined]{}
We define the \textit{Xavier functions} for a complex value $z$ as
\[ \chi(z) = \exp(z). \]

\subsection{Here is another}
starting with a title. 

\subsection[Title for table of contents]{}

Cupim tail hamburger filet mignon, shankle drumstick corned beef turducken jowl shank. Pork chop rump pastrami filet mignon, spare ribs tri-tip flank. Tongue strip steak kielbasa ham hock cupim flank. Spare ribs beef capicola, cow ground round rump bresaola flank cupim filet mignon ball tip leberkas doner. Frankfurter pork chop short loin cupim. Shank chicken tenderloin biltong filet mignon t-bone flank pork chop short loin bresaola ham hock. 

Pork belly kevin pancetta meatball, meatloaf hamburger salami capicola pork spare ribs.

\end{document}

在此处输入图片描述

答案2

这是 Aubrey Blumsohn 的答案,经过了一些小修改。Aubrey 的答案使用不同的字体来表示枚举。但更重要的是,这种风格需要较小的子节之间的垂直空间。为了完整起见,我在这里列出了修改内容,并附上了一些测试代码。

\documentclass[10pt,a4paper,oneside]{article}
\usepackage[explicit]{titlesec}
\titleformat{\section}{\normalfont\fontsize{12}{11}\selectfont\bfseries}{\thesection}{10pt}{#1}[\vspace{10pt}]
\titleformat{\subsection}[runin]{\fontsize{10}{10}\bfseries\vspace{-10pt}}{\thesubsection}{6pt}{#1}
\newcommand{\postsection}{\vspace{-10pt}\hspace{18pt}}
\begin{document}
    \tableofcontents\bigskip\bigskip\hrule\bigskip
    \section{Basic functions} 
    \postsection The horizontal separation between label and body and must be a length. In fact, using it can lead to impredictable results. Anyway, if you need them, you may use them. 
    \subsection[Trigonometric functions]{} 
    For instance the functions $\sin(x)$ and $\cos(x)$ are basic trigonometric functions.
    \section{Special functions} 
    \subsection[Xavier functions]{} 
    We define the \textit{Xavier functions} for a complex value $z$ as
    \[\chi(z) = \exp(z).\]
    The horizontal separation between label and body and must be a length. In fact, using it can lead to impredictable results. Anyway, if you need them, you may use them. 
    \subsection[Annabelle functions]{} 
    We define the \textit{Annabelle functions} for a complex value $z$ as
    \[\alpha(z) = \log(z).\]
    The horizontal separation between label and body and must be a length. In fact, using it can lead to impredictable results. Anyway, if you need them, you may use them. 
    \subsection[Theorem]{Theorem}
    \textit{Xavier functions and Annabelle functions are related by}
    \[z = \chi(\alpha(z)).\]
    The horizontal separation between label and body and must be a length. In fact, using it can lead to impredictable results. Anyway, if you need them, you may use them. 
\end{document}

相关内容