4

I have many longtable's in my document. Everything is the same across all the tables, except for the caption and the content (of course). How can I avoid duplicating the stuff required to set up longtable? Is this possible?

The code needed to produce one table is below. You can see there is a lot of stuff required to set up the table. I would like to avoid duplicating this stuff multiple times.

\begin{longtable}[h]{M{2.00in}M{0.85in}m{0.55in}m{0.55in}m{0.55in}m{0.55in}}
\caption{First Ministry in Jerusalem} \\
\toprule
Event & Location & Matt. & Mark & Luke & John  \\
\midrule
\endfirsthead
\caption{First Ministry in Jerusalem (continued)} \\
    \toprule
    Event & Location & Matt. & Mark & Luke & John \\
    \midrule
\endhead
    \bottomrule
    \multicolumn{6}{r}{\emph{Continued on next page}}
\endfoot
    \bottomrule
\endlastfoot
Content & Goes & Here
\end{longtable}
1
  • Welcome to TeX.sx. Note that you don't need to sign your message, as your (nick)name appears at its bottom.
    – egreg
    Jul 15, 2011 at 13:51

1 Answer 1

6

This goes in the preamble:

\newenvironment{mylongtable}[1]
 {\begin{longtable}{M{2.00in}M{0.85in}m{0.55in}m{0.55in}m{0.55in}m{0.55in}}
  \caption{#1} \\
    \toprule
    Event & Location & Matt. & Mark & Luke & John  \\
    \midrule
  \endfirsthead
    \caption{First Ministry in Jerusalem (continued)} \\
    \toprule
    Event & Location & Matt. & Mark & Luke & John \\
    \midrule
  \endhead
    \bottomrule
    \multicolumn{6}{r}{\emph{Continued on next page}}
  \endfoot
    \bottomrule
  \endlastfoot}
 {\end{longtable}}

Then you'll simply write

\begin{mylongtable}{First Ministry in Jerusalem}
<contents>
\end{mylongtable}
1
  • I knew it couldn't be too difficult. Thanks for showing me how!
    – jlconlin
    Jul 18, 2011 at 13:28

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.