%Test of margins and margins width

%Define paragraph command

\definenumber[ParagraphNumber][way=bysection,prefixsegments=100]
 
\unexpanded\def\startParagraph
    {\dosingleempty\dostartParagraph}
 
\def\dostartParagraph[#1]%
   {\getrawparameters[Paragraph][heading=,mark=,#1]%
    \incrementnumber[ParagraphNumber]%
    \ininner{\tfx\getnumber[ParagraphNumber]}%
    \doifsomething\Paragraphheading{\inouter{\Paragraphheading}}%
    \doifsomething\Paragraphmark{\expanded{\textreference[\Paragraphmark]{\fullheadnumber/\rawnumber[ParagraphNumber]}}}%
    \ignorespaces}

\unexpanded\def\stopParagraph
    {\blank[medium]}

% Setup margins and double sided

\definelayout[WithMarginnotes][location={duplex},grid=no,topspace=3cm,height=24cm,backspace=3cm,cutspace=0cm,leftmargin=1cm,leftmargindistance=0.4cm,width=12.1cm,rightmargindistance=0.4cm,rightmargin=3.5cm]
\setuplayout[WithMarginnotes]
\setuppagenumbering[alternative=doublesided,location=]
\showframe

% Test content

\starttext

\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte
\ininner{X X X X X X X X X X X X}\inouter{M M M M M M M M M M M M }\input tufte

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\startParagraph[heading={M M M M M M M M M M M M }]
\input tufte
\stopParagraph

\stoptext
