本文中のサブセクションの見出し

本文中のサブセクションの見出し

下の図のように、サブセクションの見出しをテキストに埋め込むにはどうすればよいでしょうか?ほとんどの標準的なLaTeXテンプレートでは、

1.2関数体に関するヴェイユの予想

このセクションで...

雑然としてしまうと思うので、私はこれを避けようとしています。それでも、セクションの見出しには隙間があり、サブセクションの見出しの前には小さなスペースがあるようにしたいと思います (下の図を参照)。

ここに画像の説明を入力してください

編集:ご要望に応じて、問題を示す最小限の動作例を以下に示します。

\documentclass[12pt]{article}
\begin{document}

\section{Section}

Text A

\subsection{Subsection}

There are two problems with this working example: the subsection is not part of this paragraph (and the letters are not the same size as the letters here), and the gap between Text A and the subsection is too large.

\end{document}

これを TeXmaker に入力すると、次の画像が出力されます。

ここに画像の説明を入力してください

使用しているドキュメント クラスを変更できて嬉しいです。

答え1

画像の出力を再現したい場合は、 を使用しますamsart

\documentclass[12pt]{amsart}

\newtheorem{theorem}{Theorem}[section]
\theoremstyle{definition}
\newtheorem{remark}[theorem]{Remark}

\begin{document}

Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.

\section{Section title}

Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.

\subsection{Subsection title}

Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.

\begin{theorem}
A theorem statement. A theorem statement. A theorem statement.
A theorem statement. A theorem statement.
\end{theorem}

\begin{remark}
A remark. A remark. A remark. A remark. A remark.
\end{remark}

Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.

\subsection{Another subsection title}

Some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words some nonsense words some nonsense words
some nonsense words.

\end{document}

ここに画像の説明を入力してください

答え2

(パッケージなし)ではarticle、セクション マクロはすべて\@startsection内部で使用されます。\@startsectionセクション タイトルの外観を制御する 6 つの引数を取ります。

\@startsection
  {<sectioning name>}
  {<sectioning level>}
  {<horizontal indent from left>}
  {<vertical skip pre>}
  {<skip post>}
  {<font choice>}

上記の引数のほとんどは説明を要しませんが、そのうちの 2 つは少し特殊な動作をします。

  • <vertical skip pre>見出しの後の段落をインデントするかどうかを決定します。これが正または 0 の場合、次の段落は通常どおりインデントされます。これが負の場合、インデントは抑制されます。どちらの場合も、この絶対値は垂直スキップに使用されます。

  • <skip post>見出しがランイン見出しとして表示されるかどうかを制御します。これが正の場合、見出しの後に垂直スキップとして動作し、見出しが表示されます。これが負または 0 の場合、見出しはランイン見出しとなり、これは見出しと同じ行のテキスト間の水平スキップになります。

これで、\subsectionランイン見出しとしてフォーマットされるように再定義できるようになりました。

\renewcommand\subsection
  {%
    \@startsection
      {subsection}
      {2}
      {\z@}
      {3.25ex \@plus 1ex \@minus .2ex}
      {-1em}
      {\normalfont\normalsize\bfseries}%
  }

レベルでこのフォーマットを開始する場合は\subsection\subsubsection同じ方法で再定義する必要があります。これらの再定義を行う完全なドキュメントは次のとおりです。

\documentclass[]{article}

\makeatletter
\renewcommand\subsection
  {%
    \@startsection
      {subsection}
      {2}
      {\z@}
      {3.25ex \@plus 1ex \@minus .2ex}
      {-1em}
      {\normalfont\normalsize\bfseries}%
  }
\renewcommand\subsubsection
  {%
    \@startsection
      {subsubsection}
      {3}
      {\z@}
      {3.25ex \@plus 1ex \@minus .2ex}
      {-1em}
      {\normalfont\normalsize\bfseries}%
  }
\makeatother

\usepackage{duckuments}

\begin{document}
\section{This is a section}\blindduck
\subsection{This is a subsection}\blindduck
\subsubsection{This is a subsubsection}\blindduck
\paragraph{This is a paragraph}\blindduck
\end{document}

ここに画像の説明を入力してください

答え3

およびtitlesecarticle:

ここに画像の説明を入力してください

\documentclass[12pt]{article}

\usepackage{titlesec}
\titleformat{\subsection}[runin]{\normalsize\bfseries}{\thesubsection}{5pt}{}

\begin{document}

\section{Section}

Text A

\subsection{Subsection}

There are two problems with this working example: the subsection is not part of this paragraph (and the letters are not the same size as the letters here), and the gap between Text A and the subsection is too large.

\end{document}

関連情報