
모든 사람,
저는 이 특정 유형의 헤더를 사용하고 있습니다. 귀찮은 'Chapter #.'라는 표현을 추가한 것 빼고는 마음에 듭니다. 내 논문의 서문과 감사의 글에 '제0장'이라고 적혀 있기 때문에 그런 표현을 원하지 않습니다. 그리고 결론에는 '제3장'이라고 되어 있지만, 그 섹션은 실제로는 장이 아닙니다. 그것을 극복하는 방법에 대한 아이디어가 있습니까?
\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{fancyhdr}
\pagestyle{fancy}
\makeatletter
\DeclareRobustCommand{\format@sec@number}[2]{{\normalfont\upshape#1}#2}
\renewcommand{\chaptermark}[1]{%
\markboth{\format@sec@number{\ifnum\c@secnumdepth>\m@ne\@chapapp\ \thechapter. \fi}{#1}}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\format@sec@number{\ifnum\c@secnumdepth>\z@\thesection. \fi}{#1}}}
\makeatother
\fancyhf{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
%\renewcommand{\headrulewidth}{1pt}
\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}
감사해요!
답변1
titleps
다음은 titlesec과 함께 제공되는 패키지인 를 사용한 훨씬 간단한 코드입니다 .
\documentclass{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{titleps}
\newpagestyle{custom}{%
\headrule\setheadrule{1pt}
\sethead[\thepage][][\thechapter.~\itshape\chaptertitle]{\thesection~\itshape\sectiontitle}{}{\thepage}%
\setfoot{}{}{}
}
\pagestyle{custom}
\begin{document}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}
답변2
페이지 스타일 멋진 헤더 정의는 언급한 것처럼 그렇게 복잡할 필요는 없습니다(특정 목적이 있을 때까지).
귀하의 요구 사항을 충족하는 멋진 헤더에 대한 간단한 정의는 다음과 같습니다.
\documentclass[12pt, letterpaper, twoside, openright]{book}
\usepackage[english]{babel}
\usepackage{blindtext}
\usepackage[T1]{fontenc}
\usepackage{amsmath}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancypagestyle{FancyStyle}{
\fancyhead{}
\fancyhead[RE]{\itshape\nouppercase{\leftmark}}
\fancyhead[LO]{\itshape\nouppercase{\rightmark}}
\fancyhead[LE,RO]{\thepage}
\renewcommand{\chaptermark}[1]{\markboth{\MakeUppercase{\thechapter. {##1}}}{}}
}
\begin{document}
\pagestyle{FancyStyle}
\chapter{Introduction}
\blindtext
\blindtext
\blindtext
\section{subsection}
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\blindtext
\end{document}