7

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:Example of table and its caption in the tufte-latex class 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): Longtable environment with wrong caption placement

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
\endfirsthead
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\endhead
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\end{document}
3
  • 2
    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, 2014 at 21:04
  • I'm not able to provide a mwe right now. Will certainly do it later. Thanks David! Jun 2, 2014 at 7:39
  • Added the mwe as requested. Jun 3, 2014 at 12:01

1 Answer 1

8

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)

enter image description here

\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
\endfirsthead
\toprule
Requirement id & Review of design & Analysis & Inspection & Test \\
%\otoprule
\endhead
\bottomrule
\endfoot
One & * & & & \\
\midrule
Two & * & & & \\
\midrule
Three & * & & & \\
\midrule
Four & * & & & \\
\end{longtable}

\end{document}
4
  • Thanks David! I added some details to the question (caption placement) Jun 6, 2014 at 10:41
  • 1
    @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, 2014 at 12:33
  • Thanks anyway! Maybe I should file a bug/feature request for the tufte-latex class Jun 7, 2014 at 9:36
  • 1
    Fixing the typo in the comment You can change \parbox[t]{\marginparwidth}{% to \parbox[t]{\marginparwidth}{\vspace{10pt}% Jun 1, 2017 at 16:04

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .