
내 문제를 설명하기 위해 MWE부터 시작하겠습니다.
\documentclass[a4paper,10pt]{book}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{extramarks}
\makeatletter
\renewcommand\chapter{\@startsection%
{chapter}{0}{0mm}%
{2.5\baselineskip}{1.5\baselineskip}%
{\centering\normalfont\large\scshape
}%
}
\makeatother
\newcommand{\mychap}[1]{
\chapter*{#1}
\markboth{#1}{#1}}
\renewcommand{\sectionmark}{}
\renewcommand{\chaptermark}{\markboth{\thechapter}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead{}
\fancyhead[LE]{{\thepage}}
\fancyhead[RE]{ {\itshape \nouppercase \firstleftmark}}%higher level \scshape \MakeUppercase
\fancyhead[LO]{ {\itshape \nouppercase \lastrightmark}}
\fancyhead[RO]{ {\thepage}} %odd page
\begin{document}
\mychap{one}
\lipsum
\mychap{two}
aaa
\mychap{five halves}
\mychap{three}
\lipsum
\mychap{fourth}
\lipsum[5]
\mychap{five}
d
\end{document}
그것을주의해라:
- 장을 섹션으로 처리하고 싶습니다(페이지 구분 없음, 간단한 제목).
- 헤더에 장의 이름을 원합니다
이런 기능을 얻을 수 있었어요
하지만
나도 받고 싶다
- 헤더에는이상한내가 원하는 페이지마지막페이지에 나타나는 챕터( 를 사용하면 작동하는 것 같습니다
\lastrightmark
) - 헤더에는심지어내가 원하지 않는 페이지첫 번째장은 페이지에서 시작하지만,현재의장, 즉 내가 페이지를 넘기면서 읽고 있는 장입니다.
내 예에서는
- 2페이지에서는 2장이 1페이지와 2페이지 사이의 페이지 나누기 이후에 시작되므로 "1"을 갖고 싶습니다.
- 4페이지에서는 5장이 3페이지와 4페이지 사이의 페이지 나누기 이후에 시작되므로 "4"를 갖고 싶습니다.
이것을 어떻게 얻을 수 있나요?
답변1
\extramarks
다음과 같이 헤더를 설정하고 사용하여 이러한 헤더를 얻을 수 있습니다 .
\newcommand{\mychap}[1]{%
\chapter*{#1}%
\markboth{#1}{#1}%
\extramarks{#1}{#1}}
\fancyhead[RE]{\textit{\MakeLowercase{\firstxmark}}}
\fancyhead[LO]{\textit{\MakeLowercase{\lastxmark}}}
따라서 귀하의 샘플과 같은 문서에서는 one' in the heading page 2 and
귀하가 요청한 대로 4페이지 제목에 4`가 표시됩니다.
\documentclass[a4paper,10pt]{book}
\usepackage{lipsum}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{extramarks}
\makeatletter
\renewcommand\chapter{\@startsection%
{chapter}{0}{0mm}%
{2.5\baselineskip}{1.5\baselineskip}%
{\centering\normalfont\large\scshape
}%
}
\makeatother
\newcommand{\mychap}[1]{%
\chapter*{#1}%
\markboth{#1}{#1}%
\extramarks{#1}{#1}}
\pagestyle{fancy}
\fancyhf{}
\fancyhead{}
\fancyhead[LE]{\thepage}
\fancyhead[RE]{\textit{\MakeLowercase{\firstxmark}}}
\fancyhead[LO]{\textit{\MakeLowercase{\lastxmark}}}
\fancyhead[RO]{\thepage}
\begin{document}
\mychap{One}
\lipsum
\mychap{Two}
Two words.
\mychap{Two and a half}
\mychap{Three}
\lipsum
\mychap{Four}
\lipsum[5]
\mychap{Five}
A sentence of five words.
\end{document}
둘 다 참고하세요\markboth
그리고 \extramarks
올바른 값을 가져와야 합니다( 의 "버그"에 의존할 수 있음 extramarks
). 또한 \MakeLowercase
이제 더 이상 표준 표시를 사용하지 않으므로 제목 텍스트를 원하는 형식으로 강제 적용하는 데 사용했습니다 .