当 \setsecnumdepth{none} 时,zref 变量在页眉/页脚中缓存不正确

当 \setsecnumdepth{none} 时,zref 变量在页眉/页脚中缓存不正确

接着这个问题:

如何访问页脚中使用的每页变量/命令

我正在使用该zref包在页脚中提供自定义的每章变量(即每章更改的“审阅日期:”日期)。

下面,我包含了一个按预期工作的 MWE。如果我尝试使用 删除章节编号\setsecnumdepth{none},页脚将不再按预期工作 - 所有章节的“审阅日期”日期都将设置为 中最后出现的设置日期的调用\lastreviewedon{...}

显然有些缓存正在发生,我不明白。如果能帮助我实现我的两个目标(不设章节编号,以及每章自定义页脚变量),我将不胜感激!

\documentclass[9pt]{memoir}

\usepackage[table]{xcolor}
\definecolor{accentcolor}{HTML}{D33900}
\definecolor{rememberbodycolor}{HTML}{000000}
\definecolor{fadedgreycolor}{HTML}{888888}
\definecolor{shadecolor}{HTML}{F9E3DC}
\definecolor{textcolor}{HTML}{000000}
\usepackage{lipsum}
\usepackage{hyperref}
\usepackage{zref}

\setsecnumdepth{chapter}
\openany
\checkandfixthelayout

% Chapter styles.
\copypagestyle{chapter}{plain}
\setlength{\beforechapskip}{0pt}
\setlength{\afterchapskip}{10pt}
\renewcommand*{\chaptitlefont}{\normalfont\Huge\bfseries\color{accentcolor}}
\makeevenfoot{chapter}{\color{fadedgreycolor}\thepage{} \reviewedblurb{}}{}{}
\makeoddfoot{chapter}{}{}{\color{fadedgreycolor}\thepage{} \reviewedblurb{}}

% Common styles.
\copypagestyle{mystyle}{headings}
\makeevenhead{mystyle}{\color{fadedgreycolor}\leftmark}{}{}
\makeoddhead{mystyle}{}{}{\color{fadedgreycolor}\leftmark}
\makeevenfoot{mystyle}{\color{fadedgreycolor}\thepage}{}{}
\makeoddfoot{mystyle}{}{}{\color{fadedgreycolor}\thepage}
\nouppercaseheads
\makerunningwidth{mystyle}{\textwidth}
\makeheadrule{mystyle}{\textwidth}{\normalrulethickness}
\makeheadfootruleprefix{mystyle}{\color{fadedgreycolor}}{\color{fadedgreycolor}}
\pagestyle{mystyle}

% Last Reviewed Date macro for putting in the footer.
\makeatletter
\zref@newprop{lastrevieweddate}[??]{\@empty}
\newcommand{\reviewedblurb}{%
  \zref@ifrefundefined{last-review-date-\thechapter}{}
    {\zref@def@extractdefault{\@lastrevieweddate}{last-review-date-\thechapter}{lastrevieweddate}{\@empty}%
     \ifx\@lastrevieweddate\@empty\else
       --- Reviewed on: \zref@extract{last-review-date-\thechapter}{lastrevieweddate}%
     \fi}}
\newcommand{\lastreviewedon}[1]{\zref@setcurrent{lastrevieweddate}{#1}}
\let\oldchapter\chapter
\renewcommand{\chapter}{%
  \ifnum\value{chapter}<1\else% Nothing to do before the first chapter
    \zref@labelbyprops{last-review-date-\thechapter}{lastrevieweddate}%
    \zref@setcurrent{lastrevieweddate}{}% Clear any review date references for the next chapter
  \fi
  \oldchapter% Resume old \chapter sequence
}
\AtEndDocument{\zref@labelbyprops{last-review-date-\thechapter}{lastrevieweddate}}%
\makeatother

\begin{document}


\chapter{First Chapter}
\lastreviewedon{November 13, 2015}

\lipsum

\chapter{Second Chapter}
\lastreviewedon{September 20, 2015}

\lipsum

\chapter{Third Chapter}
\lastreviewedon{April 1, 2014}

\lipsum

\end{document}

答案1

我已经得到了我想要的 99% - 我仍然在目录中对章节进行了编号(我宁愿没有),但我能够删除章节标题中的编号,同时仍然允许章节计数器增加。

\titleformat{\chapter}{\normalfont\Huge\bfseries}{}{0em}{}

使用该titlesec包将删除章节编号,如果我保留\setsecnumdepth{chapter}参考zref文献则可按预期工作。

相关内容