我正在使用该类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
我既没有检查副作用,也没有测试其他示例。然而,这可能是一个好的起点。