다음과 같은 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}