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
\documentclass{biditufte-book}
\usepackage{ptext}
\usepackage{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,patterns,decorations.pathmorphing,arrows.meta,decorations.markings}
\usepackage[localise=on]{xepersian}
\settextfont{Times New Roman}
\setdigitfont{Times New Roman}
\begin{document}
\chapter{مشاهدهپذیری}
\ptext[1-4]
\section{مقدمه}
\begin{marginfigure}
\centering
\begin{tikzpicture}[domain=-2:2]
\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)});
\end{tikzpicture}
\caption{ نمونه ای از یک تابع فرد}
\end{marginfigure}
\begin{marginfigure}
\centering
\begin{tikzpicture}[domain=-2:2]
\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)});
\end{tikzpicture}
\caption{ نمونه ای از یک تابع زوج}
\end{marginfigure}
\section{مقدمه}
\ptext[1]
\end{document}
My picture is not completely in page. Is there a way of preventing that happening?


\marginparcannot move stuff up, only down. – daleif Dec 20 '16 at 15:20