4

I want to customize chapter with tikz using xepersian package. I add this package to THIS CODE like below:

\documentclass[twoside]{book} \usepackage{tikz} \usetikzlibrary{shadows.blur} \usepackage{titletoc} \usepackage{lipsum} \usepackage{calc} \usepackage[]{titlesec} \definecolor{yourcolor}{HTML}{008bb2} \usepackage{xepersian} \settextfont{Yas} \colorlet{chpnumbercolor}{black} \makeatletter \let\oldl@chapter\l@chapter \def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{chpnumbercolor}{#2}}} \let\old@dottedcontentsline\@dottedtocline \def\@dottedtocline#1#2#3#4#5{% \old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{chpnumbercolor}{#5}}}} \makeatother \titleformat{\chapter}[display] {\normalfont\color{yourcolor}} {\filleft\Huge\sffamily\bfseries\chaptertitlename\hspace*{2mm}% \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}] \node[fill=yourcolor,circle,text=white] {\thechapter}; \end{tikzpicture}} {1ex} {\titlerule[1.5pt]\vspace*{5ex}\huge\sffamily\itshape} [] \titleformat{name=\chapter,numberless}[display] {\normalfont\color{yourcolor}} {} {1ex} {\vspace*{5ex}\huge\sffamily\itshape} [] %command to print the acutal minitoc \newcommand{\printmyminitoc}{% \noindent\hspace{-2cm}% \colorlet{chpnumbercolor}{white}% \begin{tikzpicture} \node[rounded corners,align=left,fill=yourcolor, blur shadow={shadow blur steps=5}, inner sep=5mm]{% \color{white}% \begin{minipage}{8cm}%minipage trick \printcontents[chapters]{}{1}{} \end{minipage}}; \end{tikzpicture}} \begin{document} \tableofcontents \chapter{\rl{فصل اول}} \startcontents[chapters] %print minitoc \printmyminitoc \section{سکشن اول} \lipsum[1] \section{سکشن دوم} \section{تست} \section{الف ب پ} \lipsum \chapter{\rl{فصل دوم}} \end{document} 

But numbers are not in persian style & word "chapter" (in persian "فصل" ) doesn't apear. enter image description here

1 Answer 1

5

Note first that the miniTOC inside \printmyminitoc command is reversed ( from left to right ) you can correct that with

\begin{RTL} \printcontents[chapters]{}{1}{} \end{RTL} 

To obtain persian form of \thechapter you can just do it with \lr{\thechapter}


Code

\documentclass[twoside]{book} \usepackage{tikz} \usetikzlibrary{shadows.blur} \usepackage{titletoc} \usepackage{lipsum} \usepackage{calc} \usepackage[]{titlesec} \definecolor{yourcolor}{HTML}{008bb2} \usepackage{xepersian} \settextfont{Yas} \colorlet{chpnumbercolor}{black} \makeatletter \let\oldl@chapter\l@chapter \def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{chpnumbercolor}{ #2}}} \let\old@dottedcontentsline\@dottedtocline \def\@dottedtocline#1#2#3#4#5{% \old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{chpnumbercolor}{#5}}}} \makeatother \titleformat{\chapter}[display] {\normalfont\color{yourcolor}} {\filleft\Huge\sffamily\bfseries\chaptertitlename\hspace*{2mm}% \begin{tikzpicture}[baseline={([yshift=-.6ex]current bounding box.center)}] \node[fill=yourcolor,circle,text=white] {\rl{\thechapter}}; \end{tikzpicture}} {1ex} {\titlerule[1.5pt]\vspace*{5ex}\huge\sffamily\itshape} [] \titleformat{name=\chapter,numberless}[display] {\normalfont\color{yourcolor}} {} {1ex} {\vspace*{5ex}\huge\sffamily\itshape} [] %command to print the acutal minitoc \newcommand{\printmyminitoc}{% \noindent\hspace{-2cm}% \colorlet{chpnumbercolor}{white}% \begin{tikzpicture} \node[rounded corners,align=left,fill=yourcolor, blur shadow={shadow blur steps=5}, inner sep=5mm]{% \color{white}% \begin{minipage}{8cm}%minipage trick \begin{RTL} \printcontents[chapters]{}{1}{} \end{RTL} \end{minipage}}; \end{tikzpicture}} \begin{document} \tableofcontents \chapter{\rl{فصل اول}} \startcontents[chapters] %print minitoc \printmyminitoc \section{سکشن اول} \lipsum[1] \section{سکشن دوم} \section{تست} \section{الف ب پ} \lipsum \chapter{\rl{فصل دوم}} \end{document} 

Output

enter image description here

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.