我正在使用 tufte-handout 文档类来为第三方文本提供页边注释,用于教学目的。因此,我希望保留正文图(figure
和figure*
环境)的编号,同时将页边图(marginfigure
环境)的编号分开。
有没有办法为边距图形创建单独的编号系统(例如,小罗马数字“图 iii”或字母“图 a”),同时保持其他两个图形环境不变?(我不需要任何 LoF)
答案1
是的,有办法。您可以定义一种新的浮点数(我称之为marfigure
),它有自己的计数器,然后marginfigure
根据新浮点数而不是标准重新定义figure
。我还提供了一个独立的“边距数字列表”:
\documentclass{tufte-book}
\usepackage{graphicx}
\hypersetup{colorlinks}
\title{A Tufte-Style Book\thanks{Thanks to Edward R.~Tufte for his inspiration.}}
\author[The Tufte-LaTeX Developers]{The Tufte-LaTeX\ Developers}
\publisher{Publisher of This Book}
\makeatletter
% counter for margin figures
\newcounter{marfigure}[chapter]
\renewcommand\themarfigure
{\ifnum \c@chapter>\z@ \thechapter.\fi \@roman\c@marfigure}
% definitions for the new float marfigure
\def\fps@marfigure{tbp}
\def\ftype@marfigure{1}
\def\ext@marfigure{lmf}
\def\fnum@marfigure{\figurename\nobreakspace\themarfigure}
\renewenvironment{marginfigure}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{marfigure}}
{\end{@tufte@margin@float}}
% definitions for the new list of margin figures
\newcommand\listmarfigurename{List of Margin Figures}
\let\l@marfigure\l@figure
\newcommand\listofmarfigures{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listmarfigurename}}%
{\section*{\listmarfigurename}}%
% \begin{fullwidth}%
\@starttoc{lmf}%
% \end{fullwidth}%
}
\makeatother
\begin{document}
\listoffigures
\listofmarfigures
\begin{figure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular figure}
\end{figure}
\begin{marginfigure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test margin figure}
\end{marginfigure}
\vspace{2cm}
\begin{figure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular figure}
\end{figure}
\begin{marginfigure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test margin figure}
\end{marginfigure}
\begin{figure*}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular starred figure}
\end{figure*}
\end{document}
由此产生的 LoF:
新的保证金数字列表:
该文件显示保证金数字及其计数器:
答案2
您也可以只renewcommand{\thefigure}
在本地处理marginfigure
环境:
\makeatletter
\newcounter{marginfigure}
% Margin figure environment
\renewenvironment{marginfigure}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{figure}
\refstepcounter{marginfigure}
\renewcommand{\thefigure}{\roman{marginfigure}}}
{\end{@tufte@margin@float}}
\makeatother
以下是 MWE(来自 Gonzalo 的回答,没有单独的边距数字列表):
% arara: pdflatex
% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass{tufte-book}
\usepackage{graphicx}
\hypersetup{colorlinks}
\title{A Tufte-Style Book\thanks{Thanks to Edward R.~Tufte for his inspiration.}}
\author[The Tufte-LaTeX Developers]{The Tufte-LaTeX\ Developers}
\publisher{Publisher of This Book}
\makeatletter
\newcounter{marginfigure}
% Margin figure environment
\renewenvironment{marginfigure}[1][-1.2ex]%
{\begin{@tufte@margin@float}[#1]{figure}
\refstepcounter{marginfigure}
\renewcommand{\thefigure}{\roman{marginfigure}}}
{\end{@tufte@margin@float}}
\makeatother
\begin{document}
\listoffigures
\begin{figure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular figure}
\label{fig:regularfig}
\end{figure}
test reference: \ref{fig:regularfig}
\begin{marginfigure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test margin figure}
\label{fig:marginfig}
\end{marginfigure}
test reference: \ref{fig:marginfig}
\vspace{2cm}
\begin{figure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular figure}
\end{figure}
\begin{marginfigure}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test margin figure}
\end{marginfigure}
\begin{figure*}
\centering
\includegraphics[width=.6\marginparwidth]{example-image-a}
\caption{test regular starred figure}
\end{figure*}
\end{document}