목차 페이지의 헤더 사용자 정의

목차 페이지의 헤더 사용자 정의

여기에 이미지 설명을 입력하세요내 책 수업 문서에는 LE 및 RO 페이지에만 장 제목이 있으며 목차 페이지에도 동일한 내용을 원합니다. 을 사용하여 헤더를 완전히 제거 \makeatletter \let\@mkboth\relax \makeatother하고 추가하려고 시도했지만 \fancyhead[LE,RO]{\leftmark}그 결과 목차 제목 옆에 Contents라는 단어가 대문자로 표시되었습니다. MWE는 아래에 제공되며 내가 얻은 이미지가 추가됩니다.

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lipsum}% used to get dummy text
\begin{document}
\pagestyle{fancy}
\makeatletter
\let\@mkboth\relax
\makeatother
\tableofcontents%
\fancyhead[LE,RO]{\leftmark}
\cleardoublepage
\chapter{Chapter 1}
\section{Section 1.1}
\lipsum[1]% used to get dummy text
\cleardoublepage
\chapter{Chapter 2}
\section{Section 2.1}
\lipsum[2]% used to get dummy text
\chapter{Chapter 3}
\section{Section 3.1}
\lipsum[3]% used to get dummy text
\end{document}

솔루션에 대한 조언을 주시면 감사하겠습니다.

모든 장에서와 같이 첫 번째 페이지를 제외하고 목차 페이지에 필요한 헤더 종류는 아래 이미지와 같습니다.첫 번째 페이지를 제외하고 필요한 샘플 콘텐츠 페이지

답변1

편집하다댓글 후: 당신이 실제로 대답하고 싶은 질문이 무엇인지 드디어 이해한 것 같습니다.

나는 fancyhdr머리글에 장과 섹션 제목을 넣곤 했습니다. 그러나 목차 페이지의 경우 장 제목 "CONTENTS"가 헤더 양쪽에 즉, 섹션 제목으로 표시됩니다. 헤더 한쪽에서 어떻게 제거하나요?

대답은 간단합니다. \markright{}헤더의 "섹션 제목" 부분을 지우는 데 사용합니다. ( 목차의 첫 번째 페이지에서 \addtocontents{toc}장 제목 호출 바로 뒤에 있도록 ) 및 (목차의 첫 번째 "항목"에 있도록) 로 래핑하여 그렇게 할 수 있습니다 .\markboth\AtBeginDocument

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lipsum}% used to get dummy text
\AtBeginDocument{\addtocontents{toc}{\protect\markboth{\textsl{CONTENTS}}{}}} 
\begin{document}
\pagestyle{fancy}
\tableofcontents%
\cleardoublepage
\chapter{Chapter 1}
\section{Section 1.1}
\lipsum[1]% used to get dummy text
\cleardoublepage
\chapter{Chapter 2}
\section{Section 2.1}
\lipsum[2]% used to get dummy text
\chapter{Chapter 3}
\section{Section 3.1}
\lipsum[3]% used to get dummy text
\end{document}

2페이지의 헤더:여기에 이미지 설명을 입력하세요


이전 답변:

수동 개입 없이 목차의 다음 페이지에 있는 기본 헤더에는 왼쪽과 오른쪽 모두 대문자로 "CONTENTS"가 있습니다. 목차의 첫 번째 페이지에는 다른 모든 장의 시작 페이지와 마찬가지로 머리글이 없습니다.

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lipsum}% used to get dummy text
\begin{document}
\pagestyle{fancy}
\tableofcontents%
\cleardoublepage
\chapter{Chapter 1}
\section{Section 1.1}
\lipsum[1]% used to get dummy text
\cleardoublepage
\chapter{Chapter 2}
\section{Section 2.1}
\lipsum[2]% used to get dummy text
\chapter{Chapter 3}
\section{Section 3.1}
\lipsum[3]% used to get dummy text
\end{document}

2페이지의 헤더:여기에 이미지 설명을 입력하세요


목차 페이지의 헤더에 입력된 내용을 수정하려면 \markboth목차 캡션으로 이미 삽입된 내용을 덮어쓰는 호출을 호출해야 합니다. 호출하지 않기 위해 다른 명령이나 관련 명령을 해킹할 필요가 없습니다 \markboth. 이러한 매크로의 목적은 실제로 이미 존재하는 것을 덮어쓰는 것이기 때문입니다. 그러니 정말로 전화만 하면 돼요\markboth ~ 후에목차의 장 제목과~ 전에첫 번째 페이지 나누기, 즉 이상적으로는 장 제목 바로 뒤에 위치합니다.

에서 영감을 받다이 답변, 첫 번째 항목으로 TOC에 대한 호출을 추가합니다 \markboth(장 제목 바로 다음에 호출되도록). 첫 번째 항목인지 확인하려면 \AtBeginDocument서문에서 사용할 수 있습니다. 최소한의 예:

\documentclass[a4paper,11pt]{book}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage{fancyhdr}
\usepackage{lipsum}% used to get dummy text
\AtBeginDocument{\addtocontents{toc}{\protect\markboth{Contents}{\textnormal{More Contents}}}} 
\begin{document}
\pagestyle{fancy}
\tableofcontents%
\cleardoublepage
\chapter{Chapter 1}
\section{Section 1.1}
\lipsum[1]% used to get dummy text
\cleardoublepage
\chapter{Chapter 2}
\section{Section 2.1}
\lipsum[2]% used to get dummy text
\chapter{Chapter 3}
\section{Section 3.1}
\lipsum[3]% used to get dummy text
\end{document}

2페이지의 헤더:여기에 이미지 설명을 입력하세요

물론 이제 필요한 헤더에 대한 정확한 문구와 텍스트 서식 스타일을 갖기 위해 이를 수정하고 싶을 것입니다. 기본 스타일(적어도 이 최소 예에서는)은 기울임꼴 텍스트이므로 덮어써야 할 수도 있습니다.

관련 정보