
논문의 최종 초안 형식을 지정하고 있는데 머리글에 나타나는 장 및 섹션 제목에 문제가 있음을 발견했습니다.
현재 나는 fancyhdr을 사용하여 헤더의 대체 페이지에 장과 섹션 제목을 가져오고 있습니다. 별도의 이유 때문에 나는 서론 장과 결론 장에 번호를 매기는 것을 원하지 않으며, 각 장의 결론 부분에 번호를 매기는 것을 원하지 않습니다. 이를 달성하기 위해 \chapter* 및 \section* 명령을 사용했습니다. 그러나 이로 인해 일부 헤더에 나타나는 장/섹션 제목과 관련하여 세 가지 원치 않는 결과가 발생했습니다.
- '목차'는 소개 헤더의 장 제목으로 나타납니다.
하지만 저는 '소개'라고 말하고 싶습니다.
- 이전 섹션 이름은 해당 장의 마지막 섹션 헤더에 섹션 제목으로 표시됩니다.
하지만 저는 '결론'이라고 말하고 싶습니다.
- 이전 장 제목은 결론 장의 머리글에 장 제목으로 표시됩니다.
다시 한번 '결론'이라고 말씀드리고 싶습니다.
MWE는 다음과 같습니다.
\documentclass[12pt, twoside]{report}
\usepackage[explicit]{titlesec} %adjust titles
\usepackage{lipsum} %random text
%%%%%%%%Chapter and section titles in headers
\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
%%%%%%%%%
\titleformat{\chapter}[display]{\LARGE\bfseries\centering}{\thechapter}{10pt}{#1}
\titleformat{\section}{\normalfont\fontsize{20}{20}\centering}{\thesection}{1em}{\MakeUppercase{#1}}
\titleformat{\subsection}{\normalfont\centering}{\thesubsection}{1em}{\textit{{#1}}}
\usepackage{subfiles} %allows multi-file projects
\setcounter{tocdepth}{1} %removes subsubsections from toc
%%%%%%%%%removes dots from toc
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
%%%%%%%%%
\begin{document}
\tableofcontents
\chapter*{Introduction}
\addcontentsline{toc}{chapter}{Introduction}
\renewcommand{\thesection}{\arabic{section}}
\section{An Introductory Section}
\lipsum
\lipsum[1]
\section{Another Introductory Section}
\lipsum
\chapter{A Chapter}
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\lipsum[2-3]
\section{A Section}
\lipsum[4-8]
\section*{Conclusion}
\lipsum[8-9]
\chapter{Another Chapter}
\renewcommand{\thesection}{\thechapter.\arabic{section}}
\lipsum[1-2]
\chapter*{Conclusion}
\addcontentsline{toc}{chapter}{Conclusion}
\lipsum
\end{document}
비슷한 질문이 제기된 것으로 알고 있습니다(예:목차 및 제목에 번호가 없는 장) 그러나 KOMA-Script에 관한 것 같습니다. 이것이 최종 초안이라는 점을 감안할 때, fancyhdr을 사용하여 많은 것을 변경하지 않고도 이 작업을 수행할 수 있다면 이상적일 것입니다. 감사해요!
답변1
나는 명령을 정의하는 pagestyles
옵션 과 번호가 없는 섹션에 대해 ( 및titlesec
\chaptermark
\pretitlemark
\titleformat
~ 전에 \section*
) :
\documentclass[12pt, twoside]{report}
\usepackage[explicit, pagestyles]{titlesec} %adjust titles
\usepackage{lipsum} %random text
\titleformat{\chapter}[display]{\LARGE\bfseries\filcenter}{\thechapter}{10pt}{#1}
\titleformat{name=\chapter, numberless}[display]{\LARGE\bfseries\filcenter}{}{10pt}{\chaptermark{#1}\addcontentsline{toc}{chapter}{#1}#1}
\titleformat{\section}{\normalfont\fontsize{20}{20}\filcenter}{\thesection}{1em}{\MakeUppercase{#1}}
\titleformat{name=\section, numberless}{\normalfont\fontsize{20}{20}\filcenter}{}{0em}{\pretitlemark{section}{#1}\MakeUppercase{#1}}
\renewcommand{\thesection}{\ifthechapter{\thechapter.}{}\arabic{section}}
\titleformat{\subsection}{\normalfont\filcenter}{\thesubsection}{1em}{\textit{{#1}}}
\newpagestyle{myps}{%
\sethead[][\itshape\chaptertitle][]{}{\itshape\sectiontitle}{}
\setfoot{}{\thepage}{}
}
%%%%%%%%%Chapter and section titles in headers
\pagestyle{myps}
\usepackage{subfiles} %allows multi-file projects
\setcounter{tocdepth}{1} %removes subsubsections from toc
%%%%%%%%%removes dots from toc
\makeatletter
\renewcommand{\@dotsep}{10000}
\makeatother
%%%%%%%%%
\begin{document}
\tableofcontents
\chapter*{Introduction}
\section{An Introductory Section}
\lipsum
\lipsum[1]
\section{Another Introductory Section}
\lipsum
\chapter{A Chapter}
\lipsum[2-5]
\section{A Section}
\lipsum[6-8]
\pretitlemark{section}{Conclusion}
\section*{Conclusion}
\lipsum[9-15]
\chapter{Another Chapter}
\lipsum[13-16]
\chapter*{Conclusion}
\lipsum[17-20]
\end{document}