longtable in footnote leads to overfull page

While longtable is good at breaking across pages on a row-by-row basis, I'm having a problem with some of them in footnotes. It seems as though not enough space is being "guessed" regarding the size of the tables when shipping out pages, with the result that the table does not break at all and ends up being written in the bottom margin of the page. (Note: sometimes it does the right thing, but not always.) Any suggestions would be appreciated, though "don't use a table there" is the least desirable solution at this point.

\documentclass[12pt]{article}

\usepackage{booktabs,longtable,lipsum}
\newcommand{\twolines}{Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida}%
\newcommand{\threelines}{Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu
libero, nonummy eget, consectetuer id, vulputate a}%

\begin{document}

\lipsum[1]\footnote{\threelines\twolines}

\lipsum[2]\footnote{\threelines\twolines}

New paragraph.%
\footnote{Note this table (with was designed for hanging footnotes):
%
\begin{longtable}{@{}p{1em} p{1.75cm} p{10.5cm}}% for hanging footnotes

& Abbrev1 & \twolines\\
% & Abbrev2 & \threelines\\ % uncommenting these lines show
% & Abbrev3 & \threelines\\ % another unhappy outcome
\end{longtable}
}% <--- end of footnote
\threelines.

\lipsum[4]

\end{document}


Edit: Perhaps I should add that I am not insisting on a longtable solution, but I would like something that can mimic a table with p{} columns (i.e., multiline single-cell contents) which can break across pages while stuck in a footnote (... which sounds like a lot once you say it out loud). That said, I thought longtable would be the easiest way to achieve this.

-
Do you really need a tabular which can break across pages in a footnote? Why don't you use simply a tabular? –  Ulrike Fischer Feb 23 '12 at 9:10
@UlrikeFischer I first learned the joys of having packages on public archives (before ctan) when I got a bug report from someone reporting that footnotes did not work in multipage tables that were, themselves, in a page footnote. –  David Carlisle Feb 23 '12 at 9:25
@UlrikeFischer -- "need" may not be the right word, but I would like one. The tables are lists of abbreviations in a long paper (four lists) with many long footnotes. Other suggestions are welcome, but it does seem like an interesting problem. (In a sense the problem is probably moot since I'll probably need to convert it to .doc and fix up whatever I can manage to get out of tex4ht anyway....) –  jon Feb 23 '12 at 14:03
How about using a tabbing environment? –  lockstep Feb 23 '12 at 18:40
@lockstep -- tabbing doesn't break lines automatically (does it?). These 'tables' are essentially lists of abbreviations: some of them are only one line long, others might be two to four lines, which is why I used the p{} columns. –  jon Feb 24 '12 at 2:32

You need to ensure that the page breaker can split the table after each row of the table which means making sure there are suitable glue and penalties, and to make sure that any boxes are unboxed.

longtable does leave all the rows unboxed to allow page breaking in footnotes, but the problem here is that the rows have large depth (from the p columns) which makes it difficult for the implicit \vsplit operation that splits footnotes to find anywhere to split. It's possible to reproduce the bad behaviour just using \parboxes and not longtableat all (so it's not my fault:-) I append at the end the best I could come up with so far, which is just using \parboxes, in theory that penalty and glue combination could be generated from longtable syntax if that is more convenient, but TeX seems quite fragile here, and several variants of this (both using and not using longtable) resulted in (apparently) looping within the output routine and non-terminating documents. The following does terminate, and does split....

\documentclass[12pt]{article}

\usepackage{lipsum}
\newcommand{\twolines}{Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida}%
\newcommand{\threelines}{Lorem ipsum dolor sit amet, consectetuer
adipiscing elit. Ut purus elit, vestibulum ut, placerat ac,
adipiscing vitae, felis. Curabitur dictum gravida mauris. Nam arcu
libero, nonummy eget, consectetuer id, vulputate a}%

\begin{document}

\makeatletter

\def\@oddfoot{\reset@font\dotfill\thepage\dotfill}

\lipsum[1]x\footnote{\threelines\twolines}

\lipsum[2]y\footnote{\threelines\twolines}

New paragraph.%
\footnote{Note this table (with was designed for hanging footnotes):

\splitmaxdepth\maxdimen
\def\goodbreak{\penalty-9000 }

\filbreak

\filbreak

}% <--- end of footnote
\threelines.

\lipsum[4]

\end{document}

-
Thanks for the hint ... though in my case the hint is to look through the comp.text.tex archives since I've looked at longtable.sty before.... –  jon Feb 23 '12 at 14:08
updated answer. –  David Carlisle Feb 25 '12 at 23:08
Thanks for this. \parboxes look like a good way to go. (I have yet to try it on the real document, but this seems promising.) Two questions remain: should the example not have a corresponding \makeatother? And could you explain what \splitmaxdepth\maxdimen are doing here? –  jon Feb 26 '12 at 0:28
leaving off \makeatother is useful when debugging as it leaves @ a letter so you can go \show\@some@horribe@internal and find out what TeX's up to. there are a couple of places where latex assumes @ has type letter but not many so most of the time it;s safe. For production code stick the definitions in a package file anyway then you don't need either of the maketat... –  David Carlisle Feb 26 '12 at 0:34
Probably (possibly) not sure, it's late \splitmaxdepth isn't doing anything in this version, but it controls the maximum depth of boxes when splitting (like \maxdepth in the main page)Normally you want to allow a bit of spare depth for descenders and the like, but you don't want material to overhang the bottom too much (off the page for example) I was having 'trouble' persuading TeX to split the footnote and setting this to its maximum value removes one constraint so narrows down the trail as to what was stopping the breaking. To be honest I didn't totally track it down... –  David Carlisle Feb 26 '12 at 0:40

You can always use:

\usepackage{tabu}


And use the longtabu environment. According to tabu's documentation, footnotes and index words are allowed inside tabu, unlike tabularx, footnote links are not broken when used with hyperref. The syntax \footnote [number]{htexti} is allowed in tabu and longtabu (this hasn't been implemented for longtable yet...)

-
Well the paper is long published now, and @DavidCarlisle's solution worked well. However, I would recommend staying away from tabu as the package author is still fiddling with things and explicitly promised that there would not be backwards compatibility. See here for the discussion. –  jon Apr 1 '13 at 20:49
Thank you @jon, I'm currently working with tabu (because of longtabu X) and I wasn't aware of this situation. Is there any environment that works with the benefits of tabularx and longtable? –  Mario S. E. Apr 1 '13 at 20:55
Well, I think that is the problem. tabu and longtabu are meant to supersede existing packages (no mean feat!), but the development has stalled somewhat as far as I know. But I don't have complicated tabular needs, and tend just to stick with longtable because I (more or less) understand how to use it. There is also supertabular, but I've never tried it. –  jon Apr 1 '13 at 21:01
This is actually quite alarming. I guess a lot of people are using tabu, and according to the link you just pointed me, it seems the developer is planning to make a new one over the existing one (instead of using a new name), rendering all tabu (version 2.8) documents useless until re-written. –  Mario S. E. Apr 1 '13 at 21:31
Yes, I don't think it is a good idea. This is why I avoid using the package, despite all the powerful features.... –  jon Apr 1 '13 at 21:54