%20%E3%81%A7%E3%81%AF%E7%AB%A0%E3%81%AE%E6%B0%B4%E5%B9%B3%E7%B7%9A%E3%81%8C%E8%A1%A8%E7%A4%BA%E3%81%95%E3%82%8C%E3%81%BE%E3%81%9B%E3%82%93.png)
titlesec
私は、各章の下に水平線を引くという簡単なことを試してみました。チュートリアル、ドキュメント、質問がたくさんあります。テックスどのようにすればこれが実現できるかを説明するものがいくつかあります。しかし...それらの答えのどれも全く役に立ちませんでした。私が試した解決策は次のとおりです。
しかし、いずれの場合も、コンパイルされた PDF には、 を一切使用せずに表示されていた内容が正確に表示されます\titleformat
。現在のプリアンブルでは、 を次のように使用していますtitlesec
。
\documentclass[11pt,oneside]{book}
\usepackage{titlesec}
% Below "\section" can be replaced with "\subsection" and "\subsubsection"
% in order to customize the corresponding headings. "bch" - Bitstream
% Charter, "b" - bold.
\titleformat{\section}[hang]
{\usefont{T1}{bch}{b}{n}\selectfont}
{} % label
{0em} % horizontal separation between label and title body
{\hspace{-0.4pt}\Large \thesection\hspace{0.6em}} % before-code
[] % after-code
\titleformat
{\chapter} % command
[display] % shape
{\normalfont\huge\bfseries} % format
{\chaptertitlename\ \thechapter} % label
{20pt} % sep
{\Huge}[\vspace{2ex}\titlerule] % before-code
これは私が試した少なくとも12のバリエーションのうちの1つにすぎません(titlesec ドキュメントセクション 3.8 で説明した方法も含まれています{name=\chapter,numberless}
が、それを示すのは次のスクリーンショットだけです。
ご覧のとおり、「概要」の章の上、下、近くには水平線がありません。文書は今のところほとんど空です。序文が終わると、私が持っているのは
\begin{document}
\maketitle
\chapter*{Abstract}
Lorem Ipsum etc. etc.
\end{document}
MWE を提供できたことを願っています。最も基本的な例でも結果が得られないのは、何が間違っているのか教えてください。
答え1
番号付き章の形式を定義し、 に番号なし章を使用していますAbstract
。 この場合、ルールを取得するには、番号なし章の形式も定義する必要があります。
\documentclass[11pt,oneside]{book}
\usepackage{titlesec}
% Below "\section" can be replaced with "\subsection" and "\subsubsection"
% in order to customize the corresponding headings. "bch" - Bitstream
% Charter, "b" - bold.
\titleformat{\section}[hang]
{\usefont{T1}{bch}{b}{n}\selectfont}
{} % label
{0em} % horizontal separation between label and title body
{\hspace{-0.4pt}\Large \thesection\hspace{0.6em}} % before-code
[] % after-code
\titleformat
{\chapter} % command
[display] % shape
{\normalfont\huge\bfseries} % format
{\chaptertitlename\ \thechapter} % label
{20pt} % sep
{\Huge}[\vspace{2ex}\titlerule] % before-code
\titleformat
{name=\chapter,numberless} % command
[display] % shape
{\normalfont\huge\bfseries} % format
{} % label
{0pt} % sep
{\Huge}[\vspace{2ex}\titlerule] % before-code %% adjust 2ex here as you want.
\begin{document}
%\maketitle
\chapter*{Abstract}
Lorem Ipsum etc. etc.
\end{document}
間隔を調整していません。\titlespacing*
デフォルトを使用して調整してください。
\titlespacing*{\chapter} {0pt}{50pt}{40pt}
番号が付いていない章についても同様に行ってください。
\titlespacing*{name=\chapter,numberless} {0pt}{50pt}{40pt}