
我正在使用回憶錄作為單方面的文檔,但我想在標題中包含章節號和名稱。
我正在用它來實現它(來自使用回憶錄在標題中包含章節名稱和章節名稱)
\pagestyle{ruled}
\makeoddhead{ruled}{\sffamily\leftmark}{}{\sffamily\rightmark}
這在大多數情況下都很有效,但是對於目錄和參考書目,兩者都有兩頁長,我在標題中出現了兩次相同的標籤,這看起來很糟糕。
我只想顯示\rightmark
是否與 不同\leftmark
。或以某種方式改變這兩件事的標籤。例如,它在介紹中工作正常,這是一個\unnumberedchapter
並且沒有\section
.我嘗試過更改\bibsection
,\unnumberedchapter
但沒有幫助。
謝謝。
答案1
我開始認為對於任何問題,總有一個受egreg啟發的答案(測試兩個完全擴展的字串是否相等):
\documentclass[oneside]{memoir}
\usepackage{pdftexcmds} % https://tex.stackexchange.com/questions/59565/on-testing-two-fully-expanded-character-strings-for-equality
\makeatletter
\newcommand*{\test}[2]{%
\ifnum\pdf@strcmp{#1}{#2}=\z@ \relax \else #2 \fi
}
\makeatother
\pagestyle{ruled}
\makeoddhead{ruled}{\sffamily\leftmark}{}{\sffamily\test{\leftmark}{\rightmark}}
\usepackage{lipsum}
\newcommand{\makechapter}{
\chapter{foo}
\section{foobar}
\lipsum[1-12]
}
\begin{document}
\tableofcontents
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\makechapter
\end{document}