3

Good afternoon,

This is a continuation of this question, which solved the problem of putting a longtable inside the multicols environment (which is not currently supported without some tinkering). This is excellent, and as the example below shows it works beautifully.

enter image description here

However when I want to add a "thanks" field to the author and this trick seems to stop working (longtable discovers it is in twocolumn mode). The code block below will reproduce the error, and the forced output is shown at the very end.

Does anyone have an idea why this is happening? (FYI I would like to stick to "longtable" because I am using this in conjunction with the glossaries package (it actually works!) and I could not get "supertable" to span exactly the column width.)

Thank you for your time.

Sigve

\documentclass[article]{memoir}
%
\usepackage{longtable}
\usepackage{multicol}
\usepackage{blindtext}
%
\newsavebox\ltmcbox
\newcounter{entryno}
\setcounter{entryno}{1}
\def\tabline{Test & \the\value{entryno} & Description\addtocounter{entryno}{1}\\}
\def\tablines{\tabline\tabline\tabline\tabline\tabline}
% Remove "\thanks{---}" before typesetting
%   %%%
%   %%%
%  %%%%%
%   %%%
%    %
\title{Longtable Inside Multicols \thanks{\copyright~2017~TeX}}
\author{Author Authorson}
%
\begin{document}
%
\maketitle
%
\begin{multicols}{2}
  %
  \blindtext
  %
  % ----------------------------------------------------
  % Make "longtable" believe it is in one-column mode
  \setbox\ltmcbox\vbox\bgroup
  \makeatletter\col@number\@ne
  \begin{longtable}{|l|l|l|}
   \tablines\tablines
  \end{longtable}
  \unskip
  \unpenalty
  \unpenalty\egroup
  \unvbox\ltmcbox
  %
  \blindtext
\end{multicols}
%
\end{document}

enter image description here

3

oops, it's not really \thanks other than that slightly changed the page breaking. It was an accident waiting to happen in the original code...

Add an extra line to disable longtables's end game.

enter image description here

\documentclass[article]{memoir}
%
\usepackage{longtable}
\usepackage{multicol}
\usepackage{blindtext}
%
\newsavebox\ltmcbox
\newcounter{entryno}
\setcounter{entryno}{1}
\def\tabline{Test & \the\value{entryno} & Description\addtocounter{entryno}{1}\\}
\def\tablines{\tabline\tabline\tabline\tabline\tabline}
% Remove "\thanks{---}" before typesetting
%   %%%
%   %%%
%  %%%%%
%   %%%
%    %
\title{Longtable Inside Multicols \thanks{\copyright~2017~TeX}}
\author{Author Authorson}
%
\begin{document}
%
\maketitle
%

\begin{multicols}{2}
  %
  \blindtext
  %
  % ----------------------------------------------------
  % Make "longtable" believe it is in one-column mode
  \setbox\ltmcbox\vbox\bgroup
  \makeatletter\col@number\@ne
\mathchardef\LT@end@pen=0 %<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<
  \begin{longtable}{|l|l|l|}
   \tablines\tablines
  \end{longtable}
  \unskip
  \unpenalty
  \unpenalty\egroup
  \unvbox\ltmcbox
  %
  \blindtext

\end{multicols}
%
\end{document}
  • Fantastic! Thank you very much for your excellent work on this package David. – Sigve Karolius Apr 7 '17 at 16:07
  • 1
    really David ... better to discover from within longtable that you are inside multicols and stop needing all they gymnastics :-) – Frank Mittelbach Apr 8 '17 at 21:56

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.