1

How can I achieve the same label-only (no separator) behaviour for \caption{} when the label is to be placed on the margin?

I started from here, but this does not apply for standard floats.

MWE:

\documentclass{tufte-book}
\usepackage{wrapfig}
\usepackage[demo]{graphicx}
\usepackage{caption}
\usepackage{etoolbox}


\makeatletter
\patchcmd{\@caption}{\csname fnum@#1\endcsname:
\ignorespaces#3}{
\csname fnum@#1\endcsname\ifblank{#3}{}{: \ignorespaces#3}}{}{}
\makeatother 


\begin{document}
\begin{figure}
  \begin{center}
    \includegraphics[width=3cm]{graphic.pdf}
    \caption[Caption for the list of figures]{ }
    \label{fig:figureX}
  \end{center}
\end{figure}
\begin{wrapfigure}{l}{4cm}
  \begin{center}
    \includegraphics[width=3cm]{graphic.pdf}
    \caption[Caption for the list of figures]{}
    \label{fig:figureX}
  \end{center}
\end{wrapfigure}
\end{document}

"Figure 1:" (margin) vs. "Figure 2" (text column)

1 Answer 1

2

It looks like you need to add a couple \expandafters:

\makeatletter
\patchcmd{\@caption}{\csname fnum@#1\endcsname:
\ignorespaces#3}{
\csname fnum@#1\endcsname\expandafter\ifblank\expandafter{#3}{}{: \ignorespaces#3}}{}{}
\makeatother 

Since #3 is \@tufte@stored@caption for regular figures/tables, \ifblank evaluates the else/false branch. Once \@tufte@stored@caption is expanded to a blank string by using \expandafter, \ifblank will work as expected.

You must log in to answer this question.

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