장 수 번호를 표시하기 위해 \titleformat을 얻는 방법은 무엇입니까?

장 수 번호를 표시하기 위해 \titleformat을 얻는 방법은 무엇입니까?

다음과 같은 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사용하려는 경우 로드하지 마십시오 . 와 충돌할 수 있습니다 .titlesecpagestylestitlepsfancyhdr

코드는 다음과 같습니다.

\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} 

여기에 이미지 설명을 입력하세요

답변2

\thechapter.\quad제목 설정의 일부로 포함 :

여기에 이미지 설명을 입력하세요

\documentclass{book}

\usepackage{titlesec}

\titleformat{\chapter}[display]
  {\normalfont\bfseries}{}{10pt}{\Huge\thechapter.\quad}

\begin{document}

\chapter{A chapter}

\end{document}

관련 정보