TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I would like to define a very plain caption format that simply typesets the caption label and text as if it were normal inline text. Of course I would like to keep the the functionality of \caption (label/ref, hyperlinks, list of figures, etc.). I want to position the caption manually using TikZ nodes.

Is this somehow possible with the caption package?

An example to illustrate what I am trying to do:

\documentclass{article}
\usepackage{tikz}
\usepackage{caption}
\usepackage{hyperref}


\tikzset{%
caption/.style={%
    anchor=center, 
    draw=blue, fill=blue!20, 
    font=\color{blue}},
figure/.style={%
    inner sep=1cm,
    draw=blue, 
    minimum width=\linewidth}%
}%

\begin{document}

\begin{figure}
\begin{tikzpicture}
    \node[figure] (fig) {Nice figure.};
    \node[caption] at (fig.north) {Figure 0: My figure};
\end{tikzpicture}
\end{figure}

% Does not work
% \captionsetup[figure]{format=plain,skip=0pt,indention=0pt}
% \begin{figure}
% \begin{tikzpicture}
    % \node[figure] (fig) {Nice figure.};
    % \node[caption] at (fig.north) {%
        % \caption{My figure}\label{fig:myfig}};
% \end{tikzpicture}
% \end{figure}
% This is \autoref{fig:myfig}.

\end{document}
share|improve this question
up vote 2 down vote accepted

Yes, it's possible with the caption package. Just use the \captionof command, for instance inside a parbox:

\listoffigures
\bigskip

\captionsetup[figure]{format=plain,skip=0pt,indention=0pt}
\begin{figure}[hbp]
\begin{tikzpicture}
    \node[figure] (fig) {Nice figure.};
    \node[caption] at (fig.north) {%
        \parbox{4cm}{\captionof{figure}{My figure}\label{fig:myfig}}};
\end{tikzpicture}
\end{figure}
This is \autoref{fig:myfig}.

alt text

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.