私の MWE は次のとおりです:
\documentclass[twoside]{book}
\usepackage[a4paper,width=150mm,top=25mm,bottom=25mm,headheight=28pt,bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\usepackage{fancyhdr}
\titleformat{\chapter}[display]
{\normalfont\bfseries}{}{10pt}{\Huge}
\newpagestyle{mystyle}{
\sethead[][][\chaptertitle]{\thesection~\sectiontitle}{}{\thepage}}
\begin{document}
\pagestyle{mystyle}
\chapter{A chapter}
\lipsum[1-40]
\end{document}
これにより、章のタイトルから「章」という単語が削除されます。ただし、章の数も含める必要があります。たとえば、「1. はじめに」などです。titlesec を使用してこれを行うにはどうすればよいでしょうか?
答え1
display
章のラベルを章のタイトルと同じ行に表示したい場合は、 スタイルを使用しないでください。を中央揃えにしたい場合は、デフォルトのhang
スタイル、または を使用してください。は必須ではないことに注意してください。これは クラスのデフォルトです。 また、 をオプションとともに使用したい場合はをロードしないでください。は をロードし、 と競合する可能性があります。block
twoside
book
fancyhdr
titlesec
pagestyles
titleps
fancyhdr
コードは次のとおりです:
\documentclass{book}
\usepackage[a4paper, width=150mm, vmargin=25mm, headheight=28pt, bindingoffset=6mm]{geometry}
\usepackage[pagestyles]{titlesec}
\usepackage{lipsum}
\titleformat{\chapter}%
{\normalfont\bfseries\Huge}{\thechapter.}{10pt}{}
\newpagestyle{mystyle}{
\sethead[][\thechapter.\enspace\chaptertitle][]{}{\thesection~\sectiontitle}{}
\setfoot{}{\thepage}{}}
\begin{document}
\pagestyle{mystyle}
\chapter{A Chapter}
\lipsum[1-5]
\section{A First Section}
\lipsum[6-20]
\end{document}