The table of content looks like this in the moment

1. Headline 1 ......... 1 % Shows only the page


But I want it to look like this

1. Headline 1 ......... 1.1 % <page>.<column>


Here is a minimal example, which has to be extended:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[a4paper, landscape, margin=3cm]{geometry}
\usepackage{lipsum}
\usepackage{multicol}

\begin{document}
\begin{multicols*}{5}

\tableofcontents
\lipsum[1-3]

\lipsum[4-6]

\end{multicols*}

\end{document}

• welcome to tex.se! it is not clear what you like to obtain. your mwe works (as expected), however, section out of multicols* start new page ... what is your real problem? Feb 9, 2018 at 20:26
• If you want to put the sections in one column and the subsections in another (overlappping) you coulod do it with paracol, but you will need to customize \l@section and \l@subsection to use \leftcolumn and \rightcolumn. Feb 9, 2018 at 20:57
• The table of contents shows only the pages, but I want to add the corresponding columns in which the section is defined to find them faster.
– brnk
Feb 9, 2018 at 21:07
• Are your readers really so helpless that they can't make the "leap" from the table of contents to a sectioning header on some unless both the page number and the column number are printed in the ToC?
– Mico
Feb 9, 2018 at 21:19
• I have really many subsections on each page since it's a cheatsheet for a lecture. So knowing the corresponding column would really help.
– brnk
Feb 9, 2018 at 21:34

The following does what you want. It needs a few runs (3) to display everything correct. The option colaction is necessary for the command \docolaction and for the patch to work.

New answer for arbitrary number of columns

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[colaction]{multicol}
\usepackage[left=1cm,right=1cm,top=1cm,bottom=1cm]{geometry}
\usepackage{etoolbox}

\makeatletter
\newcounter{brnk@col@count}
{%
{%
\protect\contentsline{#2}{#3}
{\thepage\ifnum\doublecol@number>0\relax.\string\brnk@cur@col\fi}%
}%
}
\def\brnk@patch@last
{%
\stepcounter{brnk@col@count}%
\protected@write\@auxout{}%
{%
\string\@writefile{toc}%
{\string\def\string\brnk@cur@col{\arabic{brnk@col@count}}}%
}%
}
\def\brnk@patch@else
{%
\ifmc@firstcol
\setcounter{brnk@col@count}{0}%
\fi
\brnk@patch@last
}
\def\brnk@patch@error
{%
\GenericError{}
{Patching of \string\mc@col@status@write\space failed}
{%
Make sure colaction was set as an option for multicol.%
\MessageBreak
Else you're screwed, don't use the code provided here.\MessageBreak%
}
{No further help available.}%
}
\pretocmd\mc@lastcol@status@write{\brnk@patch@last}{}{\brnk@patch@error}
\pretocmd\mc@col@status@write{\brnk@patch@else}{}{\brnk@patch@error}
\makeatother

\begin{document}
\begin{multicols*}{5}

\tableofcontents
\lipsum[1-2]

\lipsum[3]

\lipsum[4-7]

\subsection{Subsection 1}
\lipsum[8]
\subsection{Subsection 2}
\lipsum[9]
\end{multicols*}
\lipsum[5]
\begin{multicols*}{2}
\lipsum[6]
\end{multicols*}

\end{document}


Original answer for only 3 columns

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage[colaction]{multicol}

\makeatletter
\def\brnk@column{}%
\ifnum\doublecol@number>0
\docolaction
[5]
{\def\brnk@column{.1}}
{\def\brnk@column{.2}}
{\def\brnk@column{.3}}%
\fi
{\thepage\brnk@column}}}
\makeatother

\begin{document}
\begin{multicols*}{3}

\tableofcontents
\lipsum[1-2]

\lipsum[3]

\lipsum[4]
\end{multicols*}
\lipsum[5]
\begin{multicols*}{2}
\lipsum[6]
\end{multicols*}

\end{document}


Resulting ToC:

• I looked up the docolaction command in the documentation and it states that it's only for three columns (left, middle, right). But I have 5 columns. I just used three columns in the minimal example to make the document easier to read.
– brnk
Feb 10, 2018 at 13:13
• Another problem is that my subsections are defined inside the multicols in a different environment. Is it possible to check whether the multicols environment is a parent instead of checking whether it is the current environment?
– brnk
Feb 10, 2018 at 13:31
• @brnk the edit uses a better test. For the support of more than 3 columns I can't do anything right now, but will get back at it later this day (hopefully). Feb 10, 2018 at 13:55
• @brnk sorry to disappoint you. A solution for 5 columns seems possible, but I'm neither willing nor have the time to create and test it. You could send a feature request to the maintainers of multicol and hope for the best, though. Feb 10, 2018 at 23:35
• @brnk sorry to disappoint you again, but I did create some code which works for 5 columns (in fact it should work for an arbitrary number of columns). I didn't test it too much, so it might not be perfectly stable. Feb 11, 2018 at 17:06