2

I'm using the \documentclass{tufte-book} and have a series of longtables for which I wish to place the caption in the margin.

I found a solution to redefine the caption for such tables in this post, which worked perfectly.

\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

I'm also placing figures in the margin using the marginfigure but the font size for the captions of these are larger than the other text. I read in the Tufte Example Book that I can customise the style of margin content using (see pg31)...

\setsidenotefont{\footnotesize}
\setcaptionfont{\footnotesize}
\setmarginnotefont{\footnotesize}
\setcitationfont{\footnotesize}

...and these work, but they don't affect the size of fonts for marginfigure and there is no mention/description in the section on marginfigure (see pg23) of how to customise them either. However they all appear to be the same size in the example document

I had a search around and found the recommendation here to use the \usepackage[font=footnotesize]{caption} package/options, and this works, but it over-rides the custom caption defined for placing the caption of longtable in the margin, so its not really a viable option.

Can anyone advise as to how to modify the font size of captions in marginfigure or how to use the caption package but still define longtable captions to be placed in the margin?

Thanks in advance.

  • You could just replace \caption with you own code (see tex.stackexchange.com/questions/186615/… ) – John Kormylo Jul 2 '14 at 20:10
  • Thanks, that is a really good idea and I will remember that trick it in the future, but I've simplified my situation in the description above. Many of the longtable I am creating are automatically generated from the statistical package R using the xtable package, hacking that to match my custom definition isn't practical for me at the moment. I will however get a minimal working example posted next week (deadline looming this week). – slackline Jul 3 '14 at 9:33
  • Could you create a minimal working example (MWE) that replicates your problem. Something the community can use as a point of departure? – Werner Aug 2 '14 at 0:05
  • @Werner currently away on holiday will try knocking up a mwe when I'm back later this month. – slackline Aug 3 '14 at 5:25
  • @slackline: Did you think of using the mcaption package? – Bernard Aug 31 '14 at 23:50
3

Since \marginpar won't work inside a float, I used Tikzpagenodes. It is easier to create separate replacements for figure and tables than combine the two.

\documentclass{article}
\usepackage{tikzpagenodes}
\usepackage{mwe}

% repacement caption
\newcommand{\figcaption}[1]% #1 = text
{\refstepcounter{figure}%
\addcontentsline{lof}{figure}{\numberline {\arabic{figure}}{\ignorespaces #1}}%
\tikz[remember picture,overlay]{\coordinate (here) at (0,0);%
\path (here -| current page marginpar area.west) node[below right,inner sep=0pt]
{\parbox{\marginparwidth}%
{\raggedright\footnotesize Figure \arabic{figure}:\newline{}#1}};}%
\newline\vspace{-\baselineskip}}%

\begin{document}

\listoffigures

\medskip
\lipsum[1]
\begin{figure}[htp]
\figcaption{A very very very very long caption.}
\centering\includegraphics{example-image}
\end{figure}
\lipsum[2]

\end{document}

full page

  • 1
    Thanks, that looks useful, although as with my above comment I really need to keep my definition to \caption{} rather than \figcaption{} or \mylongtablecaption{} because of how the tables are being generated. If it weren't for that this would I think work well. – slackline Jul 3 '14 at 9:36

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.