2

I'm looking for a way to put sidenotes in mdframed environment on Tufte-LaTeX. Text would be refered to inside the box, and the note lying in the margin.

I have already found a fancy way to do an equivalent thing with footnotes in an article document class (Place a footnote in an environment in the bottom of the page). Here is my minimal working version for this case :

\documentclass{article}

\usepackage[utf8]{inputenc} % Required for including letters with accents
\usepackage[T1]{fontenc} % Use 8-bit encoding that has 256 glyphs
\usepackage{amsmath,amsthm}
\usepackage{xcolor}
\usepackage{etoolbox} % Necessary for the toggle 
\usepackage{footnote}
\usepackage[framemethod=default]{mdframed} % Required for creating the definition box


%----------------------------------------------------------------------------------------
%   THEOREM STYLES
%----------------------------------------------------------------------------------------

\definecolor{thmcolor}{rgb}{0.71,0.14,0.07}

% Boxed/framed environments
\newtheoremstyle{redThm}  % Theorem style name
{0pt}                     % Space above
{0pt}                     % Space below
{\normalfont}             % Body font
{}                        % Indent amount
{\small\bf\sffamily\color{thmcolor}}% % Theorem head font
{\;}                      % Punctuation after theorem head
{0.25em}                  % Space after theorem head
{\small\sffamily\color{thmcolor}\thmname{#1}\nobreakspace\thmnumber{#2}% Theorem text (e.g. Theorem 2.1)
    \thmnote{\nobreakspace\the\thm@notefont\sffamily\bfseries\color{black}---\nobreakspace#3.}} % Optional theorem note

\theoremstyle{redThm}
\newtheorem{defn}{Définition}[section]

%----------------------------------------------------------------------------------------
%   DEFINITION OF COLORED BOX
%----------------------------------------------------------------------------------------

% Definition box
\newmdenv[skipabove=7pt,
skipbelow=7pt,
rightline=false,
leftline=true,
topline=false,
bottomline=false,
linecolor=thmcolor,
innerleftmargin=5pt,
innerrightmargin=5pt,
innertopmargin=0pt,
leftmargin=0cm,
rightmargin=0cm,
linewidth=4pt,
innerbottommargin=0pt]{vBar}    

\newtoggle{indefintion}
\togglefalse{indefintion}
\pretocmd{\footnote}{\iftoggle{indefintion}{\stepcounter{footnote}}{\relax}}{}{}

% Creates the environment ---> @iacopo suggestion <---
\newenvironment{definition}[1]{%
  \savenotes
  \begin{vBar}\begin{defn}
      \toggletrue{indefintion}
      \renewcommand{\thempfootnote}{\arabic{footnote}}
    \item[\hskip \labelsep]
      {\bfseries #1}}{\end{defn}\end{vBar}
  \togglefalse{indefintion}
\spewnotes}

\begin{document}

\begin{definition}
  My definition.\footnote{My footnote.}
\end{definition}

\bigskip

My text.\footnote{Core text footnote}.  

\end{document}

Changing footnotes by sidenotes isn't enough to get it work in a tufte-latex document class : I would like to adapt the /savenote, /spewnote trick to sidenotes, while keeping a consistent numbering inside the page with the toggle trick (which allows not to increment the counter when there is no sidenote in the theorem).

Your Answer

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

Browse other questions tagged or ask your own question.