将章节标题与边注对齐

将章节标题与边注对齐

我想将章​​节标题与边注对齐,如下所示。

\documentclass[12pt,a4paper,twoside,openright]{book}
% Page format
\usepackage[left=2cm,right=6cm,top=3cm,bottom=2.5cm,
headsep=1.5cm,headheight=1cm,marginparwidth=3.5cm, marginparsep=5mm,bindingoffset=0mm]{geometry}

\usepackage{amsfonts}
\usepackage[x11names]{xcolor}
\usepackage[framemethod=tikz]{mdframed}
\usetikzlibrary{calc}
\usepackage{todonotes}

\newlength{\myoddoffset}
\setlength{\myoddoffset}{\marginparwidth + \marginparsep}
\usepackage{fancyhdr}
\makeatletter
\fancypagestyle{mypagestyle}{
\fancyheadoffset[LO,LE]{\myoddoffset}
%\fancyfootoffset[LO,LE]{\marginparsep+\marginparwidth}
\fancyhead{}
\fancyhead[LE]{\thepage}
\fancyhead[RO]{\thepage}
\fancyhead[RE]{\leftmark}
\fancyhead[LO]{\rightmark}
\fancyfoot{}
\renewcommand{\headrulewidth}{0pt}
\renewcommand{\footrulewidth}{0pt}
}
\makeatother
\pagestyle{mypagestyle}


\reversemarginpar

\usepackage{xltxtra}
\usepackage{polyglossia}
\setdefaultlanguage[calendar=gregorian,hijricorrection=1,locale=morocco]{arabic} 

\defaultfontfeatures{Ligatures=TeX,%
Mapping=tex-text,%
AutoFakeSlant=0.2%Simulate Italic%
}
\newfontfamily\arabicfont[Script = Arabic,Scale=1.0]{Amiri} 


\makeatletter
\tikzset{notestyle/.append style={
    align=right}}

\renewcommand{\@todonotes@drawMarginNote}{%
\if@todonotes@dviStyle%
    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] {};%
    \end{tikzpicture}\\%
    \begin{minipage}{\@todonotes@textwidth}%
    \if@todonotes@authorgiven%
      \@todonotes@sizecommand \@todonotes@author \@todonotes@text%
    \else%
      \@todonotes@sizecommand \@todonotes@text%
    \fi%
    \end{minipage}\\%
    \begin{tikzpicture}[remember picture]%
        \draw node[notestyle] (inNote) {};%
    \end{tikzpicture}%
\else%
    \let\originalHbadness\hbadness%
    \hbadness 100000%
    \begin{tikzpicture}[remember picture,baseline=(X.base)]%
        \node(X){\vphantom{X}};%
        \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
            {\@todonotes@text};%
        \if@todonotes@authorgiven%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                {\@todonotes@sizecommand\@todonotes@author};%
            \node(Y)[below=of X]{};%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.south)%
                {\@todonotes@text};%
        \else%
            \draw node[notestyle,font=\@todonotes@sizecommand,anchor=north] (inNote) at (X.north)%
                {\@todonotes@text};%
        \fi%
    \end{tikzpicture}%
    \hbadness \originalHbadness%
\fi}
\makeatother

\begin{document}


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

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

\end{document}

期望输出

答案1

这会将章节标题移至左边距(从左到右)。我使用[oneside]这个方法是为了使左边距足够大。

我知道的唯一从右到左的方法是切换语言(顺便说一下,\rightskip在那里有效),这会导致无法找到所需字体的错误。

\documentclass[oneside]{book}
\usepackage{showframe}

\reversemarginpar

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

\newcommand{\mysection}[2][]{%
  \rightskip=-\offset
  \section[#1]{#2}%
  \rightskip=0pt}

\begin{document}

\leftskip=-\offset
\section{I wonder what happens if I use a very very very very long title?}
\leftskip=0pt

\end{document}

左边距

相关内容