# Caption in the outer margin using longtable within a tufte-latex document

The tufte-latex class has a page layout with a wide margin on the side; the class redefines the figure and table environments so that the captions are put in the margin, side to side with the floating environment. Here's an excerpt from the sample-book.pdf file: However, there's a problem when using the longtable environment. Since it cannot be put inside a table environment, it loses the caption in the margin.

Longtable in fact has a \caption{} command, but it allows the caption to be placed only on top on the table, not on the side (that is, in the margin):

How can I have a longtable with the caption in the margin?

tufte-latex places the caption in the margin, aligned with the top of the floating environment, and it can be serif (default) or sans-serif (\sffamily).

I'm aware of this answer, but it does not solve the problem completely, as the longtable caption does not inherit the format of the other captions.

A MWE as requested (longtable with the wrong caption):

\documentclass{tufte-book}

\usepackage{booktabs}
\usepackage{longtable}

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{lcr}
\toprule
Heading & Style & Size \\
\midrule
Part & roman & {40} \\
Chapter & italic & {40} \\
Section & italic & {26} \\
Subsection & italic & {26} \\
Paragraph & italic & 10/14 \\
\bottomrule
\end{tabular}
\caption{Heading styles used in.}
\end{table}

\begin{longtable}{lcccc}
\caption{Verification methods.}\\
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
\toprule
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\end{document}

• longtable captioning could be more flexible:-) the caption package allows the caption formatting to be customised a bit, it probably doesn't allow this though. It is probably easy to arrange but it depends how your margin captions are set up. As always it would help if you provided a complete example document showing a marginal caption and a longtable that wants a marginal caption. Jun 1 '14 at 21:04
• I'm not able to provide a mwe right now. Will certainly do it later. Thanks David! Jun 2 '14 at 7:39
• Added the mwe as requested. Jun 3 '14 at 12:01

Basically you can use the code in the referenced answer but replace the \raggedright by the formatting the Tufte class uses. I don't really know that class but using \tracingall suggests that this produces the same formatting (but the class may have higher level access to these settings)

\documentclass{tufte-book}

\usepackage{booktabs}
\usepackage{longtable}

\makeatletter
\def\LT@makecaption#1#2#3{%
\noalign{\smash{\hbox{\kern\textwidth\rlap{\kern\marginparsep
\parbox[t]{\marginparwidth}{%
\@tufte@caption@font \@tufte@caption@justification \noindent
#1{#2: }\ignorespaces #3}}}}}}
\makeatother

\begin{document}

\begin{table}[h]
\centering
\begin{tabular}{lcr}
\toprule
Heading & Style & Size \\
\midrule
Part & roman & {40} \\
Chapter & italic & {40} \\
Section & italic & {26} \\
Subsection & italic & {26} \\
Paragraph & italic & 10/14 \\
\bottomrule
\end{tabular}
\caption{Heading styles used in.}
\end{table}

\begin{longtable}{lcccc}
\caption{Verification methods.}\\
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
\toprule
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\end{document}

• Thanks David! I added some details to the question (caption placement) Jun 6 '14 at 10:41
• @AlessandroCuttin yes I noticed it was a bit high:-) I think I'm going to stop though, I really don't know the tufte classes at all and the caption handling is completely different, You can change \parbox[t]{\marginparwidth}{% to \parbox[t]{\marginparwidth}{\vspace(10pt}% or something to add a correction to the positioning. Jun 6 '14 at 12:33
• Thanks anyway! Maybe I should file a bug/feature request for the tufte-latex class Jun 7 '14 at 9:36
• Fixing the typo in the comment You can change \parbox[t]{\marginparwidth}{% to \parbox[t]{\marginparwidth}{\vspace{10pt}% Jun 1 '17 at 16:04