7

I am writing a 4-5 pages article document, and a full-width, traditional table of contents really feels over the top and would take up too much space, but I still feel a toc is really great to show the document structure. Ideally, I would like to have my toc framed in the top left of the article (with the content starting inmmediately to its right), just like many journals or even wikipedia does.

So far, I've attempted to achieve that with columns, minipage and wrapfigure, but none of those solutions is really satisfying (I've been using latex for some time now, but I always let him do the job, so I'm not that familiar with manually doing stuff).

The main issues are getting the starting content to properly and automatically wrap around the toc (didn't achieve with colums or minipage), and getting the starting content and the toc correctly aligned and clean (didn't achieve with wrapfigure).

Here's my best attempt so far:

\documentclass[a4paper]{article}
\usepackage[frenchb]{babel}
\usepackage[utf8]{inputenc}
\usepackage{textcomp}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}

\usepackage{lipsum}

\usepackage{float}                            %floats and figures
\usepackage{graphicx}                         %load images
\usepackage{wrapfig}                          %figures within text
\usepackage{subcaption}                       %multiple subfigures and subcaptions

\usepackage{amsmath}

\begin{document}
\begin{center}
  {\LARGE Rapport de visite d'entreprise}\\
  {\includegraphics[width=.3\textwidth]{ABB.jpg}}\\
  Nathan Dwek\\
  \today
\end{center}

\begin{wrapfigure}{L!}{.5\textwidth}
  \tableofcontents
\end{wrapfigure}



\section{Le groupe ABB}
\lipsum[1]

\section{ABB Jumet}

\lipsum[2]

\section{La ligne de production de condensateurs}


\subsection{La métallisation}

\subsection{Le choupage\label{choupage}}


\subsection{Traitements de finition}


\section{Systèmes à condensateurs}

\subsection{Condensateurs en triphasé}

\subsection{Armoires à condensateurs}

\end{document}          

and the result:

as you can see the section title is out of place (should be right above starting text) and the toc has a weird horizontal alignment (see @Keks Dose 's answer for this part)

Any hints?

Thank you in advance

2 Answers 2

3

You're very nearly there! The main problem you're facing is discussed in Strange space left above wrapfig figures and Wrapped figure diverges from text level after sections. As such the important part of my code is

\section{Le groupe ABB}
\begingroup
\setlength\intextsep{0pt} %<---- IMPORTANT
\begin{wrapfigure}{l}{.5\textwidth}
....
\end{wrapfigure}
\lipsum[1]
\endgroup

You have many choices to help with the framing; I like the tcolorbox package or else the mdframed package.

screenshot

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[a4paper]{article}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{tcolorbox}
\tcbuselibrary{skins}

\begin{document}
\begin{center}
    {\LARGE Rapport de visite d'entreprise}\\
    {\includegraphics[width=.3\textwidth]{ABB.jpg}}\\
    Nathan Dwek\\
    \today
\end{center}

\section{Le groupe ABB}
\begingroup
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}{.5\textwidth}
    \begin{tcolorbox}[
            enhanced,fonttitle=\bfseries\Large,
            colback=gray!10,colframe=gray,%colframe=red!50!black,
            drop fuzzy shadow,
        title={Contents},]
        \makeatletter
        \@starttoc{toc}
        \makeatother
        \vspace{.5cm}
    \end{tcolorbox}
\end{wrapfigure}
\lipsum[1]
\endgroup

\section{ABB Jumet}

\lipsum[2]

\section{La ligne de production de condensateurs}


\subsection{La métallisation}

\subsection{Le choupage\label{choupage}}


\subsection{Traitements de finition}


\section{Systèmes à condensateurs}

\subsection{Condensateurs en triphasé}

\subsection{Armoires à condensateurs}

\end{document}

Update following comment

If you want the section next to the toc, you can trick wrapfig into believing there is a paragraph there using, for example

...
\end{wrapfigure}
\paragraph{}
\unskip
\section{Le groupe ABB}
\lipsum[1]

You can use the titlesec package to help with spacing surrounding the heading- a final result is:

screenshot

Here's the complete code to play with at your leisure.

% arara: pdflatex
% !arara: indent: {overwrite: yes}
\documentclass[a4paper]{article}
\usepackage{lipsum}
\usepackage[demo]{graphicx}
\usepackage{wrapfig}
\usepackage{tcolorbox}
\usepackage{titlesec}
\tcbuselibrary{skins}

% spacing around headings
% From the titlesec package
% \titlespacing{command}{left spacing}{before spacing}{after spacing}[right]
% spacing: how to read {12pt plus 4pt minus 2pt}
%           12pt is what we would like the spacing to be
%           plus 4pt means that TeX can stretch it by at most 4pt
%           minus 2pt means that TeX can shrink it by at most 2pt
%       This is one example of the concept of, 'glue', in TeX
\titlespacing\section{0pt}{5pt plus 0pt minus 2pt}{5pt plus 2pt minus 2pt}

\begin{document}
\begin{center}
    {\LARGE Rapport de visite d'entreprise}\\
    {\includegraphics[width=.3\textwidth]{ABB.jpg}}\\
    Nathan Dwek\\
    \today
\end{center}

\begingroup
\titlespacing\section{0pt}{-5pt plus 0pt minus 2pt}{5pt plus 2pt minus 2pt}
\titlespacing{\paragraph}{0pt}{0pt plus .1ex minus .2ex}{0pt}
\setlength\intextsep{0pt}
\begin{wrapfigure}{l}{.5\textwidth}
    \begin{tcolorbox}[
            enhanced,fonttitle=\bfseries\Large,
            colback=gray!10,colframe=gray,%colframe=red!50!black,
            drop fuzzy shadow,
        title={Contents},]
        \makeatletter
        \@starttoc{toc}
        \makeatother
    \end{tcolorbox}
\end{wrapfigure}
\paragraph{}
\unskip
%\vspace*{-2\parskip}
\section{Le groupe ABB}
\lipsum[1]
\endgroup

\section{ABB Jumet}

\lipsum[2]

\section{La ligne de production de condensateurs}


\subsection{La métallisation}

\subsection{Le choupage\label{choupage}}


\subsection{Traitements de finition}


\section{Systèmes à condensateurs}

\subsection{Condensateurs en triphasé}

\subsection{Armoires à condensateurs}

\end{document}
2
  • Maybe I should've precised it in my mwe, but my major concern was getting the section title right above where the text starts, and not above the toc. Upvote for the horizontal alignment fix though.
    – nathdwek
    Commented Feb 23, 2014 at 21:21
  • @nathdwek sure no problem- see the update
    – cmhughes
    Commented Feb 24, 2014 at 0:43
2

I'm not sure I clearly understood your wish, but what about this:

\documentclass[a4paper]{article}
\usepackage[frenchb]{babel}
\usepackage[utf8]{inputenc}
\usepackage{textcomp, multicol}
\usepackage[T1]{fontenc}
\usepackage{fixltx2e}

\usepackage{lipsum}

% \usepackage{float}                            %floats and figures
% \usepackage{graphicx}                         %load images
% \usepackage{wrapfig}                          %figures within text
% \usepackage{subcaption}                       %multiple subfigures and subcaptions

% \usepackage{amsmath}

\begin{document}
\begin{center}
  {\LARGE Rapport de visite d'entreprise}\\
%  {\includegraphics[width=.3\textwidth]{ABB.jpg}}\\
  Nathan Dwek\\
  \today
\end{center}

\begin{multicols}{2}
  \tableofcontents

\columnbreak



\section{Le groupe ABB}
\lipsum[1]
\end{multicols}

\section{ABB Jumet}

\lipsum[2]

\section{La ligne de production de condensateurs}


\subsection{La métallisation}

\subsection{Le choupage\label{choupage}}


\subsection{Traitements de finition}


\section{Systèmes à condensateurs}

\subsection{Condensateurs en triphasé}

\subsection{Armoires à condensateurs}

\end{document} 

In your real document you'd have to play around with the placement of \columnbreak.

enter image description here

1
  • As said in my question, I tried this solution, and it indeed looks good, my only issue is that I'd have to, as you say, play around with \columnbreak to adjust relative size.
    – nathdwek
    Commented Feb 23, 2014 at 21:07

You must log in to answer this question.

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