该titleps
样式不应用cleardoublepage
命令之前1.3节的最后一页样式(参见自定义\cleardoubletransition
命令)。
我认为该错误与之相关,titleps
因为如果您应用默认样式(例如headings
),则第 1.3 节的页面样式是正确的。
请注意,将\cleardoubletransition
命令放入环境中myenv
可以解决问题。
如何使titleps
页面样式与自定义环境保持强大功能,无论将其放在\cleardoubletransition
环境的末尾还是外部?
梅威瑟:
\documentclass[12pt, a4paper, twoside]{book}
\usepackage[pagestyles,toctitles]{titlesec}
\usepackage[strict]{changepage} % for \checkoddpage
\usepackage{lipsum}
% To clear double page and put transition
%
% USAGE
% \cleardoubletransition
%
\newcommand{\cleardoubletransition}%
{%
\checkoddpage%
\ifoddpage \clearpage\thispagestyle{empty}\cleardoublepage\else \cleardoublepage\fi%
}
\newpagestyle{numchapnumsec}{%
\sethead[
{\sffamily\normalsize\thechapter\quad\MakeUppercase{\chaptertitle}}
]
[]
[
{\sffamily\normalsize{\sectiontitle}\quad\thesection}
]
{%
{\sffamily\normalsize\thesection\quad{\sectiontitle}}
}
{}
{%
{\sffamily\normalsize\MakeUppercase{\chaptertitle}\quad\thechapter}
}
\setfoot*{}
{%
{\sffamily\thepage}
}
{}
}
\newenvironment{myenv}{%
\pagestyle{numchapnumsec} % It does not work properly
% \pagestyle{headings} % It works properly
}{}
\begin{document}
\begin{myenv}
\chapter{Chapter 1 title}
\section{First section first chapter}
\lipsum[1]
\clearpage
\section{All is ok here}
\lipsum[2]
\clearpage
\section{Bug can appear for this page!}
\lipsum[3]
% \cleardoubletransition % with numchapnumsec, use this instead of the next one and it works!
\end{myenv}
\cleardoubletransition % Comment it if you use the previous cleardoubletransition cmd.
\begin{myenv}
\chapter{Chapter 2 title}
\section{First section new chapter}
\lipsum[4]
\end{myenv}
\end{document}