11

I have a question regarding \minitoc, I want to change the layout for \minitoc inside my MSc thesis. The document is written using a single column, but I want to have the content within the \minitoc in two columns (I think is more elegant than in one).

I'll create an ASCII example for you:

CHAPTER 1

INTRODUCTION
________________________________________
1.1 aims               1.3 bla bla

1.2 background         1.4 bla bla
________________________________________

I guess it's possible because I saw that before, but I'm getting crazy trying to find how to do that.

1
  • Would using the titletoc package (instead of minitoc) be an option for you? Jul 31, 2012 at 22:49

1 Answer 1

9

I don't know if a two column partial toc is a good idea (long titles) might look odd. Anyway, below there's a possible solution. Some remarks:

  1. I used titletoc instead of minitoc.
  2. To produce the horizontal rules around the nulticol environment, I borrowed some code by Werner from his answer to Horizontal lines touching the multicol column separator rule.
  3. I used the titletoc package to give a different formatting to the partial ToC entries (font size was set to \small and page numbers were italicized).
  4. The titlesec package was used to reduce the vertical space between the chapter title and the partial ToC.
  5. I decided to add a vertical rule between the columns in the partial ToC to prevent page numbers from the left column to interfere with sectional unit numbers on the right column. In the third variation of the code (below), I suppressed the page numbers so the vertical rule was also removed.

The first variation:

    \documentclass{book}
    \usepackage{titletoc}
    \usepackage{etoolbox}
    \usepackage{multicol}
    \usepackage{lipsum}

    % start of Werner's code
    % https://tex.stackexchange.com/a/37732/3954
    \makeatletter
    \patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
    \newenvironment{multicolumns}[1]
      {% \begin{multicolumns}{<cols>}
       \par\nobreak % don't break a page here
       \kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
       {\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
       \kern-\multicolsep % space after the rule
       \nointerlineskip % no additional space after the rule
       \begin{multicols}{#1}
      }
      {% \end{multicolumns}
       \end{multicols}%
       \par\nobreak % don't break a page here
       \kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
       {\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
       \kern\multicolsep % space after the rule
       \nointerlineskip % no additional space after the rule
      }
    \makeatother
    % end of Werner's code

    \titlecontents{lsection}
      [2.3em]{\small}{\contentslabel{2.3em}}
      {\hspace*{-2.3em}}
      {\hfill\itshape\contentspage}
    \titlecontents{lsubsection}
      [4.6em]{\small}{\contentslabel{2.3em}}
      {\hspace*{-2.3em}}
      {\hfill\itshape\contentspage}

    \setlength\columnseprule{1pt}

    \newcommand\buildptc{%
      \startcontents[chapter]\vspace*{-2.5\baselineskip} 
      \begin{multicolumns}{2}
      \printcontents[chapter]{l}{1}{}
      \end{multicolumns}%
    }

    \begin{document}
    \tableofcontents

    \chapter{Test Chapter One}
    \buildptc
    \section{Test Section One One}
    \lipsum[2-5]
    \subsection{Test Subsection One One One}
    \lipsum[2]
    \subsection{Test Subsection One One Two}
    \lipsum[2]
    \subsection{Test Subsection One One Three}
    \lipsum[2]
    \section{Test Section One Two}
    \lipsum[2]
    \subsection{Test Subsection One Two One}
    \lipsum[2]
    \subsection{Test Subsection One Two Two}
    \lipsum[2]
    \subsection{Test Subsection One Two Three}
    \lipsum[2]
    \section{Test Section One Three}
    \lipsum[2]
    \subsection{Test Subsection One Three One}
    \lipsum[2]
    \subsection{Test Subsection One Three Two}
    \lipsum[2]
    \subsection{Test Subsection One Three Three}
    \lipsum[2]

    \end{document}

enter image description here

Here's now a variation showing only sections in the partial ToCs:

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{lipsum}

% start of Werner's code
% https://tex.stackexchange.com/a/37732/3954
\makeatletter
\patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
\newenvironment{multicolumns}[1]
  {% \begin{multicolumns}{<cols>}
   \par\nobreak % don't break a page here
   \kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
   {\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
   \kern-\multicolsep % space after the rule
   \nointerlineskip % no additional space after the rule
   \begin{multicols}{#1}
  }
  {% \end{multicolumns}
   \end{multicols}%
   \par\nobreak % don't break a page here
   \kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
   {\columnseprulecolor\hrule height \columnseprule} % the rule, same width as \columnseprule
   \kern\multicolsep % space after the rule
   \nointerlineskip % no additional space after the rule
  }
\makeatother
% end of Werner's code

\titlecontents{lsection}
  [2.3em]{\small}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {\hfill\itshape\contentspage}
\titlecontents{lsubsection}
  [4.6em]{\small}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {\hfill\itshape\contentspage}

\setlength\columnseprule{1pt}

\newcommand\buildptc{%
  \startcontents[chapter]
  \begin{multicolumns}{2}
  \printcontents[chapter]{l}{0}{\setcounter{tocdepth}{1}}
  \end{multicolumns}%
}

\begin{document}
\tableofcontents

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing{\chapter}
  {0pt}{40pt}{-10pt}

\chapter{Test Chapter One}
\buildptc
\section{Test Section One One}
\lipsum[2-5]
\subsection{Test Subsection One One One}
\lipsum[2]
\subsection{Test Subsection One One Two}
\lipsum[2]
\subsection{Test Subsection One One Three}
\lipsum[2]
\section{Test Section One Two}
\lipsum[2]
\subsection{Test Subsection One Two One}
\lipsum[2]
\subsection{Test Subsection One Two Two}
\lipsum[2]
\subsection{Test Subsection One Two Three}
\lipsum[2]
\section{Test Section One Three}
\lipsum[2]
\subsection{Test Subsection One Three One}
\lipsum[2]
\subsection{Test Subsection One Three Two}
\lipsum[2]
\subsection{Test Subsection One Three Three}
\lipsum[2]
\section{Test Section One Four}
\lipsum[2-5]
\subsection{Test Subsection One Four One}
\lipsum[2]
\subsection{Test Subsection One Four Two}
\lipsum[2]
\section{Test Section One Five}
\lipsum[2-5]
\subsection{Test Subsection One Five One}
\lipsum[2]
\subsection{Test Subsection One Five Two}
\lipsum[2]

\end{document}

enter image description here

If no page numbers are to be shown in the partial ToCs, the vertical rule of the above examples is now superfluous and we could have:

\documentclass{book}
\usepackage{titlesec}
\usepackage{titletoc}
\usepackage{etoolbox}
\usepackage{multicol}
\usepackage{lipsum}

% start of Werner's code
% https://tex.stackexchange.com/a/37732/3954
\makeatletter
\patchcmd{\endmulticols}{\par}{\par\xdef\@@tpd{\the\prevdepth}}{}{}
\newenvironment{multicolumns}[1]
  {% \begin{multicolumns}{<cols>}
   \par\nobreak % don't break a page here
   \kern\dimexpr\the\prevdepth+\multicolsep\relax % don't take into account the depth of the preceding line + #2
   {\columnseprulecolor\hrule height 0.4pt} % the rule, same width as \columnseprule
   \kern-\multicolsep % space after the rule
   \nointerlineskip % no additional space after the rule
   \begin{multicols}{#1}
  }
  {% \end{multicolumns}
   \end{multicols}%
   \par\nobreak % don't break a page here
   \kern\dimexpr\@@tpd-\multicolsep\relax % don't take into account the depth of the preceding line + #2
   {\columnseprulecolor\hrule height 0.4pt} % the rule, same width as \columnseprule
   \kern\multicolsep % space after the rule
   \nointerlineskip % no additional space after the rule
  }
\makeatother
% end of Werner's code

\titlecontents{lsection}
  [2.3em]{\small}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {}
\titlecontents{lsubsection}
  [4.6em]{\small}{\contentslabel{2.3em}}
  {\hspace*{-2.3em}}
  {}

\newcommand\buildptc{%
  \startcontents[chapter]
  \begin{multicolumns}{2}
  \printcontents[chapter]{l}{0}{\setcounter{tocdepth}{1}}
  \end{multicolumns}%
}

\begin{document}
\tableofcontents

\titleformat{\chapter}[display]
  {\normalfont\huge\bfseries}{\chaptertitlename\ \thechapter}{20pt}{\Huge}
\titlespacing{\chapter}
  {0pt}{40pt}{-10pt}

\chapter{Test Chapter One}
\buildptc
\section{Test Section One One}
\lipsum[2-5]
\subsection{Test Subsection One One One}
\lipsum[2]
\subsection{Test Subsection One One Two}
\lipsum[2]
\subsection{Test Subsection One One Three}
\lipsum[2]
\section{Test Section One Two}
\lipsum[2]
\subsection{Test Subsection One Two One}
\lipsum[2]
\subsection{Test Subsection One Two Two}
\lipsum[2]
\subsection{Test Subsection One Two Three}
\lipsum[2]
\section{Test Section One Three}
\lipsum[2]
\subsection{Test Subsection One Three One}
\lipsum[2]
\subsection{Test Subsection One Three Two}
\lipsum[2]
\subsection{Test Subsection One Three Three}
\lipsum[2]
\section{Test Section One Four}
\lipsum[2-5]
\subsection{Test Subsection One Four One}
\lipsum[2]
\subsection{Test Subsection One Four Two}
\lipsum[2]
\section{Test Section One Five}
\lipsum[2-5]
\subsection{Test Subsection One Five One}
\lipsum[2]
\subsection{Test Subsection One Five Two}
\lipsum[2]

\end{document}

enter image description here

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .