0

enter image description here

\documentclass[12pt,oneside, tikz, ignorerest=false]{book} \usepackage[paperwidth=210mm,paperheight=297mm,hmargin=0.5cm,top=10mm,bottom=23mm]{geometry} \usepackage{tikz} \usetikzlibrary{mindmap} \pagestyle{empty} \usepackage{etoc} %\usepackage{hyperref}% if links are wanted \usepackage[pdfstartview=FitH,colorlinks=true,urlcolor=blue,linkcolor=red]{hyperref} \usepackage{polyglossia} \setotherlanguage{english} \setmainlanguage[numerals=maghrib]{arabic} \setotherlanguage{french} \newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Amiri} \newfontfamily\frenchfont{Times New Roman} \newfontfamily\fontb[Script=Arabic, Scale=0.9]{AlBattar} \newfontfamily\fonta[Script=Arabic, Scale=1.2]{AlBattar} \newfontfamily\ttfont[Script=Arabic, Scale=1.2]{AlBattar} \newfontfamily\myfont[Script=Arabic,Scale=1.3]{Sakkal Majalla} \newfontfamily\na[Script=Arabic,Scale=0.9]{Amiri} \newfontfamily\naa[Script=Arabic,Scale=0.8]{Amiri} \begin{document} \newtoks\treetok \newtoks\chaptertok \newtoks\sectiontok \newcommand*\treenode {} % just to check we don't overwrite something \newcommand*\tmprotate {} % just to check we don't overwrite something \newcommand*\tmpoption {} % just to check we don't overwrite something \newcommand*\tmpstuff {} % just to check we don't overwrite something \newcommand*\appendtotok[2]{% #1=toks variable, #2=macro, expands once #2 #1\expandafter\expandafter\expandafter{\expandafter\the\expandafter #1#2}} \newcommand*{\appendchildtree}[3]{% % this is to construct "t1 child [concept color= #3]{t2}" from #1=t1 and #2=t2 % t1 and t2 are two toks variable (not macros) % #3 = for example teal!60 \edef\tmpstuff {\the#1 child [concept color = #3]{\the#2}}% #1\expandafter {\tmpstuff }% } \newcounter{partco} \etocsetstyle{chapter} {} {} { \toks0 \expandafter{\etocthelinkednumber}% \toks2 \expandafter{\etocthelinkedname}% \stepcounter{partco}% \ifcase\value{partco}% \or \def\tmpoption {}% \def\tmprotate {[clockwise from = 120]}% first \or \def\tmpoption {}% \def\tmprotate {[clockwise from = 60]}% second \else\def\tmpoption {\textarabic{}}% \def\tmprotate {[counterclockwise from = 90]}% third and higher \fi % define the part node \edef\treenode{node \tmpoption{\the\toks2} \tmprotate }% % this is a starting point which will be filled it by the section children \chaptertok\expandafter{\treenode} } {} %\etocsetstyle{chapter} % {\etocskipfirstprefix} % {\appendchildtree\treetok\chaptertok} % {\preparetreenode % \chaptertok\expandafter{\treenode}} % {\appendchildtree\treetok\chaptertok} \etocsetstyle{section} {} {} {\toks0 \expandafter{\etocthelinkednumber}% \toks2 \expandafter{\etocthelinkedname }% % define the section node \edef\treenode {node {\the\toks2 \space\the\toks0}} \sectiontok\expandafter{\treenode}% % update current part tree with this section node, adding the correct color \ifcase\value{partco}% \or \appendchildtree\chaptertok\sectiontok {teal!30}% first \or \appendchildtree\chaptertok\sectiontok {yellow!40}% second \or \appendchildtree\chaptertok\sectiontok {red!80} \else\appendchildtree\chaptertok\sectiontok {green!30}% third etc... \fi } % This updates the global tree with the data from the % part and all its children sections {\ifcase\value{partco}% \or \appendchildtree\treetok\chaptertok {teal!60}% first \or \appendchildtree\treetok\chaptertok {yellow!80}% second \or \appendchildtree\treetok\chaptertok {red!80}% second \else\appendchildtree\treetok\chaptertok {green!50}% third and next ... \fi } \etocsettocstyle {\treetok{\node{\textbf{\textarabic{العنواين الرئيسية}}} [clockwise from=45]}} {\global\appendtotok\treetok{ ;}} % The \global above is mandatory because etoc always typesets TOC inside a group \tableofcontents % \showthe\treetok % debugging \begin{tikzpicture}[rotate=90, grow cyclic, text width=2cm, align=flush center, every node/.style=concept, concept color=orange!60, level 1/.style={level distance=5cm,sibling angle=90}, level 2/.style={rotate=-30,level distance=4cm,sibling angle=45}] \the\treetok \end{tikzpicture} \chapter {\textarabic{العنوان الرئيسي الاول}} \section {\textarabic{العنوان الاول}} \section {العنوان الثاني } \section {\textarabic{العنوان الثالث}} \chapter {العنوان الرئيسي الثاني } \section {العنوان الفرعي الاول} \section {العنوان الثاني} \section {العنوان الثاني} \end{document} 
2
  • are you using lualatex or xelatex? Commented Jun 4, 2023 at 7:53
  • your image does not seem to match the pasted code for chapters which uses only \toks2 which contains the name, and not \toks0 which contains the number, but your image appears to have chapter numbers. Commented Jun 4, 2023 at 8:10

1 Answer 1

1

I don't have the fonts so I tested your example with

 % \newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Amiri} % \newfontfamily\frenchfont{Times New Roman} % \newfontfamily\fontb[Script=Arabic, Scale=0.9]{AlBattar} % \newfontfamily\fonta[Script=Arabic, Scale=1.2]{AlBattar} % \newfontfamily\ttfont[Script=Arabic, Scale=1.2]{AlBattar} % \newfontfamily\myfont[Script=Arabic,Scale=1.3]{Sakkal Majalla} % \newfontfamily\na[Script=Arabic,Scale=0.9]{Amiri} % \newfontfamily\naa[Script=Arabic,Scale=0.8]{Amiri} \newfontfamily\arabicfont[Script=Arabic,Scale=1.2]{Al Tarikh} \newfontfamily\frenchfont{Times New Roman} \newfontfamily\fontb[Script=Arabic, Scale=0.9]{Al Tarikh} \newfontfamily\fonta[Script=Arabic, Scale=1.2]{Al Tarikh} \newfontfamily\ttfont[Script=Arabic, Scale=1.2]{Al Tarikh} \newfontfamily\myfont[Script=Arabic,Scale=1.3]{Al Tarikh} \newfontfamily\na[Script=Arabic,Scale=0.9]{Al Tarikh} \newfontfamily\naa[Script=Arabic,Scale=0.8]{Al Tarikh} 

as Al Tarikh is available on my mac os as system font. Compiling with XeLaTeX I see some strange fontspec warning:

Package fontspec Warning: Font "Al Tarikh" does not contain requested Script (fontspec) "Arabic". 

but the output may be ok: (caveat I don't read arabic, so apologies in advance)

xelatex altarikh

The lines commanding this appear to be the following

 {\toks0 \expandafter{\etocthelinkednumber}% \toks2 \expandafter{\etocthelinkedname }% % define the section node \edef\treenode {node {\the\toks2 \space\the\toks0}} 

in the \etocsetstyle{section} hunk. So it already says to put the number on right, but perhaps it should actually be in output this opposite due to LTR ? maybe my output is all wrong... notice here the section numbers are below only due to the width which happens to shift them to a second line.

You can thus try to play with the order of things in the line

 \edef\treenode {node {\the\toks2 \space\the\toks0}} 

and use some TikZ syntax here perhaps to manage the node width.

Another fontspec warning is

Missing character: There is no ‏ (U+200F) in font Al Tarikh Regular/OT:language =dflt;! 

Finally, trying lualatex gives an altogether different output:

lualatex output

No idea if this is TikZ problem or RTL rendering problem.


Back to xelatex and integrating these comments:

I need the section nombre before the section not after

locate the line after % define the section node which is \edef\treenode {node {\the\toks2 \space\the\toks0}} and replace it with \edef\treenode {node {\the\toks0 \noexpand\hspace{3mm}\the\toks2}}

i added a \hspace so you can configure spacing. The \noexpand is because this is in an \edef but expansion must be delayed. Also, I am assuming you still want RTL for the section number so 1.1, 2.1, 3.1 and not 1.1, 1.2, 1.3.

Output:

enter image description here

5
  • I need the section nombre before the section not after Commented Jun 6, 2023 at 11:56
  • see updated answer. If you need the section numbers to use LTR typesetting you may use \edef\treenode {node {{\noexpand\textfrench{\the\toks0}}\noexpand\hspace{3mm}\the\toks2}} rather. Commented Jun 6, 2023 at 12:18
  • I finde the. Solution withe \RL \edef\treenode {node {\RL {{\noexpand\textfrench{\the\toks0}}\noexpand\hspace{3mm}\the\toks2}}} Commented Jun 6, 2023 at 19:39
  • right to left is too challenging to me; good that you solved it for yourself Commented Jun 6, 2023 at 20:59
  • I sloved it Withe your solution Commented Jun 6, 2023 at 21:42

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.