1

I have a document that wraps tables (or rather, tabular/tabulary) with mdframed. This works quite happily whether the table is shown inline or floated to another page (mdframed inside the table*, obviously) and I am pleased with the result.

When I try to wrap longtable with mdframed, though, it doesn't work out quite right. The table breaks at page end as expected, but I don't get the secondary headers and footers.

  • Also doesn't work with longtabu or other longtable-style hacks (such as ltabulary).
  • Also doesn't work when tcolorbox surrounds the longtable.

In the example below:

  • Chapter 1 shows the longtable I expect ('continued on next page...', '... continued from previous page', with column headings).
  • Chapter 2 shows the same longtable wrapped in mdframed, notice there are no 'continued' comments, nor column headings after the first page).
  • Chapters 3 and 4 show what text looks like, for comparison (may or may not be important)

How do I get the longtable to show the secondary head and foot when wrapped in mdframed?

MWE:

\documentclass{report}
\usepackage{lipsum}
\usepackage{longtable}
\usepackage{mdframed}

\begin{document}
\chapter{Table, no mdframed}
\input{ltab}
\chapter{Table, mdframed}
\begin{mdframed}[frametitle={Table Sample mdframed}]
\input{ltab}
\end{mdframed}
\chapter{Text, no mdframed}
\lipsum[1-4]
\chapter{Text, mdframed}
\lipsum[5]
\begin{mdframed}[frametitle={Text Sample mdframed}]
\lipsum[6-8]
\end{mdframed}
\end{document}

MWE ltab.tex:

\begin{longtable}{clr}
\textbf{d\%} & \textbf{Text Column} & \textbf{Page} \\
\endfirsthead

\multicolumn{3}{l}{\emph{... continued from previous page}} \\
\textbf{d\%} & \textbf{Text Column} & \textbf{Page} \\
\endhead

\multicolumn{3}{r}{\emph{continued on next page...}} \\
\endfoot
\endlastfoot

1--1 & text column & 1 \\
2--2 & text column & 2 \\
3--3 & text column & 3 \\
4--4 & text column & 4 \\
5--5 & text column & 5 \\
6--6 & text column & 6 \\
7--7 & text column & 7 \\
8--8 & text column & 8 \\
9--9 & text column & 9 \\
10--10 & text column & 10 \\
11--11 & text column & 11 \\
12--12 & text column & 12 \\
13--13 & text column & 13 \\
14--14 & text column & 14 \\
15--15 & text column & 15 \\
16--16 & text column & 16 \\
17--17 & text column & 17 \\
18--18 & text column & 18 \\
19--19 & text column & 19 \\
20--20 & text column & 20 \\
21--21 & text column & 21 \\
22--22 & text column & 22 \\
23--23 & text column & 23 \\
24--24 & text column & 24 \\
25--25 & text column & 25 \\
26--26 & text column & 26 \\
27--27 & text column & 27 \\
28--28 & text column & 28 \\
29--29 & text column & 29 \\
30--30 & text column & 30 \\
31--31 & text column & 31 \\
32--32 & text column & 32 \\
33--33 & text column & 33 \\
34--34 & text column & 34 \\
35--35 & text column & 35 \\
36--36 & text column & 36 \\
37--37 & text column & 37 \\
38--38 & text column & 38 \\
39--39 & text column & 39 \\
40--40 & text column & 40 \\
41--41 & text column & 41 \\
42--42 & text column & 42 \\
43--43 & text column & 43 \\
44--44 & text column & 44 \\
45--45 & text column & 45 \\
46--46 & text column & 46 \\
47--47 & text column & 47 \\
48--48 & text column & 48 \\
49--49 & text column & 49 \\
50--50 & text column & 50 \\
51--51 & text column & 51 \\
52--52 & text column & 52 \\
53--53 & text column & 53 \\
54--54 & text column & 54 \\
55--55 & text column & 55 \\
56--56 & text column & 56 \\
57--57 & text column & 57 \\
58--58 & text column & 58 \\
59--59 & text column & 59 \\
60--60 & text column & 60 \\
61--61 & text column & 61 \\
62--62 & text column & 62 \\
63--63 & text column & 63 \\
64--64 & text column & 64 \\
65--65 & text column & 65 \\
66--66 & text column & 66 \\
67--67 & text column & 67 \\
68--68 & text column & 68 \\
69--69 & text column & 69 \\
70--70 & text column & 70 \\
71--71 & text column & 71 \\
72--72 & text column & 72 \\
73--73 & text column & 73 \\
74--74 & text column & 74 \\
75--75 & text column & 75 \\
76--76 & text column & 76 \\
77--77 & text column & 77 \\
78--78 & text column & 78 \\
79--79 & text column & 79 \\
80--80 & text column & 80 \\
81--81 & text column & 81 \\
82--82 & text column & 82 \\
83--83 & text column & 83 \\
84--84 & text column & 84 \\
85--85 & text column & 85 \\
86--86 & text column & 86 \\
87--87 & text column & 87 \\
88--88 & text column & 88 \\
89--89 & text column & 89 \\
90--90 & text column & 90 \\
91--91 & text column & 91 \\
92--92 & text column & 92 \\
93--93 & text column & 93 \\
94--94 & text column & 94 \\
95--95 & text column & 95 \\
96--96 & text column & 96 \\
97--97 & text column & 97 \\
98--98 & text column & 98 \\
99--99 & text column & 99 \\
100--100 & text column & 100 \\

\end{longtable}
  • 1
    I am not sure if this possible at all due to the 'breaking' mechanism of longtable and mdframed (It doesn't work with tcolorbox as surrounding box neither :-( ) – user31729 Oct 20 '15 at 16:28

Your Answer

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

Browse other questions tagged or ask your own question.