1

I am using tikz to customise my miniToc at each chapter. however I am having problems with the alignment of the TOC inside the node.

I have used \begin{flushright} inside the minipage, also to use \contentsmargin{0cm} before the \printcontents command, also \noindent. However, I have not gotten the desire result.

This is what I am after:

enter image description here

enter image description here

This is the code I am using for the customisation of the minitoc:

\newcommand{\printmyminitoc}{%
    \begin{center}%
        \begin{tikzpicture}%
            \node[anchor=south,inner ysep=12.5pt,inner xsep=20pt,align=flush left] (s) at (current page.south) {
                \begin{minipage}[c][][t]{0.90\textwidth}
                    \begin{flushright}
                        \renewcommand{\baselinestretch}{1.2}\selectfont
                        \startcontents[chapters]
                        \printcontents[chapters]{}{1}{}
                     \end{flushright}
                \end{minipage}
             };
            \draw[bottom color = blue!80, top color= blue!10, draw=blue!90,fill opacity=0.1,decorate, decoration={random steps,segment length=3pt,amplitude=1pt},line width=1.25pt] (s.north west) rectangle (s.south east);
        \end{tikzpicture}%
    \end{center}%
    }

Could I get any guidance on how to define the correct alignment?

Here is the MWE:

\documentclass[twoside,12pt,openright]{scrbook}
\usepackage[a4paper]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage[sfdefault]{universalis}
\usepackage{titletoc}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{decorations, decorations.pathmorphing, decorations.pathreplacing}
\usepackage[linkcolor=black,colorlinks=true]{hyperref}
%% command to print the actual minitoc ---------------------------------------------
\newcommand{\printmyminitoc}{%
    \begin{center}%
        \begin{tikzpicture}%
            \node[anchor=south,inner ysep=12.5pt,inner xsep=20pt,align=flush left] (s) at (current page.south) {
                \begin{minipage}[c][][t]{0.90\textwidth}
                    \begin{flushright}
                        \renewcommand{\baselinestretch}{1.2}\selectfont
                        \startcontents[chapters]
                        \printcontents[chapters]{}{1}{}
                     \end{flushright}
                \end{minipage}
             };
            \draw[bottom color = blue!80, top color= blue!10, draw=blue!90,fill opacity=0.1,decorate, decoration={random steps,segment length=3pt,amplitude=1pt},line width=1.25pt] (s.north west) rectangle (s.south east);
        \end{tikzpicture}%
    \end{center}%
    }

\begin{document} \renewcommand{\chaptermark}[1]{\markboth{#1}{}} \frontmatter \pagenumbering{roman} \pagestyle{empty}
\setcounter{tocdepth}{2} \tableofcontents
\cleardoublepage \mainmatter \pagenumbering{arabic} \setcounter{page}{1} \pagestyle{headings} \chapter{Intro} \printmyminitoc \lipsum[1-3] \section{Intro 1 - Section 1} \lipsum[1-3] \section{Intro 1 - Section 2} \lipsum[1-3] \section{Intro 1 - Section 3} \lipsum[1-3] \section{Intro 1 - Section 4} \lipsum[1-3] \section{Intro 1 - Section 5} \lipsum[1-3] \chapter{Literature} \printmyminitoc \lipsum[1-3] \section{Literature - Section 1} \lipsum[1-3] \section{Literature - Section 2} \lipsum[1-3] \section{Literature - Section 3} \lipsum[1-3] \section{Literature - Section 4} \lipsum[1-3] \section{Literature - Section 5} \lipsum[1-3] \end{document}

1 Answers1

2

Create a new section and subsection format (named xsection and xsubsection) using \titlecontents from titletoc and adjust left (the left margin from the left page margin)

\titlecontents{⟨section⟩}[⟨left⟩]{⟨above-code⟩}{⟨numbered-entry-format⟩}{⟨numberless-entry-format⟩}
{⟨filler-page-format⟩}[⟨below-code⟩]

Then use \printcontents[chapters]{x}{1}{} to produce the partial ToC.

a

\documentclass[twoside,12pt,openright]{scrbook}
\usepackage[a4paper]{geometry}
\usepackage[dvipsnames]{xcolor}
\usepackage[sfdefault]{universalis}
\usepackage{titletoc}
\usepackage{lipsum}
\usepackage{tikz}
\usetikzlibrary{decorations, decorations.pathmorphing, decorations.pathreplacing}
\usepackage[linkcolor=black,colorlinks=true]{hyperref}
%% command to print the actual minitoc ---------------------------------------------
\newcommand{\printmyminitoc}{%
    \begin{center}%
        \begin{tikzpicture}%
            \node[anchor=south,inner ysep=12.5pt,inner xsep=20pt,align=flush left] (s) at (current page.south) {
                \begin{minipage}[c][][t]{0.90\textwidth}
                    \begin{flushright}
                        \renewcommand{\baselinestretch}{1.2}\selectfont
                        \startcontents[chapters]
                        \printcontents[chapters]{x}{1}{}% changed <<<<<<<<<<<<<<<<
                    \end{flushright}
                \end{minipage}
            };
            \draw[bottom color = blue!80, top color= blue!10, draw=blue!90,fill opacity=0.1,decorate, decoration={random steps,segment length=3pt,amplitude=1pt},line width=1.25pt] (s.north west) rectangle (s.south east);
        \end{tikzpicture}%
    \end{center}%
}

%***************************% added <<<<<<<<<<<< from https://tex.stackexchange.com/a/66346/161015 \titlecontents{xsection}[1em]{}{\contentslabel{2.3em}} {} {\titlerule[1pc]{.}\contentspage}

\titlecontents{xsubsection}[4.2em]{}{\contentslabel{3.2em}} {} {\titlerule[1pc]{.}\contentspage} %*********************************

\begin{document} \renewcommand{\chaptermark}[1]{\markboth{#1}{}} \frontmatter \pagenumbering{roman} \pagestyle{empty}
\setcounter{tocdepth}{2} \tableofcontents
\cleardoublepage \mainmatter \pagenumbering{arabic} \setcounter{page}{1} \pagestyle{headings} \chapter{Intro} \printmyminitoc \lipsum[1-3] \section{Intro 1 - Section 1} \lipsum[1-3] \subsection{Intro 1 -Sub Section 1} \lipsum[1-3] \section{Intro 1 - Section 3} \lipsum[1-3] \section{Intro 1 - Section 4} \lipsum[1-3] \section{Intro 1 - Section 5} \lipsum[1-3] \chapter{Literature} \printmyminitoc \lipsum[1-3] \section{Literature - Section 1} \lipsum[1-3] \section{Literature - Section 2} \lipsum[1-3] \section{Literature - Section 3} \lipsum[1-3] \section{Literature - Section 4} \lipsum[1-3] \section{Literature - Section 5} \lipsum[1-3] \end{document}

From remove section indentation in partial ToC

Simon Dispa
  • 39,141