5

I'm using the tufte-latex layout, and running into problems with the double-sided mode. I found a proposed bug-fix here and applied it to the most recent version of tufte-latex available on github

% Define Tuftian float styles (with the caption in the margin)
% original \floatc@tufteplain command
%    \newcommand{\floatc@tufteplain}[2]{%
%      \begin{lrbox}{\@tufte@caption@box}%
%        \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
%          \@tufte@caption@font{\@fs@cfont #1:} #2\par%
%        \end{minipage}%
%      \end{lrbox}%
%      \smash{\hspace{\@tufte@caption@fill}\usebox{\@tufte@caption@box}}%
%    }

    % bugfix? - http://code.google.com/p/tufte-latex/issues/detail?id=50
    %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
    \newcommand{\floatc@tufteplain}[2]{%
      \begin{lrbox}{\@tufte@caption@box}%
        \begin{minipage}[\floatalignment]{\marginparwidth}\hbox{}%
          \@tufte@caption@font{\@fs@cfont #1:} #2\par%
        \end{minipage}%
      \end{lrbox}%
       \@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]}}%
  \ifthenelse{\NOT\boolean{@tufte@symmetric}\OR\boolean{@tufte@float@recto}}{%
    % asymmetric or page is odd, so caption is on the right
   \smash{\hspace{\@tufte@caption@fill}\usebox{\@tufte@caption@box}}%
    \@tufte@float@debug{Caption position: [right]}%
  }{% symmetric pages and page is even, so caption is on the left
\smash{\hspace{-\@tufte@overhang}\usebox{\@tufte@caption@box}}%
    \@tufte@float@debug{Caption position: [left]}%
  }%
    }
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

    \newcommand{\fs@tufteplain}{%
      \def\@fs@cfont{\@tufte@caption@font}%
      \let\@fs@capt\floatc@tufteplain%
      \def\@fs@pre{}%
      \def\@fs@post{}%
      \def\@fs@mid{}%
      \let\@fs@iftopcapt\iftrue%
    }
    \let\fs@tufteplaintop=\fs@tufteplain
    \let\floatc@tufteplaintop=\floatc@tufteplain
    \newcommand\floatc@tufteruled[2]{%
      {\@fs@cfont #1} #2\par%
    }
    \newcommand\fs@tufteruled{%
      \def\@fs@cfont{\@tufte@caption@font}%
      \let\@fs@capt\floatc@tufteplain%
      \def\@fs@pre{\hrule height.8pt depth0pt width\textwidth \kern2pt}%
      \def\@fs@post{\kern2pt\hrule width\textwidth\relax}%
      \def\@fs@mid{}%
      \let\@fs@iftopcapt\iftrue%
    }
    \newcommand\fs@tufteboxed{%
      \def\@fs@cfont{}%
      \let\@fs@capt\floatc@tufteplain%
      \def\@fs@pre{%
        \setbox\@currbox\vbox{\hbadness10000
        \moveleft3.4pt\vbox{\advance\hsize by6.8pt
          \hrule \hbox to\hsize{\vrule\kern3pt
            \vbox{\kern3pt\box\@currbox\kern3pt}\kern3pt\vrule}\hrule}}
      }%
      \def\@fs@mid{\kern2pt}%
      \def\@fs@post{}%
      \let\@fs@iftopcapt\iftrue%
    }
  }{%
    % Nothing to do
  }
}

I commented out what I thought was the relevant section, and pasted in the code that I found. However, I'm not sure if I have commented out all of the relevant parts as my problem still exists. For example, here you can see the caption on the wrong side of the margin:

enter image description here

I've noticed that the problem only occurs with tables or figures that are positioned at the top of the page. Captions elsewhere in the page are fine. I have also found that running \clearpage does result in the offending caption and figure or table to move to the correct side of the page, but this is not my preferred way of solving the problem for something book length!

2 Answers 2

4

You might try the \forceversofloat macro inside your figure environment. It will bypass Tufte-LaTeX's autodetection and force the caption to appear to the left of the figure. There's also a \forcerectofloat macro that does the opposite. More information about the use of these macros may be found on pages 25–26 of the Tufte-LaTeX sample book.

4
  • Thanks @godbyk - I missed that advice in the sample book. It's unfortunate that it won't do it automatically but it's very useful to know how to fix it and a lot better than \clearpage.
    – celenius
    Dec 9, 2011 at 20:55
  • 1
    @celenius: Normally it does do it automatically. However, at the top of the page it can sometimes get confused due to LaTeX's asynchronous page-breaking. When the figure was created, it was on the previous page. LaTeX then decided at the last minute to move it to the next page (after the figure had been typeset). Oftentimes, rerunning latex, pdflatex, or xelatex, will correct this but not always. As a last resort, using \forceversofloat and \forcerectofloat will tell Tufte-LaTeX to assume the figure is on the left- or right-hand page, respectively.
    – godbyk
    Dec 10, 2011 at 2:00
  • @godbyk Is there any command that does the same for footnotes/sidenotes? I use the symmetric option and now some footnotes appear on the wrong side.
    – jak
    Apr 1, 2015 at 19:40
  • 1
    @JakobH I'm afraid not. It relies on LaTeX placing the \marginpar in the right place. Near the tops of pages, LaTeX can misplace it because its output routine runs asynchronously with TeX's page builder. You might try the mparhack package to see if it solves the issue. (I haven't tried it with TL, so I don't know if it'll work or not.)
    – godbyk
    Apr 1, 2015 at 19:52
6

An automatic way of getting the float caption on the correct side is to use the changepage package

\usepackage[strict]{changepage}
...
\begin{figure}
\checkoddpage \ifoddpage \forcerectofloat \else \forceversofloat \fi
etc

with changes as necessary. This unconfuses LaTeX's page breaking and is more automatic than @godbyk 's answer.

2
  • Is there any way to force this behaviour? It worked for me initially (or at least looked like it did) but then as I continued to compile the figure moved back into the wrong place.
    – NotEvans.
    Dec 3, 2017 at 12:14
  • 1
    I've not had it fail for me. You might try adding \strictpagecheck just after \begin{figure}, which enforces strict checking. If that doesn't help, I can only presume that tufte is not playing well with the changepage package.
    – GeoffV
    Dec 4, 2017 at 14:31

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .