# Splitting a caption and cross-referencing

I'm currently writing my thesis and I'm struggling with my redefinition of the caption command.

I've got large captions which I don't want to show up in my list of figures. Of each caption I want only to use the first sentence. In some captions I would like to refer to other floats using the cleveref package. Below a minimal example is given.

\documentclass{article}
\usepackage{cleveref}
\def\mcaption#1{%
\begingroup
\edef\@tempa{#1}%
\expandafter\endgroup
\expandafter\split\@tempa\relax
}
\def\split#1.#2\relax{\caption[#1]{#1.#2}}
\begin{document}
\listoffigures
\begin{figure}
\centering
Insert figure here
\mcaption{This is a working caption. One can see that ......}
\label{fig:abc}
\end{figure}
\begin{figure}
\centering
Insert figure here
\end{figure}
\end{document}


This fails to produce a PDF with the following error message:

./temp.tex:27: Undefined control sequence. \@cref ...oup =1\count@group =1\def \cref@variant {#1}\newif \if@secondref ... l.27 ... not work. See also Figure \cref{fig:abc}}

./temp.tex:27: Undefined control sequence. \if@secondref

Is it possible to do what I want or should I forgo the idea of referencing other floats in a caption?

• Welcome to TeX.SX! I'd prefer \mcaption{First sentence}{Rest of the caption}: just as easy to type and much easier to parse for TeX. So \newcommand{\mcaption}[2]{\caption[#1]{#1. #2}} Apr 10 '14 at 7:54

You're doing a useless \edef, which is also dangerous if commands such as \textbf appear in the caption text.

Just say

\documentclass{article}
\usepackage{cleveref}

\makeatletter
\def\mcaption#1{\split@caption#1\@nil}
\def\split@caption#1.#2\@nil{\caption[#1]{#1.#2}}
\makeatother

\begin{document}
\listoffigures
\begin{figure}
\centering
Insert figure here
\mcaption{This is a working caption. One can see that ......}
\label{fig:abc}
\end{figure}
\begin{figure}
\centering
Insert figure here
\end{figure}
\end{document}


Better not using \split as a name, because this is a command used by amsmath. However, I'd prefer a simpler approach:

\documentclass{article}
\usepackage{cleveref}

\newcommand\mcaption[2]{\caption[#1]{#1. #2}}

\begin{document}
\listoffigures
\begin{figure}
\centering
Insert figure here
\mcaption{This is a working caption}{One can see that ......}
\label{fig:abc}
\end{figure}
\begin{figure}
\centering
Insert figure here