
바닥글에 번호를 매기는 동안 머리글에 섹션/하위 섹션 제목과 번호를 어떻게 넣을 수 있나요?
\pagestyle{...}
이 조합은 허용되지 않습니다.
답변1
다음은 몇 가지 문제를 해결하는 방법입니다(별표 표시된 섹션과 하위 섹션을 헤더에 추가하거나 수정된 경우 TOC에도 추가하는 것과 같은).
\documentclass[twoside]{article}
\usepackage{lipsum}
\usepackage{fancyhdr}
%\fancyhead[CO,CE]{}
\fancyhead[LO,RE]{\scshape\leftmark}
\fancyhead[RO,LE]{\itshape\rightmark}
\let\oldsection\section
\let\oldsubsection\subsection
\makeatletter
\def\section{%
\@ifstar{\@Starred}{\@nonStarred}%
}
\def\@Starred{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to ignore them!}\@StarredWith}%
{\@StarredWithout}%
}
\def\@StarredWith[#1]#2{%
\oldsection*{#2}%
\renewcommand\leftmark{#1}%
}
\def\@StarredWithout#1{
\oldsection*{#1}%
\renewcommand\leftmark{#1}
}
\def\@nonStarred{%
\@ifnextchar[%
{\@nonStarredWith}%
{\@nonStarredWithout}%
}
\def\@nonStarredWith[#1]#2{%
\oldsection[#1]{#2}%
\renewcommand\leftmark{\thesection~#1}%
}
\def\@nonStarredWithout#1{%
\oldsection{#1}%
\renewcommand\leftmark{\thesection~#1}%
}
\def\subsection{%
\@ifstar{\@StarredS}{\@nonStarredS}%
}
\def\@StarredS{%
\@ifnextchar[%
{\GenericWarning{}{Warning: A starred section can not have parameters. I am going to use them for the hearder}\@StarredSWith}%
{\@StarredSWithout}%
}
\def\@StarredSWith[#1]#2{%
\oldsubsection*{#2}%
\renewcommand\rightmark{#1}%
}
\def\@StarredSWithout#1{
\oldsubsection*{#1}%
\renewcommand\rightmark{#1}
}
\def\@nonStarredS{%
\@ifnextchar[%
{\@nonStarredSWith}%
{\@nonStarredSWithout}%
}
\def\@nonStarredSWith[#1]#2{%
\oldsubsection[#1]{#2}%
\renewcommand\rightmark{\thesubsection~#1}%
}
\def\@nonStarredSWithout#1{%
\oldsubsection{#1}%
\renewcommand\rightmark{\thesubsection~#1}%
}
\makeatother
\pagestyle{fancy}
\title{Test redefined sections}
\author{Kostis Leledakis}
\begin{document}
\maketitle
\tableofcontents
\clearpage
\section{A section}
\lipsum[1-8]
\subsection{A subsection}
\lipsum[1-6]
\subsection*{A starred subsection}
\lipsum[1-8]
\subsection{Another numbered subsection}
\lipsum[1-6]
\subsection*{Another starred subsection}
\lipsum[1-8]
\subsection[Short title of subection \thesubsection]{Another numbered subsection with short title}
\lipsum[1-6]
\section{Another section}
\lipsum[1-6]
\section*{A starred section}
\lipsum[1-8]
\subsection{A subsection}
\lipsum[1-6]
\subsection*{A starred subsection}
\lipsum[1-8]
\subsection{Another numbered subsection}
\lipsum[1-6]
\subsection*{Another starred subsection}
\lipsum[1-8]
\subsection[Short title of subection \thesubsection]{Another numbered subsection with short title}
\lipsum[1-6]
\section{Another numbered section}
\lipsum[1-6]
\section*{Another starred section}
\lipsum[1-8]
\section[Short title of section \thesection]{Another numbered section with short title}
\lipsum[1-6]
\section*[Short title of starred section]{Another starred section with short title}
\lipsum[1-8]
\end{document}
추신: 그렇습니다이것답변이 수정되었습니다.