I want to align sections titles with margin notes as shown below.

% Page format
headsep=1.5cm,headheight=1cm,marginparwidth=3.5cm, marginparsep=5mm,bindingoffset=0mm]{geometry}


\setlength{\myoddoffset}{\marginparwidth + \marginparsep}



AutoFakeSlant=0.2%Simulate Italic%
\newfontfamily\arabicfont[Script = Arabic,Scale=1.0]{Amiri} 

\tikzset{notestyle/.append style={

    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] {};%
      \@todonotes@sizecommand \@todonotes@author \@todonotes@text%
      \@todonotes@sizecommand \@todonotes@text%
    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] (inNote) {};%
    \hbadness 100000%
    \begin{tikzpicture}[remember picture,baseline=(X.base)]%
        \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
            \node(Y)[below=of X]{};%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.south)%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
    \hbadness \originalHbadness%


\section{مجموعات الأعداد}

 قسمة عددين صحيحين هو عدد نسبي، أي أنه عنصر من مجموعة 
{\bfseries الأعداد النسبية}:
\vadjust{\todo{\RL{مجموعة العناصر 
 حيث $m$ عدد صحيح و $n$ عدد طبيعي.
\mathbb{Q} = \left\{\frac{m}{n} : m\in \mathbb{Z} , n\in\mathbb{N}\right\}. 


Desired Output

  • Could you make your MWE a little more minimal? From what I can gather, all you really want is to move the section titles into the margin. This can be done with \leftskip or \rightskip (depending which side of the page}. – John Kormylo Mar 6 '16 at 15:38
  • @JohnKormylo I want all the sections titles in the whole document to be aligned with margin notes and headings. So I don't want really to do it manually for each sequence. What I put in the MWE is what is really needed: RTL, twoside, todonotes, fancyhdr. – user46994 Mar 6 '16 at 18:29
  • Since \section is used for lots of other things (\tableofcontents for example), it would be better to create a new macro (\mysection) than redefine the old one. – John Kormylo Mar 6 '16 at 21:01

This will move the section title into the left margin (for left to right). I used [oneside] so that the left margin would be big enough.

The only way I know to use right to left is to switch languages (BTW \rightskip works there) which leads to errors about not being able to find the needed font.



\setlength{\offset}{\dimexpr \marginparwidth+\marginparsep}



\section{I wonder what happens if I use a very very very very long title?}


left margin

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.