重新定義標題頁時數字不會居中

重新定義標題頁時數字不會居中

我正在使用該類別tufte-book。如果我重新定義\maketitlepage命令,數字將不再居中。這是重現問題的 MWE:

\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}

這就是(不需要的)結果

在此輸入影像描述

答案1

我建議您在 tufte 網頁上寫一份錯誤報告。

請參閱以下稍微更改的程式碼(重要的是,我添加了選項debug,並且在圖周圍添加了更多文本,以便能夠通過更多更改來顯示罪魁禍首(取消註釋更多文本)):

\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}

然後你會得到相同的佈局

佈局

但在日誌檔案中您可以找到以下內容:

偵錯資訊

odd正如您所看到的,罪魁禍首是even識別了錯誤的頁碼。

要擺脫它,您可以取消註解行以取得程式碼:

\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}

正如你在這裡看到的

頁面佈局

該圖居中,因為解決方法將圖周圍的文字移至第 2 頁。

在此輸入影像描述

因此,手動向下或向上移動圖形的程式碼可以解決問題,但這不是自動的事情。若要自動返回,請將錯誤報告新增至 tufte 網站。

答案2

除了使用 和 進行手動標記之外\forcerectofloat\forceversofloat我還成功嘗試了套件文件中描述的解決方案ifoddpage

%\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

我既沒有檢查副作用,也沒有測試其他例子。然而,這可能是一個很好的起點。

相關內容