# Move mini table of contents to top corner of page part 2

This question is building of the solution presented here.

I would now like the contents to appear on opposite sides based on the page number, i.e. odd or even. I tried using the commands \node[above right=\topmargin, anchor=north east, but I did not get the desired results. Can you assist me in getting the mini TOC to show up on alternate sides based on the page number that the chapter starts?

Here is the code developed by Cragfelt:

\documentclass{report}

\RequirePackage{polyglossia}
\RequirePackage{calc}
\RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}
\RequirePackage{amsmath, amsfonts, amssymb}
\RequirePackage{ragged2e}
\RequirePackage{eso-pic}
\RequirePackage{fancyhdr}
\RequirePackage{marginfix}
\RequirePackage{titletoc}
\RequirePackage{mdframed}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{changepage}

\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{\errmessage{Cannot patch \string\part}}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\setlength{\marginparpush}{1.5\baselineskip}

\RequirePackage[
xetex,
a4paper,
%   showframe,
twoside,
top=27mm,
bottom=27mm,
inner=20mm,
outer=20mm,
ignorefoot,
includemp,
marginparwidth=52mm,
marginparsep=8mm,
footskip=14mm,
]{geometry}

% Commands for changing the page layout mid-document
\newcommand{\symmetricalPage}{
\fancyhfoffset[OR, EL]{0mm}
\newgeometry{
top=20mm,
bottom=20mm,
inner=20mm,
outer=20mm,
ignorefoot,
nomarginpar,
footskip=10mm,
}
}
\newcommand{\asymmetricalPage}{
\restoregeometry
\fancyhfoffset[OR, EL]{\marginparsep + \marginparwidth}
}

\setlength{\columnsep}{\marginparsep}

% Saving some length as commands
\newlength{\wholeMargin}
\setlength{\wholeMargin}{\marginparwidth}

\newlength{\wholeWidth}
\setlength{\wholeWidth}{\textwidth}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Titling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoc}
\RequirePackage{titlesec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Hyper-references
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{hyperref}
\hypersetup{
pdftoolbar=false,
pdffitwindow=false,
pdfborder={0 0 0},
pdfcreator=LaTeX,
urlcolor=blue,
citecolor=blue,
filecolor=blue,
}

\usepackage{lipsum}

\usepackage{tikz}

\usepackage{titletoc}

\usepackage{calc}

\usepackage[]{titlesec}

\definecolor{lightGrey}{gray}{0.94}

\colorlet{chpnumbercolor}{blue}
\makeatletter
\let\oldl@chapter\l@chapter
\def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{black}{\textbf{#2}}}}

\let\old@dottedcontentsline\@dottedtocline
\def\@dottedtocline#1#2#3#4#5{%
\old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{black}{#5}}}}
\makeatother

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{%
\noindent\hspace{-2cm}%
\colorlet{chpnumbercolor}{white}%
\begin{tikzpicture}[remember picture, overlay, transform shape]
\node[above left=\topmargin, anchor=north west, rounded corners, align=left, fill=lightGrey, blur shadow={shadow blur steps=5}, inner sep=5mm] at (current page.north west)
{%
\color{black}%
\begin{minipage}{8cm}%minipage trick
\hfill\rule{\linewidth}{.5mm}
\printcontents[chapters]{}{1}{}
\hfill\rule{\linewidth}{.5mm}
\end{minipage}
};
\end{tikzpicture}}

\begin{document}

\chapter{Introduction}
\startcontents[chapters]
\printmyminitoc

\section{Lorem Ipsum Dolor}
\lipsum[2]
\subsection{Test Subsection}
\lipsum[1]

\section{Nam dui ligula}

\lipsum[3]

\chapter{Content}
\startcontents[chapters]
\printmyminitoc

\lipsum[2]
\lipsum[3]

\section{First Section}
\subsection{Subsection}

\lipsum[2]

\lipsum[2]

\lipsum[3]

\end{document}

• If you get rid of above left=\topmargin,  then the minitoc no longer gets swallowed. But I am wondering if you really want to add the minitoc by hand or am I missing something? (I am asking because you are loading eso-pic anyaway.) – user121799 Aug 8 '18 at 1:46

Just in case you want to put the minitoc automatically (rather than by hand), since you are loading eso-pic anyway, I could not resist.

\documentclass{report}

\RequirePackage{polyglossia}
\RequirePackage{calc}
\RequirePackage[usenames,dvipsnames,svgnames,table]{xcolor}
\RequirePackage{amsmath, amsfonts, amssymb}
\RequirePackage{ragged2e}
\RequirePackage{eso-pic}
\RequirePackage{fancyhdr}
\RequirePackage{marginfix}
\RequirePackage{titletoc}
\RequirePackage{mdframed}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Layout
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{changepage}

\patchcmd{\part}{\thispagestyle{plain}}{\thispagestyle{empty}}{}{\errmessage{Cannot patch \string\part}}

\setlength{\parindent}{0pt}
\setlength{\parskip}{\baselineskip}
\setlength{\marginparpush}{1.5\baselineskip}

\RequirePackage[
xetex,
a4paper,
%   showframe,
twoside,
top=27mm,
bottom=27mm,
inner=20mm,
outer=20mm,
ignorefoot,
includemp,
marginparwidth=52mm,
marginparsep=8mm,
footskip=14mm,
]{geometry}

% Commands for changing the page layout mid-document
\newcommand{\symmetricalPage}{
\fancyhfoffset[OR, EL]{0mm}
\newgeometry{
top=20mm,
bottom=20mm,
inner=20mm,
outer=20mm,
ignorefoot,
nomarginpar,
footskip=10mm,
}
}
\newcommand{\asymmetricalPage}{
\restoregeometry
\fancyhfoffset[OR, EL]{\marginparsep + \marginparwidth}
}

\setlength{\columnsep}{\marginparsep}

% Saving some length as commands
\newlength{\wholeMargin}
\setlength{\wholeMargin}{\marginparwidth}

\newlength{\wholeWidth}
\setlength{\wholeWidth}{\textwidth}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Titling
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\usepackage{etoc}
\RequirePackage{titlesec}

%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%       Hyper-references
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\RequirePackage{hyperref}
\hypersetup{
pdftoolbar=false,
pdffitwindow=false,
pdfborder={0 0 0},
pdfcreator=LaTeX,
urlcolor=blue,
citecolor=blue,
filecolor=blue,
}

\usepackage{lipsum}

\usepackage{tikz}

\usepackage{titletoc}

\usepackage{calc}

\usepackage[]{titlesec}

\definecolor{lightGrey}{gray}{0.94}

\colorlet{chpnumbercolor}{blue}
\makeatletter
\let\oldl@chapter\l@chapter
\def\l@chapter#1#2{\oldl@chapter{#1}{\textcolor{black}{\textbf{#2}}}}

\let\old@dottedcontentsline\@dottedtocline
\def\@dottedtocline#1#2#3#4#5{%
\old@dottedcontentsline{#1}{#2}{#3}{#4}{{\textcolor{black}{#5}}}}
\makeatother

%command to print the acutal minitoc
\newcommand{\printmyminitoc}{%
\noindent\hspace{-2cm}%
\colorlet{chpnumbercolor}{white}%
\begin{tikzpicture}[remember picture, overlay, transform shape]
\node[above left=\topmargin, anchor=north west, rounded corners, align=left, fill=lightGrey, blur shadow={shadow blur steps=5}, inner sep=5mm] at (current page.north west)
{%
\color{black}%
\begin{minipage}{8cm}%minipage trick
\hfill\rule{\linewidth}{.5mm}
\printcontents[chapters]{}{1}{}
\hfill\rule{\linewidth}{.5mm}
\end{minipage}
};
\end{tikzpicture}}

\ifodd\value{page}
\printmyminitoc %<- move this below \else if you want the minitoc on even pages
\else
\fi
}

\begin{document}

\chapter{Introduction}
\startcontents[chapters]

\section{Lorem Ipsum Dolor}
\lipsum[2]
\subsection{Test Subsection}
\lipsum[1]

\section{Nam dui ligula}

\lipsum[3]

\chapter{Content}
\startcontents[chapters]

\lipsum[2]
\lipsum[3]

\section{First Section}
\subsection{Subsection}

\lipsum[2]

\lipsum[2]

\lipsum[3]

\end{document}