Fix #2622: Latex produces empty pages after title and table of contents

The 'openany' option was not correctly obeyed.
This commit is contained in:
jfbu
2016-06-06 11:04:59 +02:00
parent 20a7f3b0ca
commit 78589b05ab

View File

@@ -77,7 +77,8 @@
\end{flushright}%\par \end{flushright}%\par
\@thanks \@thanks
\end{titlepage}% \end{titlepage}%
\cleardoublepage% % avoid extra blank page after title if openany option
\if@openright\cleardoublepage\else\clearpage\fi
\setcounter{footnote}{0}% \setcounter{footnote}{0}%
\let\thanks\relax\let\maketitle\relax \let\thanks\relax\let\maketitle\relax
%\gdef\@thanks{}\gdef\@author{}\gdef\@title{} %\gdef\@thanks{}\gdef\@author{}\gdef\@title{}
@@ -86,38 +87,54 @@
% Catch the end of the {abstract} environment, but here make sure the abstract % Catch the end of the {abstract} environment, but here make sure the abstract
% is followed by a blank page if the 'openright' option is used. % is followed by a blank page if the 'openright' option is used.
%
% Note added (Sphinx 1.4.4): the earlier code was wrong and in fact not really
% needed as after an abstract there might be table of contents, part, or chapter
% which all do the right \cleardoublepage if openright option. Besides, there
% does not seem to be Sphinx interface for user to abstract.
\if@openright
\let\py@OldEndAbstract=\endabstract \let\py@OldEndAbstract=\endabstract
\renewcommand{\endabstract}{ \renewcommand{\endabstract}{%
\if@openright
\ifodd\value{page}
\typeout{Adding blank page after the abstract.}
\vfil\pagebreak
\fi
\fi
\py@OldEndAbstract \py@OldEndAbstract
% mimic \clearpage/\cleardoublepage with added message to log
\clearpage
% LaTeX's standard is that openright has any effect only under twoside
\if@twoside
\ifodd\c@page\else
\typeout{Adding blank page after the abstract}%
\hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi
\fi
\fi
} }
\fi
% This wraps the \tableofcontents macro with all the magic to get the spacing % This wraps the \tableofcontents macro with all the magic to get the spacing
% right and have the right number of pages if the 'openright' option has been % right and have the right number of pages if the 'openright' option has been
% used. This eliminates a fair amount of crud in the individual document files. % used. This eliminates a fair amount of crud in the individual document files.
%
% Note added (Sphinx 1.4.4): code was wrong in case of openany option. Further:
% after table of contents there will be part or chapter which by default already
% do the right thing. Blank page code is thus here only for the extra message
% in log.
\let\py@OldTableofcontents=\tableofcontents \let\py@OldTableofcontents=\tableofcontents
\renewcommand{\tableofcontents}{% \renewcommand{\tableofcontents}{%
% before resetting page counter, let's do the right thing.
\if@openright\cleardoublepage\else\clearpage\fi
\pagenumbering{roman}% \pagenumbering{roman}%
\setcounter{page}{1}% \setcounter{page}{1}%
\pagebreak%
\pagestyle{plain}% \pagestyle{plain}%
{% {%
\parskip = 0mm% \parskip \z@skip
\py@OldTableofcontents% \py@OldTableofcontents
\if@openright% % mimic \clearpage/\cleardoublepage with added message to log
\ifodd\value{page}% \clearpage
\typeout{Adding blank page after the table of contents.}% % LaTeX's standard is that openright has any effect only under twoside
\pagebreak\hspace{0pt}% \if@openright\if@twoside
\fi% \ifodd\c@page\else
\fi% \typeout{Adding blank page after the table of contents}%
\cleardoublepage% \hbox{}\newpage\if@twocolumn\hbox{}\newpage\fi
\fi
\fi\fi
}% }%
\pagenumbering{arabic}% \pagenumbering{arabic}%
\@ifundefined{fancyhf}{}{\pagestyle{normal}}% \@ifundefined{fancyhf}{}{\pagestyle{normal}}%