3

I want to add some marginal explanation notes for math lectures notes written in Arabic and I am using for that todonotes package. The problem is that the note text is not well adjusted.. I thought of changing text width for each note but the option \todo[textwidth=4cm] is not working. Also the arabic text within the todo note is adjusted to the left rather to the right.. Any help?

\documentclass[12pt,a4paper]{book}
%\usepackage[force]{filehook}
% Page format
\usepackage[left=5cm,right=5cm,top=3cm,bottom=2.5cm,
headsep=1.5cm,headheight=1cm]{geometry}

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


\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.5]{Scheherazade} 

\begin{document}


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

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

\end{document}

2 Answers 2

4

You can add align=right to the style notestyle like this

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

But this is not enough because of remember picture option of tikzpikture environment for the command \@todonotes@drawMarginNote, you should modify it with renewcommand

Code

\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.5]{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 الأعداد النسبية}:
\todo{\RL{مجموعة العناصر 
$\frac{m}{n}$
 حيث $m$ عدد صحيح و $n$ عدد طبيعي.
 }}
$$
\mathbb{Q} = \left\{\frac{m}{n} : m\in \mathbb{Z} , n\in\mathbb{N}\right\}. 
$$

\end{document}

Output

enter image description here

0
1

Unfortunately [textwidth=4cm] seems to be just a package option, so you can only set it when you are loading the package \usepackage[textwidth=4cm]{todonotes}. But you could adjust the tikz style todonotes uses (notestyleraw) to adjust the width and put it into a group together with the note you want to have a different width.

\documentclass{article}
\usepackage{todonotes}
\usepackage{blindtext}
\begin{document}
\blindtext
\todo{A regular note}
\blindtext
{% text width group start
\tikzstyle{notestyleraw} += [text width=4cm]%
\todo{A note with a custom width.}
}% text width group end
\blindtext
\todo{A regular note}
\end{document}

Output:

todonotes

3
  • Thanks Benjamin.. I still have problem of adjusting arabic text to the right.. please see my edited question.
    – Mostafa
    Feb 27, 2016 at 17:53
  • @user46994 Did you try with align=right option? i.e. \tikzstyle{notestyleraw} += [text width=4cm,align=right]
    – Ignasi
    Feb 27, 2016 at 20:28
  • @Ignasi Yes but it does not work.
    – Mostafa
    Feb 28, 2016 at 5:05

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .