Figures don't get centered when redefining title page

I'm using the tufte-book class. If I redefine the \maketitlepage command, the figures stop getting centered. Here's a MWE reproducing the issue:

\documentclass[justified, symmetric, titlepage]{tufte-book}
\usepackage{graphicx, lipsum}
\usepackage[english]{babel}

\makeatletter
\renewcommand{\maketitlepage}{
\thispagestyle{empty}
{\fontsize{15}{15}\scshape\@author\par}
\vspace{5cm}
{\fontsize{37}{37}\scshape\@title}
\newpage
\pagenumbering{arabic}}
\makeatother

\title{Title}
\author{Author}
\begin{document}
\maketitle

\lipsum[1-4]

\begin{figure}
\centering
\includegraphics[width=0.4\textwidth]{example-image-a}
\end{figure}

\lipsum[5]
\end{document}


And this is the (unwanted) result

• As you can see, the class becomes thoroughly confused and page 2 is considered as a right-hand page, but the figure is still considered to be on a left-hand page. – egreg Feb 25 at 23:51
• @egreg Is there a way to fix it? – noibe Feb 26 at 0:12

I suggest you write an bug report on the tufte web page please.

Please see the following a little bit changed code (important here I added option debug and I added some more text around the figure to be able to show the culprit with some more changings (uncommenting more text)):

\documentclass[%
justified,
symmetric,
titlepage,
debug       % <=======================================================
]{tufte-book}

\usepackage{graphicx, lipsum}
\usepackage[english]{babel}

\makeatletter
\renewcommand{\maketitlepage}{
\thispagestyle{empty}
{\fontsize{15}{15}\scshape\@author\par}
\vspace{5cm}
{\fontsize{37}{37}\scshape\@title}
\newpage
\pagenumbering{arabic}}
\makeatother

\title{Title}
\author{Author}

\begin{document}

\maketitle

\lipsum[1-4]

Now follows figure in code. % <=========================================
%Now follows figure in code. % <========================================
%Now follows figure in code. Now follows figure in code.
%Now follows figure in code. Now follows figure in code.
%Now follows figure in code. Now follows figure in code.
%Now follows figure in code. Now follows figure in code.
%Now follows figure in code. Now follows figure in code.

\begin{figure}
\centering
\includegraphics[width=0.4\textwidth]{example-image-a} % [width=0.4\textwidth]
\caption{figure}
\label{fig:example}
\end{figure}

This is text after the figure in code. % <==============================
This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.

\lipsum[5]
\end{document}


Then you get the same layout you have

but in the log file you can find following:

As you can see the culprit is that the wrong page number odd instead of even is recognized.

To get rid of that you can uncoment the commented lines to get the code:

\documentclass[%
justified,
symmetric,
titlepage,
debug       % <=======================================================
]{tufte-book}

\usepackage{graphicx, lipsum}
\usepackage[english]{babel}

\makeatletter
\renewcommand{\maketitlepage}{
\thispagestyle{empty}
{\fontsize{15}{15}\scshape\@author\par}
\vspace{5cm}
{\fontsize{37}{37}\scshape\@title}
\newpage
\pagenumbering{arabic}}
\makeatother

\title{Title}
\author{Author}

\begin{document}

\maketitle

\lipsum[1-4]

Now follows figure in code. % <=========================================
Now follows figure in code. % <========================================
Now follows figure in code. Now follows figure in code.
Now follows figure in code. Now follows figure in code.
Now follows figure in code. Now follows figure in code.
Now follows figure in code. Now follows figure in code.
Now follows figure in code. Now follows figure in code.

\begin{figure}
\centering
\includegraphics[width=0.4\textwidth]{example-image-a} % [width=0.4\textwidth]
\caption{figure}
\label{fig:example}
\end{figure}

This is text after the figure in code. % <==============================
This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.
This is text after the figure in code. This is text after the figure in code.

\lipsum[5]
\end{document}


As you can see here

the figure is centered, because the workaround moves the text around the figure to page 2. That allows a correct recognizing of used page you can see in the debug info:

So moving manually the code for the figure down or up can solve the culprit, but it is no automatic thing. To get the automatic back add the bug report to tufte web site.

• It seems like the issue has already been reported, here and here. The class was last updated four years ago, which tells me it isn't very well maintained . – noibe Feb 26 at 10:49

Apart from using manual markings with \forcerectofloat and \forceversofloat, I successfully tried a solution described in the documentation of the ifoddpage package:

%\usepackage{ifoddpage}% works also without this package
...
\makeatletter
\renewcommand*{\@tufte@checkoddpage}{%
\leavevmode \hbox \bgroup
\checkoddpage
\egroup
\ifoddpage%
\setboolean{@tufte@odd@page}{true}%
\else%
\setboolean{@tufte@odd@page}{false}%
\fi%
}%
\makeatother


I have neither checked for side-effects nor have I tested other examples. However, it may be a good point to start with.