"Chapter 1" 또는 섹션 번호 없이 fancyhdr을 사용하여 머리글에서 교대로 장 및 섹션 제목을 얻는 방법

"Chapter 1" 또는 섹션 번호 없이 fancyhdr을 사용하여 머리글에서 교대로 장 및 섹션 제목을 얻는 방법

중복된 것처럼 보일 수도 있지만 그렇지 않은 것 같습니다. 내가 원하는 것은 "1장"이나 섹션 번호가 앞에 오지 않고 이탤릭체로 교체되는 페이지의 헤더에 있는 장과 섹션 제목입니다. 나는 거기까지 거의 도달했지만 짝수 페이지의 헤더에서 장 제목이 완전히 사라지지 않고 홀수 페이지의 섹션 제목(섹션 번호 없이)을 얻을 수 없습니다.

"1장"과 "1.1"을 각각 제거하기 위해 사용하는 명령은 다음과 같습니다.

\renewcommand{\chaptermark}[1]{\markboth{#1}{}}

\renewcommand{\sectionmark}[1]{\markboth{#1}{}}

MWE는 다음과 같습니다.

\documentclass[12pt, twoside]{report}

\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} %clears header
\fancyhead[CE]{\nouppercase{\textit{\leftmark}}} %puts chapter title on even page in lower-case italics
\fancyhead[CO]{\nouppercase{\textit{\rightmark}}} %puts section title on odd page in lower-case italics
\renewcommand{\headrulewidth}{0pt} %gets rid of line
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} %gets rid of chapter number
\renewcommand{\sectionmark}[1]{\markboth{#1}{}} %gets rid of section number

\begin{document}

\chapter{Off we go}

\section{Introduction}

\lipsum[1-7]

\section{Key Point}

\lipsum[7-10]


\end{document}

나는 그것이 \markboth 비트와 관련이 있다고 생각하지만 그것을 알 수 없습니다! 감사해요!

답변1

당신은 사용해야합니다

\renewcommand{\sectionmark}[1]{\markright{#1}}

예:

\documentclass[12pt, twoside]{report}
\usepackage{lipsum}

\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{} %clears header
\fancyhead[CE]{\nouppercase{\textit{\leftmark}}} %puts chapter title on even page in lower-case italics
\fancyhead[CO]{\nouppercase{\textit{\rightmark}}} %puts section title on odd page in lower-case italics
\renewcommand{\headrulewidth}{0pt} %gets rid of line
\renewcommand{\chaptermark}[1]{\markboth{#1}{}} %gets rid of chapter number
\renewcommand{\sectionmark}[1]{\markright{#1}} %gets rid of section number

\begin{document}
\chapter{Off we go}
\section{Introduction}
\lipsum[1-7]
\section{Key Point}
\lipsum[7-10]
\end{document}

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

관련 정보