# Using reledmac with multicol (two column footnotes in two column document)

I'm trying to typeset footnotes using reledmac in a twocolumned document (based on multicol). For simplicity, let's say that I use only one series of 'familiar footnotes' in reledmac, but these footnotes are double-columned so that the weight of their vertical space needs to be counted only single, not double.

I'm trying to patch the multicol package accordingly, but there are often weird corner cases in which a footnote lands on the wrong page (one page before its anchor in the text). In this case, multicol posts the warning "I moved some lines to the next page. Footnotes on page x might be wrong on input line xx."

I wonder: Did I do anything wrong (or incomplete) in patching? Does anyone know how I could improve the following MWE?

\documentclass{scrbook}
\setlength{\parskip}{0pt}
\RequirePackage{polyglossia}
\setmainlanguage{latin}

\RequirePackage{multicol}
\RequirePackage{reledmac}
\newseries{T}

\arrangementX[T]{twocol}
\setlength{\skip\footinsT}{1\baselineskip plus 10mm}%
\hsizetwocolX[T]{75mm}
\let\footnote\footnoteT

%%%%%%%%%% patching multicol.sty for twocolumn footnotes %%%%%%%%%
\makeatletter
\count\footinsT1000
\def\init@mult@footins{%
\count\footinsT1000
}
\def\reinsert@footnotes{\ifvoid\footinsT\else
\insert\footinsT{}\fi}
\patchcmd\multi@column@out{\divide\skip\footins\col@number}{}{}{}
\patchcmd\multi@column@out{\footins}{\footinsT}{}{}
\patchcmd\multi@column@out{\footins}{\footinsT}{}{}
\def\leave@mult@footins{%
}
\makeatother

\usepackage{lipsum}

\begin{document}

\mainmatter
\lipsum*[3]\footnote{Fn 1}

\lipsum*[3]\footnote{Fn 2}

\lipsum*[3]\footnote{Fn 3}

\lipsum*[3]\footnote{Fn 4}

\lipsum*[5]%\footnote{Fn 5}

\lipsum*[6]\footnote{Fn 5}%\footnote{Fn 6}

\lipsum*[7]\footnote{Fn 7}

\lipsum*[8]\footnote{Fn 8}

\lipsum*[9]\footnote{Fn 9}

\lipsum*[10]\footnote{Fn 10}

\lipsum*[6]\footnote{Fn 5}%\footnote{Fn 6}

\lipsum*[7]\footnote{Fn 7}
\end{multicols}
\end{document}

This produces the corner case where you see the error (misplaced footnote 4):

Addendum: I'm aware that multicol was not designed for double-columned footnotes and that this is a hard problem to solve – this is mentioned in so many posts on this matter. So I'm not asking for the perfect solution but for any ideas what I could do better in my patching to improve the result. The MWE I gave above does already deliver perfect results in a majority of cases, but maybe someone with more insights into the internal magic of multicol can say if there is another tweak I might add.

• multicol doesn't support two column footnotes and it is not simple to patch it to do so, because of the way it balances columns you would have to take account of the footnote space in multiple parts of the balancing column. it is not supported because it's not easily feasible with the current structure, not just because the feature hadn't been considered. Apr 23 '18 at 20:40

Double-columned footnotes with double-columned text are a topic that is relevant to quite a few people out there. Yet there is no LaTeX-solution right now, because multicol is incompatible with reledmac (and also with dblfnote) and ltxgrid.sty, which is a viable alternative to multicol as it also supports floats in columns, is even more incompatible with reledmac.

While there is no solution to this situation in sight, in the meantime, I found a 'partial' solution (or a set of workarounds) that might be helpful to all those facing a similar situation. The workaround consists of three parts.

1) The first is patching multicol in the way I posted as MWE in my question above. This works well, but there are some corner cases left where some footnotes appear one page too early.

2) The frequency of this corner case can be dramatically reduced by playing around with \setcounter{collectmore}{-2} in the document preamble. In my case I could reduce the frequency of the error to about 10%. In the documents I was testing, -2 works best, but sometimes, -1 could also be appropriate. After this step, much less footnotes are left that appear too early and need manual rearrangement.

3) The placement of the remaining misplaced footnotes can be tweaked manually. For this a mechanism is needed to shift certain footnotes from one page to the other (as they appear one page too early). For this you can use the following push-pop mechanism that stores footnotes and releases them upon command, while the footnote anchors are untouched by this mechanism. This needs to be included in the preamble:

\RequirePackage{expl3}
\makeatletter
\ExplSyntaxOn
\tl_new:N \twocolftn@toks

\def\pushFootnotes{%
\let\vfootnoteT@old\vfootnoteT%
\let\vfootnoteT\@pushftn@vfootnoteT%
}
\def\popFootnotes{%
\let\vfootnoteT\vfootnoteT@old%
\tl_use:N \twocolftn@toks%
\tl_clear:N \twocolftn@toks%
}%

\long\def\@pushftn@vfootnoteT#1#2{%
\tl_gput_right:Nn \twocolftn@toks {\@popftn@vfootnoteT}%
\tl_gput_right:Nx \twocolftn@toks {{\@thefnmarkT}}%
\tl_gput_right:No \twocolftn@toks {{T}}%
\tl_gput_right:Nx \twocolftn@toks {{#2}}%
}%

\newcommand*{\@popftn@vfootnoteT}[3]{%
\def\@thefnmarkT{#1}%
%\vfootnoteT{#2}{#3}%eledmac
\regvfootnoteT{T}{#3}%reledmac
}
\ExplSyntaxOff
\makeatother

You can now issue the command \pushFootnotes anywhere in the document. Subsequent footnotes will then be stored but not typeset (only the anchors). Later in the document (on the page where the saved footnotes are to be placed) you must then issue \popFootnotes so that all the saved footnotes will be released and printed on the page where \popFootnotes is located.

So in the MWE above, where Footnote 4 appears too early, you would do this:

\lipsum*[3]\pushFootnotes\footnote{Fn 4}

\lipsum*[5]

\lipsum*[6]\popFootnotes\footnote{Fn 5}

Note that \popFootnotes has to be issued before the next footnote otherwise the order of appearance will switch. By the way: If you implemented step 2, you will not need this push-pop-mechanism in the case of footnote 4 in this concrete MWE as step 2 will already correct this particular case. If you implement step 2, manual readjustment is really only rarely necessary.

I know that this is an experimental workaround. But pragmatically, to all who have to typeset twocol footnotes with twocol text this might be helpful.