Kapital kopf-bild und Toc mit polyglossia

Inhalt, Abbildungen, Tabellen, Quellcodes und andere Verzeichnisse


AAA
Forum-Newbie
Forum-Newbie
Beiträge: 1
Registriert: Mi 6. Mai 2020, 21:34

Kapital kopf-bild und Toc mit polyglossia

Beitrag von AAA »

ich möchte 2 Rechteck um den Kapitalname in dem Inhaltsverzeichnis legen.
Dafür habe ich diese Code:

Code: Alles auswählen

\documentclass[10pt,a4paper,openany,bidi]{book}
\usepackage{tocloft}
\usepackage{graphicx}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,decorations.pathmorphing,decorations.text}
\usepackage[tmargin=2cm,bmargin=2.5cm,hmargin=2cm,foot=1pt]{geometry}
\usepackage[most]{tcolorbox}
\newtcbox{\chapternumberbox}[1][]{%
  colback=blue!50!black,
  colupper={white},
  fontupper={\bfseries\large},
  valign=center,
  size=small,
  nobeforeafter,
  equal height group=chaptertoc,
  #1,
}
\newtcolorbox{chapternamebox}[1][]{%
  enhanced jigsaw,
  valign=center,
  interior style={left color={white!30!blue},right color={white!90!blue}},
  colframe={red},
  boxrule={1pt},
  colupper={black},
  size=small,
  fontupper={\bfseries\large},
  nobeforeafter,
  equal height group=chaptertoc,
  #1,
}
\newcommand{\mychapternamebox}[3][]{%
  \begin{chapternamebox}[#1]
    #2\hfill#3%
  \end{chapternamebox}%
}
\usepackage{xpatch}
\makeatletter
\xpatchcmd{\@chapter}{%
  \addcontentsline{toc}{chapter}%
  {\protect\numberline{\thechapter}#1}%
}{%
  \addtocontents{toc}{\protect\cftpagenumbersoff{chapter}}
  \addcontentsline{toc}{chapter}{\protect\chapternumberbox{\protect\chaptername{} \thechapter}\protect\mychapternamebox[width={13.8cm}]{#1}{\thepage}}%%
  \addtocontents{toc}{\protect\cftpagenumberson{chapter}}%
}{}{}
\definecolor{corref@color}{cmyk}{0,0.88,0.88,0.45}
\usepackage[colorlinks=true,linkcolor=corref@color]{hyperref}
\usepackage{polyglossia}
\setmainlanguage{arabic}
\setmainlanguage[numerals=maghrib]{arabic}
%% Setting a font
\newfontfamily\arabicfont[Script=Arabic]{Amiri}
\setotherlanguage{english}
\begin{document}
\renewcommand{\bibname}{}
\tableofcontents
\chapter{First Chapter}
\section{First Section}‎‎
\section{Second Section}
\chapter{Second Chapter}
\section{First Section}‎‎
\section{Second Section}
\section{Thirdd Section}
\end{document}

Dazu möchte ich tikz-Bild um den Kapitalname in der ersten Seite bei
jedem Kapital legen.
Dafür habe ih diese Code:

Code: Alles auswählen

% Run with XeLaTeX and the order of preamble is important!
\documentclass[10pt,a4paper,openany]{book}
\usepackage[x11names,dvipsnames,svgnames]{xcolor}
\usepackage{tikz}
\usetikzlibrary{calc,shapes.geometric,decorations.pathmorphing,decorations.text}
\usepackage{verbatim}
\usepackage{fontspec}
\usepackage{kpfonts}
\usepackage[explicit]{titlesec}
\usepackage{nameref}                
\usepackage[toc,page]{appendix}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \usepackage{polyglossia} \setmainlanguage[numerals=maghrib]{arabic} \setotherlanguage{english} \newfontfamily\arabicfont[Script=Arabic]{Times New Roman} %%%%%%%%%%%%%%%%%%%%%%%%%%%%%% \makeatletter \newcommand{\currentname}{\@currentlabelname} \renewcommand\tableofcontents{% \chapter[قائمة المحتويات]{} \@starttoc{toc}% } \makeatother \newcommand{\customTitleFormat}[1]{% \titleformat{name=\chapter} {\normalfont\huge\bfseries}{ \begin{tikzpicture}[remember picture,overlay] \node[yshift=-3cm] at (current page.north west) {\begin{tikzpicture}[remember picture, overlay] \draw[fill=LightSkyBlue] (0,0) rectangle (\paperwidth,3cm); \node[anchor=east,xshift=.9\paperwidth,rectangle, rounded corners=20pt,inner sep=11pt,fill=MidnightBlue, text=white]{#1}; \end{tikzpicture} }; \end{tikzpicture} }{20pt}{\Huge} \titlespacing*{name=\chapter}{0pt}{50pt}{-60pt} } \newcommand{\chapterformat}{% \titleformat{name=\chapter} {\normalfont\huge\bfseries}{ \begin{tikzpicture}[remember picture,overlay] \node[yshift=-3cm] at (current page.north west) {\begin{tikzpicture}[remember picture, overlay] \draw[fill=LightSkyBlue] (0,0) rectangle (\paperwidth,3cm); \node[anchor=east,xshift=.9\paperwidth,rectangle, rounded corners=20pt,inner sep=11pt,fill=MidnightBlue, text=white]{\currentname\ \thechapter}; \end{tikzpicture} }; \end{tikzpicture} }{20pt}{\Huge} \titlespacing*{\chapter}{0pt}{50pt}{-60pt} } \begin{document} \renewcommand{\bibname}{} \customTitleFormat{قائمة المحتويات} \tableofcontents \chapterformat \chapter[المقدمة]{} Text \chapter[الفصل التالي]{} More text \section{البداية} Extra more text \customTitleFormat{قائمة المراجع} \begin{thebibliography}{99} \bibitem{Test} test reference \end{thebibliography} \begin{appendices} \chapter[الجزء الاول]{} Infomration... \end{appendices} \end{document}

Das Problem ist wenn ich die beiden codes zusammen verwenden, sie funktionieren nicht.
Die Frage ist wie kann ich diese 2 codes zusammen verwenden??

Dateianhänge
Bild-3
Bild-3
Bild-3.png (8.49 KiB) 802 mal betrachtet
Bild-2
Bild-2
Bild-2.png (11.7 KiB) 802 mal betrachtet
Bild-1
Bild-1
bild-1.png (18.77 KiB) 802 mal betrachtet