0

So, I'm trying to recreate the following style of TOC.

enter image description here

I used the following:

{\tikz[remember picture,overlay] 
\draw [fill,red!20] (current page.north west) rectangle
 +(0.33\paperwidth,-\paperheight);
\tableofcontents}

which I found in this answer. It works OK, but I get only the one page of the TOC filled with color. The second and final page of the TOC is left intact. So, how can I succeed in getting the rectangle produced by tikz to match the two pages of my toc?

Here, is an MWE

\documentclass[12pt, a4paper, twoside, openany]{memoir}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{polyglossia}
\usepackage{xltxtra}
\usepackage{fontspec}
\setmainfont{GFS Didot}
\setdefaultlanguage{greek}
\usepackage{tikz}

\begin{document}

{\tikz[remember picture,overlay] 
    \draw [fill,red!20] (current page.north west) rectangle
    +(0.20\paperwidth,-\paperheight);
    \tableofcontents}

\chapter*{Πρόλογος}
\addcontentsline{toc}{chapter}{Αντί Προλόγου}

\chapter*{Οδηγός Μελέτης}
\addcontentsline{toc}{chapter}{Οδηγός Μελέτης}

\part{ΑΛΓΕΒΡΑ}

\chapter{Αλγεβρικές Παραστάσεις}

\section{Πραγματικοί αριθμοί και πράξεις}

\section{Δυνάμεις πραγματικών αριθμών}

\section{Τετραγωνική ρίζα πραγματικού αριθμού}

\section{Μονώνυμα $\bullet$ Πολυώνυμα}

\chapter{Ταυτότητες $-$ Παραγοντοποίηση}

\section{Αξιοσημείωτες ταυτότητες}

\section{Παραγοντοποίηση}

\section{Ε.Κ.Π $\bullet$ Μ.Κ.Δ αλγεβρικών παραστάσεων}

\section{Ρητές αλγεβρικές παραστάσεις}

\section{Πρόσθεση $\bullet$ Αφαίρεση ρητών παραστάσεων}

\chapter{Εξισώσεις - Ανισώσεις}

\section{Η εξίσωση $\alpha x + \beta = 0 $}

\section{Εξίσωση δευτέρου βαθμού}

\section{Επίλυση εξίσωσης δεύτερου βαθμού με τύπο}

\section{Κλασματικές εξισώσεις}

\section{Διάταξη}

\chapter{Συστήματα γραμμικών εξισώσεων}

\section{Η έννοια της γραμμικής εξίσωσης}

\section{Γραμμικό σύστημα}

\part{ΓΕΩΜΕΤΡΙΑ $-$ ΤΡΙΓΩΝΟΜΕΤΡΙΑ}

\chapter{Γεωμετρία}

\section{Πρωτεύοντα - Δευτερεύοντα στοιχεία τριγώνου}

\section{Ίσα τρίγωνα}



\end{document}

Tolaso
  • 1,555

1 Answers1

1

Probably not the most effecient method, but it does work with my TeXLive 2023 and the hook mechanisms

\documentclass[12pt, a4paper, twoside, openany]{memoir}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amssymb}
\usepackage{polyglossia}
\usepackage{xltxtra}
\usepackage{fontspec}
\setmainfont{GFS Didot}
\setdefaultlanguage{greek}
\usepackage{tikz}

\cftinsertcode{pre-toc}{ \AddToHook{shipout/background}[toc-bg]{% \tikz[remember picture,overlay] \draw [fill,red!20] (current page.north west) rectangle +(0.20\paperwidth,-\paperheight); } }

\cftinsertcode{post-toc}{ \AddToHookNext{shipout/background}{ \RemoveFromHook{shipout/background}[toc-bg] } }

% add a hookline into the toc file it self \AddToHook{begindocument}{ \cftinserthook{toc}{pre-toc} } % add one at the very end as well, we cannot use \cftinserthook there % as it needs to be immediate \makeatletter \AddToHook{enddocument/afterlastpage}{ \immediate@protected@write@auxout{}{\string@writefile{toc}{\string\cftinsert\string{post-toc\string}}} } \makeatother

\begin{document}

\tableofcontents

... % the rest of the OPs example

daleif
  • 54,450