I am using \titleformat
(together with titlesec
and titletoc
packages) to configure the aspect of the section titles. Since I needed a solid framed title I tried:
\documentclass{article}
\usepackage[svgnames]{xcolor}
\usepackage[explicit]{titlesec}
\usepackage{titletoc}
\usepackage{multicol}
\usepackage{lipsum}
\titleformat{\section}
[block]
{
\LARGE\sffamily\color{white}
}
{}
{0pt}
{\hspace{-20pt}\colorbox{blue}{\parbox{\textwidth}{
\strut
\hspace{10pt}
#1.
\hfill
}}}
\begin{document}
%\begin{minipage}{\textwidth}
\begin{multicols}{2}
\tableofcontents
\end{multicols}
%\end{minipage}
\section{First section}
\lipsum[0]
\subsection{Subsection 1.1}
\lipsum[1]
\subsubsection{Subsubsection 1.1.1}
\lipsum[2]
\section{Second section}
The second section begins here\ldots
\subsection{Subsection 2.1}
\lipsum[4]
\subsubsection{Subsubsection 2.1.1}
\lipsum[5]
\section{Third section}
\lipsum[6]
\end{document}
which seems to work fine except for the table of contents (which I want in two columns). In this case, the second column of the table of contents invades the space of the frame (a behavior which, of course, I would like to avoid). I tried to put the two-column(ed) toc within a minipage but that doesn't seem to work either.
Any advice on how to fix this problem?
Thanks in advance!