8

I want to use marginfigure, but it is inserting space inline. Check out my minimal example:

documentclass{tufte-book}

\begin{document}
Hello\begin{marginfigure}$2+2=4$\end{marginfigure}I'm new here.

\end{document}

enter image description here

As you can see, the "Hello I'm new here" is two different lines--I want a single line. Of course, one "solution" is to simply move the marginfigure; however, this is not an option for me.

1 Answer 1

10

The culprit appears to be the \FloatBarrier command (provided by the placeins package). If we remove the \FloatBarrier command from the code that generates the marginfigure, then no space is inserted:

\documentclass{tufte-book}

% Remove \FloatBarrier from marginfigure definition
% to prevent unwanted spaces.
\makeatletter% so we can use @ commands
\renewenvironment{@tufte@margin@float}[2][-1.2ex]{%
  %\FloatBarrier% removed because it adds unwanted white space
  \begin{lrbox}{\@tufte@margin@floatbox}%
  \begin{minipage}{\marginparwidth}%
    \@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}}%
}
\makeatother% restore meaning of @


\begin{document}

Hello\begin{marginfigure}$2+2=4$\end{marginfigure}I'm new here.

\end{document}
4
  • To make this work in Lyx, simply remove \makeatletter% so we can use @ commands and \makeatother% restore meaning of @ from the code and use everything else in between inside Document>Settings>LaTeX Preamble for Lyx.
    – Black Milk
    Oct 30, 2013 at 0:13
  • But is this simply a bug in tufte-latex, or is there some drawback to removing \FloatBarrier? Jan 9, 2019 at 22:47
  • Removing \FloatBarrier could allow LaTeX to place earlier figures after the margin figure so the numbering would appear out of sequence. You could remove \FloatBarrier and, if you notice there's a problem, write \FloatBarrier yourself in between paragraphs where it won't cause spacing problems.
    – godbyk
    Jan 10, 2019 at 3:52
  • Thank you godbyk... this is SO useful! (+1) Mar 9, 2019 at 2:05

You must log in to answer this question.

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