I'm trying to create a custom table environment that has the following properties:
- It may be very long (i.e., longer than a page) and so I need to use a
longtable
- It may (or may not) have footnotes.
I've included an example here of what I'm trying to do. I have two tables, an "uppercase" and a "lowercase" table. The uppercase table has no footnotes, while the lowercase table does.
\documentclass{scrartcl}
\usepackage{longtable}
\usepackage[referable]{threeparttablex}
\usepackage{booktabs}
\title{MWE}
\author{jlconlin}
\newenvironment{letterTable}{%
\begin{longtable}{rl}
\toprule
Letter & Index \\
\midrule
\endfirsthead
continued \\
\toprule
Letter & Index \\
\midrule
\endhead
\bottomrule
\emph{Continued on next page}
\endfoot
\bottomrule
\insertTableNotes
\endlastfoot
}
{\end{longtable}}
\begin{document}
\maketitle
\begin{letterTable}
A & 1 \\
B & 2 \\
C & 3 \\
D & 4 \\
E & 5 \\
F & 6 \\
G & 7 \\
H & 8 \\
I & 9 \\
J & 10 \\
K & 11 \\
L & 12 \\
M & 13 \\
N & 14 \\
O & 15 \\
P & 16 \\
Q & 17 \\
R & 18 \\
S & 19 \\
T & 20 \\
U & 21 \\
V & 22 \\
W & 23 \\
X & 24 \\
Y & 25 \\
Z & 26 \\
\end{letterTable}
\begin{ThreePartTable}
\begin{TableNotes}
\item[a] \label{tn:a} lowercase A
\item[b] \label{tn:b} lowercase B
\item[c] \label{tn:c} lowercase C
\item[d] \label{tn:d} lowercase D
\item[e] \label{tn:e} lowercase E
\item[f] \label{tn:f} lowercase F
\item[g] \label{tn:g} lowercase G
\item[h] \label{tn:h} lowercase H
\item[i] \label{tn:i} lowercase I
\item[j] \label{tn:j} lowercase J
\item[k] \label{tn:k} lowercase K
\item[l] \label{tn:l} lowercase L
\item[m] \label{tn:m} lowercase M
\item[n] \label{tn:n} lowercase N
\item[o] \label{tn:o} lowercase O
\item[p] \label{tn:p} lowercase P
\item[q] \label{tn:q} lowercase Q
\item[r] \label{tn:r} lowercase R
\item[s] \label{tn:s} lowercase S
\item[t] \label{tn:t} lowercase T
\item[u] \label{tn:u} lowercase U
\item[v] \label{tn:v} lowercase V
\item[w] \label{tn:w} lowercase W
\item[x] \label{tn:x} lowercase X
\item[y] \label{tn:y} lowercase Y
\item[z] \label{tn:z} lowercase Z
\end{TableNotes}
\begin{letterTable}
a\tnotex{tn:a} & 1 \\
b\tnotex{tn:b} & 1 \\
c\tnotex{tn:c} & 1 \\
d\tnotex{tn:d} & 1 \\
e\tnotex{tn:e} & 1 \\
f\tnotex{tn:f} & 1 \\
g\tnotex{tn:g} & 1 \\
h\tnotex{tn:h} & 1 \\
i\tnotex{tn:i} & 1 \\
j\tnotex{tn:j} & 1 \\
k\tnotex{tn:k} & 1 \\
l\tnotex{tn:l} & 1 \\
m\tnotex{tn:m} & 1 \\
n\tnotex{tn:n} & 1 \\
o\tnotex{tn:o} & 1 \\
p\tnotex{tn:p} & 1 \\
q\tnotex{tn:q} & 1 \\
r\tnotex{tn:r} & 1 \\
s\tnotex{tn:s} & 1 \\
t\tnotex{tn:t} & 1 \\
u\tnotex{tn:u} & 1 \\
v\tnotex{tn:v} & 1 \\
w\tnotex{tn:w} & 1 \\
x\tnotex{tn:x} & 1 \\
y\tnotex{tn:y} & 1 \\
z\tnotex{tn:z} & 1 \\
\end{letterTable}
\end{ThreePartTable}
\end{document}
In this example, the uppercase table comes first—and LaTeX fails to compile with this error:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation. Type H for immediate help. ...
l.51 \begin{letterTable}
If I move the uppercase table (with no table footnotes) after the lowercase table (with table footnotes) then everything compiles just fine.
- Why does the order matter here?
- What can I do to fix it so that the order doesn't matter?
\insertTaleNotes
in the definition ofletterTable
. This doesn't make sense outside of aThreePartTable
(but for some reason does work if there was aThreePartTable
prior to that). A quick fix would be to add an optional argument which tells theletterTable
that it is used inside ofThreePartTable
(or do some witchcraft to detect that alone).