我正在尝试为 tufte-book.cls 书中的照相底片定义一个新环境。该环境应该:
- 与现有的图形/表格环境一样,适用于非星号用途,并且
- 将标题放在主体区域内、图形下方,以供加星号(全宽)使用。
每页将只有一张图片。纵向图片由无星号环境处理。横向图片由星号环境处理。
我有(1)通过定义一个有自己的柜台等的“盘子”环境来工作。 tufte-book 类中新浮动标题的放置。请参阅下面的 MWE。但是,我被困在 (2) 上了。
更改 tufte 类整页图表中的标题接近 - 但你失去了简短标题/图片列表/超文本引用功能。我认为我需要重新定义 \@caption 命令以供星号使用 - 按照类似如何更改 Tufte Book/Handout 中 marginfigure 的标签分隔符?或者如何在 tufte-book 中使用不带标题的图形标签?
一个混乱的解决方案可能是在每一页上使用 \newgeometry{} 来显示一个板块*并将 marginpar 定义为等于(或几乎等于)页面宽度。
这对于横向浮动(带星号)的长标题来说是必需的,因为它们在标准 tufte-book 实现中会从页面底部消失。对于非星号使用来说这不是问题,因为您可以使用 marginpar 。:
我的 MWE 是:
\documentclass[a4paper,justified,twoside,openright]{tufte-book}
\geometry{landscape,top=1in,bottom=0.75in,textheight=7in,textwidth=6in,marginparsep=0.5in,marginparwidth=3in}
\usepackage{tikz}
%% Plate environment %%%%%%%%%%%%%%% from https://tex.stackexchange.com/questions/113631/caption-placement-for-new-float-in-tufte-book-class
\newcounter{plate}
\newcommand\platename{Plate}
\newcommand\listplatename{List of Plates}
\makeatletter
\newcommand\listofplates{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listplatename}}%
{\section*{\listplatename}}%
% \begin{fullwidth}%
\@starttoc{lop}%
% \end{fullwidth}%
}
\renewcommand\theplate
% {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@plate}
{\@arabic\c@plate} % alter numbering to be continuous
\def\fps@plate{tbp}
\def\ftype@plate{1}
\def\ext@plate{lop}
\def\fnum@plate{\platename\nobreakspace\theplate}
\newenvironment{plate}[1][htbp]
{\begin{@tufte@float}[#1]{plate}{}}
{\end{@tufte@float}}
\newenvironment{plate*}[1][htbp]%
{\begin{@tufte@float}[#1]{plate}{star}}
{\end{@tufte@float}}
\newcommand{\@tufte@lop@line}[2]{%
% #1 is the figure/table number and its caption text
% #2 is the page number on which the figure/table appears
\leftskip 0.0em
\rightskip 0em
\parfillskip 0em plus 1fil
\parindent 0.0em
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima 2.0em
\advance\leftskip\@tempdima
\null\nobreak\hskip -\leftskip
{#1}\nobreak\qquad\nobreak#2%
\par%
}
\let\l@plate\l@figure
\makeatother
%% End plate environment %%%%%%%%%%%
\begin{document}
\listofplates
\chapter{Plate Environment}
\begin{plate}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption{Non-starred}
\label{plate:1}
\end{plate}
\begin{plate}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption[Non-starred - long caption.]{Non-starred - long caption. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum.}
\label{plate:2}
\end{plate}
\begin{plate*}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption{Starred}
\label{plate:3}
\end{plate*}
\begin{plate*}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption[Starred - long caption.]{Starred - long caption. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum.}
\label{plate:4}
\end{plate*}
\end{document}
答案1
这是我用来使某事奏效的方法。不是最巧妙的……
我将 @tufte@float 环境定义和 \@tufte@float@fullwidth 命令定义复制到我的前言中,分别将它们重命名为 @TC@float 和 \@TC@float@fullwidth。
我改变了我的 plate* 环境定义以使用 @TC@float 而不是标准的 tufte-class figure* 环境。
这使我可以改变标题文本框的宽度(改变行 \begin{minipage}[\floatalignment]{2\marginparwidth}\hbox{} 使其成为正常宽度的两倍)和位置,方法是强制 \@TC@float@fullwidth 仅使用我想要的选项(有效地注释掉不需要的选项)。
由于我的 \textwidth = 2\marginparwidth,并且 \@TC@float@fullwidth 中的选项允许位置位于左下方,因此我可以在图形下方和正文通常填充的相同空间中显示一个长标题。
梅威瑟:
\documentclass[a4paper,justified,twoside,openright]{tufte-book}
\usepackage{layouts}
\usepackage{showframe}
\geometry{landscape,top=1in,bottom=0.75in,textheight=7in,textwidth=6in,marginparsep=0.5in,marginparwidth=3in}
\usepackage{tikz}
%% Plate environment %%%%%%%%%%%%%%% from http://tex.stackexchange.com/questions/113631/caption-placement-for-new-float-in-tufte-book-class
\newcounter{plate}
\newcommand\platename{Plate}
\newcommand\listplatename{List of Plates}
\makeatletter
\newcommand\listofplates{%
\ifthenelse{\equal{\@tufte@class}{book}}%
{\chapter*{\listplatename}}%
{\section*{\listplatename}}%
% \begin{fullwidth}%
\@starttoc{lop}%
% \end{fullwidth}%
}
\renewcommand\theplate
% {\ifnum \c@chapter>\z@ \thechapter.\fi \@arabic\c@plate}
{\@arabic\c@plate} % alter numbering to be continuous
\def\fps@plate{tbp}
\def\ftype@plate{1}
\def\ext@plate{lop}
\def\fnum@plate{\platename\nobreakspace\theplate}
\newenvironment{plate}[1][htbp]
{\begin{@tufte@float}[#1]{plate}{}}
{\end{@tufte@float}}
% \newenvironment{plate*}[1][htbp]%
% {\begin{@tufte@float}[#1]{plate}{star}} % need to define a new @tufte@float environment - copy the existing one and alter all the names then change the position of the caption box. Something like @TC@float
% {\end{@tufte@float}}
\newenvironment{plate*}[1][htbp]%
{\begin{@TC@float}[#1]{plate}{star}} % need to define a new @tufte@float environment - copy the existing one and alter all the names then change the position of the caption box. Something like @TC@float
{\end{@TC@float}}
\newcommand{\@tufte@lop@line}[2]{%
% #1 is the figure/table number and its caption text
% #2 is the page number on which the figure/table appears
\leftskip 0.0em
\rightskip 0em
\parfillskip 0em plus 1fil
\parindent 0.0em
\@afterindenttrue
\interlinepenalty\@M
\leavevmode
\@tempdima 2.0em
\advance\leftskip\@tempdima
\null\nobreak\hskip -\leftskip
{#1}\nobreak\qquad\nobreak#2%
\par%
}
\let\l@plate\l@figure
\newenvironment{@TC@float}[3][htbp]%
{% begin @tufte@float
% Should this float be full-width or just text-width?
\ifthenelse{\equal{#3}{star}}%
{\gsetboolean{@tufte@float@star}{true}}%
{\gsetboolean{@tufte@float@star}{false}}%
% Check page side (recto/verso) and store detected value -- can be overriden in environment contents
\@tufte@checkoddpage%
\ifthenelse{\boolean{@tufte@odd@page}}%
{\gsetboolean{@tufte@float@recto}{true}\@tufte@float@debug{Detected page: [recto/odd]}}%
{\gsetboolean{@tufte@float@recto}{false}\@tufte@float@debug{Detected page: [verso/even]}}%
% If the float placement specifier is 'b' and only 'b', then bottom-align the mini-pages, otherwise top-align them.
\renewcommand{\@tufte@fps}{#1}%
\@tufte@float@debug{Allowed positions: [#1]}
\ifthenelse{\equal{#1}{b}\OR\equal{#1}{B}}%
{\renewcommand{\floatalignment}{b}\@tufte@float@debug{Presumed position: [bottom]}}%
{\renewcommand{\floatalignment}{t}\@tufte@float@debug{Presumed position: [top]}}%
% Capture the contents of the \caption and \label commands to use later
\global\let\@tufte@orig@caption\caption%
\global\let\@tufte@orig@label\label%
\renewcommand{\caption}{\optparams{\@tufte@caption}{[][0pt]}}%
\renewcommand{\label}[1]{\@tufte@label{##1}}%
% Handle subfigure package compatibility
\ifthenelse{\boolean{@tufte@packages@subfigure}}{%
% don't move the label while inside a \subfigure or \subtable command
\global\let\label\@tufte@orig@label%
}{}% subfigure package is not loaded
\@tufte@orig@float{#2}[#1]%
\ifthenelse{\boolean{@tufte@float@star}}%
{\setlength{\@tufte@float@contents@width}{\@tufte@fullwidth}}%
{\setlength{\@tufte@float@contents@width}{\textwidth}}%
\begin{lrbox}{\@tufte@figure@box}%
\begin{minipage}[\floatalignment]{\@tufte@float@contents@width}\hbox{}%
}{% end @tufte@float
\par\hbox{}\vspace{-\baselineskip}\ifthenelse{\prevdepth>0}{\vspace{-\prevdepth}}{}% align baselines of boxes
\end{minipage}%
\end{lrbox}%
% build the caption box
\begin{lrbox}{\@tufte@caption@box}%
% EDIT THE WIDTH OF THE CAPTION HERE
\begin{minipage}[\floatalignment]{2\marginparwidth}\hbox{}%
\ifthenelse{\NOT\equal{\@tufte@stored@caption}{}}{\@tufte@orig@caption[\@tufte@stored@shortcaption]{\@tufte@stored@caption}}{}%
\ifthenelse{\NOT\equal{\@tufte@stored@label}{}}{\@tufte@orig@label{\@tufte@stored@label}}{}%
\par\vspace{-\prevdepth}%% TODO: DOUBLE-CHECK FOR SAFETY
\end{minipage}%
\end{lrbox}%
% now typeset the stored boxes
\begin{fullwidth}%
\begin{minipage}[\floatalignment]{\linewidth}%
\ifthenelse{\boolean{@tufte@float@star}}%
{\@TC@float@fullwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}%
{\@TC@float@textwidth[\@tufte@caption@vertical@offset]{\@tufte@figure@box}{\@tufte@caption@box}}%
\end{minipage}%
\end{fullwidth}%
\@tufte@orig@endfloat% end original LaTeX float environment
% output debug info
\ifthenelse{\boolean{@tufte@debug}}{%
\typeout{^^J^^J----------- Tufte-LaTeX float information ----------}%
\ifthenelse{\equal{\@tufte@stored@label}{}}%
{\typeout{Warning: Float unlabeled!}}%
{\typeout{Float label: [\@tufte@stored@label]}}%
\typeout{Page number: [\thepage]}%
\def\MessageBreak{^^J}%
\typeout{\@tufte@float@debug@info}%
\ifthenelse{\boolean{@tufte@symmetric}}%
{\typeout{Symmetric: [true]}}%
{\typeout{Symmetric: [false]}}%
\typeout{----------------------------------------------------^^J^^J}%
}{}%
% reset commands and temp boxes and captions
\gdef\@tufte@float@debug@info{}%
\let\caption\@tufte@orig@caption%
\let\label\@tufte@orig@label%
\begin{lrbox}{\@tufte@figure@box}\hbox{}\end{lrbox}%
\begin{lrbox}{\@tufte@caption@box}\hbox{}\end{lrbox}%
\gdef\@tufte@stored@shortcaption{}%
\gdef\@tufte@stored@caption{}%
\gdef\@tufte@stored@label{}%
\gsetlength{\@tufte@caption@vertical@offset}{0pt}% reset caption offset
}
% COMMENT OUT ALL OPTIONS, THEN SELECT THE OPTION YOU WANT AND PLACE AT SHOWN POINT
%
\newcommand{\@TC@float@fullwidth}[3][0pt]{%
% \ifthenelse{\equal{\floatalignment}{b}}%
% {% place caption above figure
% \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
% {\hfill\smash{\raisebox{#1}{\usebox{#3}}}\par\usebox{#2}\@tufte@float@debug{Caption position: [above right]}}% caption on the right
% {\smash{\raisebox{#1}{\usebox{#3}}}\hfill\par\usebox{#2}\@tufte@float@debug{Caption position: [above left]}}% caption on the left
% }{% place caption below figure
% \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}%
% {\usebox{#2}\par\hfill\smash{\raisebox{#1}{\usebox{#3}}}\@tufte@float@debug{Caption position: [below right]}}% caption on the right
% {\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}}% caption on the left
% }%
% CHOSEN OPTION GOES HERE
\usebox{#2}\par\smash{\raisebox{#1}{\usebox{#3}}}\hfill\@tufte@float@debug{Caption position: [below left]}% caption on the left
}
\makeatother
%% End plate environment %%%%%%%%%%%
\begin{document}
\setuplayouts
\listofplates
\chapter{Plate Environment}
\begin{plate}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption{Non-starred}
\label{plate:1}
\end{plate}
\begin{plate}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption[Non-starred - long caption.]{Non-starred - long caption. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum.}
\label{plate:2}
\end{plate}
\begin{plate*}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption{Starred}
\label{plate:3}
\end{plate*}
\begin{plate*}
\tikz{\path[draw=red,fill=blue] (0,0) rectangle (\textwidth-1cm,\textheight-1cm);}
\caption[Starred - long caption.]{Starred - long caption. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum. Lorem ipsum, lorem ipsum,Lorem ipsum, lorem ipsum,Lorem ipsum.}
\label{plate:4}
\end{plate*}
\clearpage
\begin{figure}
\centering
%\setlayoutscale{0.3}
\currentpage
\drawparametersfalse
\drawpage
\caption{Test}
\end{figure}
%\setlayoutscale{0.3}
%\drawpage
\end{document}