Tufte 类提供了@tufte@margin@float
用于表格和图形的环境,但其结果不会自动与文本对齐。该\marginnote
命令提供了一个边注,它与您放置注释的文本对齐,但是,它不以marginfigure
环境作为输入。那么我该如何修改此环境以使图形自动与文本对齐?
\documentclass[nofonts]{tufte-handout}
\usepackage{graphicx}
\newcommand*{\fig}
{
\marginnote
{
\includegraphics[width=\marginparwidth]{image2}
This is a margin figure.
}
}
\begin{document}
test\fig
\end{document}
答案1
尝试将以下代码添加到你的序言中:
\makeatletter
\catcode`\V=14 % `V' is a comment character unless [verbose]
\def\FloatBarrier{\begingroup \let\@elt\relax
V\edef\@tempa{\write\m@ne{Package placeins Info: Float barrier, from
V input line \the\inputlineno, processed on page \thepage, lands on
V page \noexpand\thepage. }}\@tempa
\edef\@tempa{\@fb@botlist\@deferlist\@dbldeferlist}%
\ifx\@tempa\@empty V\PackageInfo{placeins}{No floats held,}%
\else
\ifx\@fltovf\relax % my indicator of recursion
\if@firstcolumn V\PackageWarning{placeins}{Some floats are stuck,}%
\clearpage
\else V\PackageInfo{placeins}{Eject a column and check again:}%
\null\newpage\FloatBarrier
\fi
\else V\PackageInfo{placeins}{Must dump some floats}%
\newpage \let\@fltovf\relax V\PackageInfo{placeins}{Check again:}%
\FloatBarrier % recurse once only
\fi\fi \endgroup
\@fb@topbarrier }
\catcode`\V=11
\renewenvironment{@tufte@margin@float}[2][0pt]{%
\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
\begin{lrbox}{\@tufte@margin@floatbox}%
\begin{minipage}[t]{\marginparwidth}% top-aligned minipage
\@tufte@caption@font
\def\@captype{#2}%
\hbox{}\vspace*{#1}%
\@tufte@caption@justification
\@tufte@margin@par
\noindent
}{%
\end{minipage}%
\end{lrbox}%
\marginpar{\usebox{\@tufte@margin@floatbox}}%
}
%%
% Margin figure environment
\renewenvironment{marginfigure}[1][-7pt]%
{\begin{@tufte@margin@float}[#1]{figure}}
{\end{@tufte@margin@float}}
\makeatother
此代码与 Tufte-LaTeX 文档类中的代码之间的唯一区别是,minipage
新代码中的环境是顶部对齐而不是中心对齐,并且默认偏移量从 更改-1.2ex
为0pt
。