
내 라텍스 문서의 현재 코드는 다음과 같습니다.
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\nouppercase{\textit \leftmark}}
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\thispagestyle{plain}
\newpage
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
"1장"을 제거하고 싶습니다. 내 헤더 "Chapter 1. One"의 키워드를 사용하고 싶습니다. "1-One"입니다. 어떻게 하나요?
답변1
\chaptermark
다음과 같이 재정의할 수 있습니다 .
\renewcommand\chaptermark[1]{\markboth{\thechapter\,--\,#1}{}}
완전한 예:
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage{fancyhdr}
\pagestyle{fancy}
\fancyhead{}
\fancyhead[C]{\nouppercase{\textit{\leftmark}}}
\renewcommand\chaptermark[1]{\markboth{\thechapter\,--\,#1}{}}
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\thispagestyle{plain}
\newpage
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
답변2
대안으로 다음을 fancyhdr
사용할 수 있습니다.scrlayer-scrpage
:
\documentclass[12pt,notitlepage]{report}
\usepackage{lipsum}
\usepackage[pagestyleset=KOMA-Script,headsepline,automark]{scrlayer-scrpage}
\setkomafont{pagehead}{\itshape}% use italic instead of slanted page header
\renewcommand*{\chaptermarkformat}{\thechapter--}% Use "1–" instead of "Chapter 1 " in the chapter mark
\begin{document}
\pagenumbering{roman}
\cleardoublepage
\addcontentsline{toc}{chapter}{Table of Contents}% Has to be at the begin of
% the first ToC page (before \tableofcontents)
\tableofcontents
\cleardoublepage% if twoside next odd page
\pagenumbering{arabic}
\chapter{One}
\lipsum[2-5]
\end{document}
\thispagestyle{plain}
참고: 이상한 명령 도 제거 하고 \addcontentsline
명령을 이동했습니다. 귀하의 예에서는 목차의 마지막 페이지를 목차에 추가하는데 이는 의미가 없습니다.
대안으로 패키지를 사용할 수 있습니다tocbibind
.
그러나 목차에 대한 항목을 목차에 추가하지 않는 것이 좋습니다. 대부분 이것은 의미가 없습니다.
답변3
간단한 가능성은 titleps
함께 제공되지만 titlesec
독립적으로 사용할 수 있는 로드하는 것입니다. 표시를 만지작거리지 마세요(원하지 않는 한...). 단지 \chaptertitle
, \sectiontitle
, &c.).
\documentclass[12pt,notitlepage]{report}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lipsum}
\usepackage{titleps}
\newpagestyle{mypagestyle}{%
\headrule
\sethead{}{\textit{\thechapter.\,–\,\chaptertitle}}{}
\setfoot{}{\thepage}{}
}%
\begin{document}
\pagenumbering{roman}
\thispagestyle{plain}
\tableofcontents
\addcontentsline{toc}{chapter}{Table of Contents}
\newpage
\pagestyle{mypagestyle}
\pagenumbering{arabic}
\chapter{One}
\lipsum
\end{document}