沃纳的建议

沃纳的建议

当我重新定义命令 \cleardoublepage 以包含字样“此页面已故意留空”时,章节标题未对齐。

\documentclass{book}
\usepackage[a4paper, top=14mm, bottom=10mm, inner=15mm, outer=13mm, bindingoffset=10mm, includefoot, includehead, headsep=14mm, footskip=14mm]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter.}{1em}{} 

\newcommand*{\blankpage}{%
\vspace*{\fill}
\centering [This page is intentionally left blank]
\vspace{\fill}}
\makeatletter
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\blankpage
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\makeatletter

\begin{document}
\chapter{First chapter title.}
\chapter{Misaligned chapter title illustrating the bug I'm experiencing.}
\end{document}

在此处输入图片描述

答案1

这结合了沃纳的评论和伊恩汤普森的回答的修改版本。

沃纳的建议

沃纳的建议解决了问题中提到的问题,但又暴露了另一个问题:

\documentclass{book}
\usepackage[a4paper, top=14mm, bottom=10mm, inner=15mm, outer=13mm, bindingoffset=10mm, includefoot, includehead, headsep=14mm, footskip=14mm]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries\raggedright}{\chaptertitlename\ \thechapter.}{1em}{}

\newcommand{\blankpage}{%
  \vspace*{\fill}%
  \centering [This page is intentionally left blank]
  \vspace{\fill}}
\makeatletter
  \renewcommand*{\cleardoublepage}{%
    \clearpage%
      \if@twoside
        \ifodd
          \c@page
        \else
          \blankpage\thispagestyle{empty}\newpage
            \if@twocolumn
              \hbox{}\newpage
            \fi
        \fi
      \fi}
\makeatother

\begin{document}
\chapter{First chapter title.}
\chapter{Misaligned chapter title illustrating the bug I'm experiencing.}

Some text.
\end{document}

进一步的问题

将以下文本置于中心可能不是这里的本意,因此是有问题的。

伊恩·汤普森的回答

Ian Thompson 的解决方案解决了这个问题,但又产生了第三个问题:

\documentclass{book}
\usepackage[a4paper, top=14mm, bottom=10mm, inner=15mm, outer=13mm, bindingoffset=10mm, includefoot, includehead, headsep=14mm, footskip=14mm]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries\raggedright}{\chaptertitlename\ \thechapter.}{1em}{}

\newcommand{\blankpage}{%
  \vspace*{\fill}%
  {\centering [This page is intentionally left blank]} % <--- Braces added here
  \vspace{\fill}}
\makeatletter
  \renewcommand*{\cleardoublepage}{%
    \clearpage%
      \if@twoside
        \ifodd
          \c@page
        \else
          \blankpage\thispagestyle{empty}\newpage
            \if@twocolumn
              \hbox{}\newpage
            \fi
        \fi
      \fi}
\makeatother

\begin{document}
\chapter{First chapter title.}
\chapter{Misaligned chapter title illustrating the bug I'm experiencing.}

Some text.
\end{document}

解决一个问题,又产生另一个问题

发生这种情况是因为\centering仅当段落结束时才有效,而分组会阻止段落结束,所以代码实际上从未有效。

最终代码

\documentclass{book}
\usepackage[a4paper, top=14mm, bottom=10mm, inner=15mm, outer=13mm, bindingoffset=10mm, includefoot, includehead, headsep=14mm, footskip=14mm]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries\raggedright}{\chaptertitlename\ \thechapter.}{1em}{}

\newcommand{\blankpage}{%
  \vspace*{\fill}%
  {\centering [This page is intentionally left blank]\par}%
  \vspace{\fill}}
\makeatletter
  \renewcommand*{\cleardoublepage}{%
    \clearpage%
      \if@twoside
        \ifodd
          \c@page
        \else
          \blankpage\thispagestyle{empty}\newpage
            \if@twocolumn
              \hbox{}\newpage
            \fi
        \fi
      \fi}
\makeatother

\begin{document}
\chapter{First chapter title.}
\chapter{Misaligned chapter title illustrating the bug I'm experiencing.}

Some text.
\end{document}

最终代码

答案2

我不知道为什么,但加入\centering一个小组可以解决问题。

\documentclass{book}
\usepackage[a4paper, top=14mm, bottom=10mm, inner=15mm, outer=13mm, bindingoffset=10mm, includefoot, includehead, headsep=14mm, footskip=14mm]{geometry}
\usepackage{titlesec}
\titleformat{\chapter}[hang]{\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter.}{1em}{}
\newcommand*{\blankpage}{%                                       
\vspace*{\fill}
{\centering [This page is intentionally left blank]} % <--- Braces added here
\vspace{\fill}}
\makeatletter
\renewcommand*{\cleardoublepage}{\clearpage\if@twoside \ifodd\c@page\else
\blankpage
\thispagestyle{empty}
\newpage
\if@twocolumn\hbox{}\newpage\fi\fi\fi}
\makeatother
\makeatletter    
\begin{document}
\show\chapter
\chapter{First chapter title.}
\chapter{Misaligned chapter title illustrating the bug I'm experiencing.}
\end{document}

相关内容