I'm not sure if LyX exposes them, but the Tufte-LaTeX document classes provide a few options for adjusting the positions of captions and margin notes.
Adjusting margin notes and sidenotes positions
First, if you want to adjust the minimum distance between all margin notes (and not just one or two), then you can set the \marginparpush
length:
% The default minimum amount of space between \marginnotes is 10 pt.
\setlength\marginparpush{10pt}
Next, you can adjust the position of \marginnote
s and \sidenote
s using an optional parameter. To adjust the position of a \marginnote
or \sidenote
, use the following syntax:
\marginnote[<offset>]{Margin note text}
\sidenote[][<offset>]{Sidenote text}
where a positive <offset>
length moves the note down and a negative length moves the note down. Some examples of valid lengths are:
1.0in 2.54cm 254mm 6\baselineskip
You can view more information about the \marginnote
and \sidenote
commands on pages 21–22 of the Tufte-LaTeX documentation (PDF).
Adjusting caption positions
Captions can be positioned vertically in one of a four positions: either above or below the figure or top- or bottom-aligned with the figure.
The vertical alignment of the caption can be affected in two ways: (1) using the \setfloatalignment
macro or (2) using the optional offset argument.
Unless the figure position specifier is only [b]
, the Tufte-LaTeX document classes assume the figure will be positioned at the top of the page, in the middle of the page, or on its own page. The caption will be top-aligned with text-width figure
s and placed below full-width figure*
s.
If the figure position specifier is [b]
, then the caption will be bottom-aligned with text-width figures and placed above full-width figure*
s.
You can change this position of the caption using the \setfloatalignment
macro. Using \setfloatalignment{b}
will bottom-align the caption and \setfloatalignment{t}
will top-align the caption. This is convenient for moving a caption that would otherwise interfere with a sidenote or margin note and still keeps the caption neatly aligned with the top or bottom edge of the figure.
Another option for moving the caption is to use the optional offset argument similar to that of the \sidenote
and \marginnote
macros:
\caption[][<offset>]{Caption text}
The syntax of the \caption
command (and a few examples) is provided on pp. 23–24 of the manual, and more information about the \setfloatalignment
macro is available on pp. 25–26 of the manual.
Here's an approach I've used to get something working. Not the neatest...
I copied the @tufte@float environment definition and the \@tufte@float@fullwidth command definition into my preamble, renaming them as @TC@float and \@TC@float@fullwidth, respectively.
I altered my plate* environment definition to use @TC@float instead of the standard tufte-class figure* environment.
This allows me to alter the width of the caption text box (altering the line \begin{minipage}[\floatalignment]{2\marginparwidth}\hbox{} makes it twice the normal width) and the location by forcing \@TC@float@fullwidth to only use the option I want (commenting out the unwanted options, effectively).
As my \textwidth = 2\marginparwidth, and an option in \@TC@float@fullwidth allows the position to be bottom left, I can have a long caption appear below my figure and in the same space as the body text would normally fill.
MWE:
\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}
Best Answer
If you include
\listfiles
before\begin{document}
and compile you can see the list of packages and its version shown below.you might be using an old version of
sidenotes.sty 2011/11/29 v0.81
which causes the error, becausemarginfigure
feature is added insidenotes
fromv0.90
as seen in page 6 of Change History. Hence your MWE compiles well withsidenotes.sty 2012/11/09 v0.92
.It is recommended to update to your TeX distribution ? to keep pace with latex package development or use latest version of sidenotes from ctan.