# Why is \caption*{} not working?

I've been inspired by this question to add sources to captions. Basically, to define a source in a comment a new command can be created,

\newcommand{\source}[1]{\caption*{\hfill Source: {#1}} }


And it would be sufficient to add a \source{Book} to the figure environment to have a source within the figure, without it appearing in the \listoffigures.

Unfortunately, whenever I do this the following result is obtained:

The \caption* command is not well-received by LaTeX and what's inside is still somehow read and intended as a caption. Apart from the horrible artifact of "Figure 1.2: *" in the text, in the list of figures this is still recorded, with a list going like

• Figure 1.1: Resistivity etc etc
• Figure 1.2: *
• Figure 1.3: Meaningful caption
• Figure 1.4: *

And so on.

Additional info: I'm using TeXstudio 2.10.8 with a base of MikTeX 2.9.4196 on Windows 10.

MWE:

\documentclass[12pt,a4paper]{report}
\usepackage{graphicx} %for figures
\newcommand{\source}[1]{\caption*{\hfill Source: {#1}} } %command definition for sources in figures
\begin{document}
\listoffigures
\chapter{On how my caption went wrong}
Well hello there.
\begin{figure}
\centering
%   \includegraphics[width=0.7\linewidth]{whatevs}
\caption{Look at me I'm a caption}
\label{fig:preeetty_figure}
\source{Interesting book}
\end{figure}
\end{document}


Does anybody know why this is happening? Thanks in advance!

• You don't need \caption to add text in a figure environment, won't just \newcommand{\source}[1]{\hfill Source: {#1} } do the job? – Torbjørn T. May 17 '16 at 16:55
• Well Torbjørn, that pretty much solved it! Thank you very much! By the way... do you know how to close the question? I cannot mark your answer as being the correct one. – Francesco May 17 '16 at 16:58
• Why is \caption* not working? Because the caption package isn't loaded here. And what \caption* is good for when you can simply add text to figures anyway? \caption* typesets the text as setup with \captionsetup, i.e. it is formatted as a caption, w/ vertical spaces above and below it. So it's meant as some kind of caption replacement, but not to typeset additional text beside an existing (real) caption. – user2574 May 18 '16 at 8:09

A figure environment can contain normal text as well, not just graphics and captions. As such, a simple way of achieving what you want is

\newcommand{\source}[1]{\hfill Source: #1} %command definition for sources in figures


Complete code:

\documentclass[12pt,a4paper]{report}
\newcommand{\source}[1]{\hfill Source: {#1}} %command definition for sources in figures
\begin{document}
\listoffigures
\begin{figure}[htb]
\centering
\caption{Look at me I'm a caption}
\label{fig:preeetty_figure}
\source{Interesting book}
\end{figure}
\begin{figure}[htb]
\centering
\caption{Words.}
\label{fig:preetty_figure}
\source{Uninteresting book}
\end{figure}

\end{document}