I'm typesetting my document with tufte-book class which has an environment called marginfigure. it's good but sometime it doesn't fit my picture in document well. for example in this MW:

% !TEX TS-program = xelatex
% !TEX encoding = UTF-8


\settextfont{Times New Roman}
\setdigitfont{Times New Roman}

\draw[->] (-2,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-2) -- (0,2) node[above] {$y$};
\coordinate (o) at (0,0);
\coordinate (a) at (1,{sin(1 r)});
\coordinate (b) at (-1,{sin(-1 r)});
\draw[dashed] (a|-o) node[below] {$x$} -- (a) -- (a-|o) node[left] {$f(x)$};
\draw[dashed] (b-|o) node[right] {$-f(x)$} -- (b) -- (b|-o) node[above] {$-x$};
\draw[color=blue] plot (\x,{sin(\x r)});
\caption{ نمونه ای از یک تابع فرد}
\draw[->] (-2,0) -- (2,0) node[right] {$x$};
\draw[->] (0,-2) -- (0,2) node[above] {$y$};
\coordinate (o) at (0,0);
\coordinate (a) at (1,{cos(1 r)});
\coordinate (b) at (-1,{cos(-1 r)});
\draw[dashed] (a|-o) node[below] {$x$} -- (a) -- (a-|o);
\draw[dashed] (b-|o) node[above] {$f(x)$} -- (b) -- (b|-o) node[below] {$-x$};
\draw[color=blue] plot (\x,{cos(\x r)});
\caption{ نمونه ای از یک تابع زوج}


My picture is not completely in page. Is there a way of preventing that happening?

enter image description here

  • The key is that it (or at least memoir) uses \marginpar to place the image (which is saved using lrbox). – John Kormylo Dec 20 '16 at 14:15
  • See also tex.stackexchange.com/questions/292394/… – John Kormylo Dec 20 '16 at 14:20
  • Could you put both tikzpictures into one \marginfigure? Two captions in one figure (or minipage) is no problem. – John Kormylo Dec 20 '16 at 15:03
  • As far as I can see \marginpar cannot move stuff up, only down. – daleif Dec 20 '16 at 15:20

Macro \marginpar is fed a minipage by \marginfigure which causes the center of the figure to be aligned to the baseline of the text. This means that the bottom of the figure can protrude below the text area. One can raise it using \raisebox, but one must first determine how much space is left on the page.

This can be done several ways, but the easiest is to use tikzpagenodes.

Note: I am unable to get biditufte-book to work, so am using tufte-book instead.


\usepackage{showframe}% MWE only
\usepackage{lipsum}% MWE only

\newcommand{\GetDistanceToBottom}{\tikz[remember picture,overlay]{%
  \pgfextracty{\DistanceToBottom}{\pgfpointdiff{\pgfpointanchor{current page text area}{south}}%

  {\FloatBarrier% process all floats before this point so the figure/table numbers stay in order.
      \raisebox{\dimexpr \dp\@tufte@margin@floatbox-\DistanceToBottom}%





full page

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.