[Tex/LaTex] \renewcommand with \caption*

captionsmacrosstarred-version

I'd like to redefine \caption* as

\renewcommand{\caption*}[1]{\vspace{\abovecaptionskip}\caption*{\textbf{Note:} #1}\vspace{-\abovecaptionskip}}

but keep getting an error when I try to compile. My work-around is to just define the new command \floatnote and use that instead of \caption*. It's a perfectly fine work-around, but I'm left with the question:

Q: Why doesn't the above \renewcommand code work?

\documentclass{article}
\usepackage{booktabs}
\usepackage[margin=10pt,font=small,labelfont=bf,labelsep=colon,tableposition=top,figureposition=bottom]{caption}
%\renewcommand{\caption*}[1]{\vspace{\abovecaptionskip}\caption*{\textbf{Note:} #1}\vspace{-\abovecaptionskip}}
\newcommand{\floatnote}[1]{\vspace{\abovecaptionskip}\caption*{\textbf{Note:} #1}\vspace{-\abovecaptionskip}}
\begin{document}
Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.

\begin{table}[h]
  \centering
  \caption{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
  \begin{tabular}{ll}
    \toprule
    foo & bar \\
    \midrule
    baz & qux \\
    \bottomrule
  \end{tabular}
  %\caption*{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
  \floatnote{Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.}
\end{table}

Lorem ipsum dolor sit amet. Lorem ipsum dolor sit amet.
\end{document}

tab1

Best Answer

First: you can't say \renewcommand{\caption*}[1]{...} no matter what you put in as the replacement text. A *-variant is not a command by itself: when you say \caption, LaTeX peeks at what's coming next and decides whether to perform the normal action (\caption) or the variant (\caption*).

Second: even if you could, you may not define a command in terms of itself (without taking special precautions, and this is not the case).

If you say \renewcommand{\foo}{xyz \foo} then TeX, upon finding \foo will dutifully replace it with

xyz \foo

and so it would replace \foo with xyz \foo and … TeX will stop when its memory is exhausted.

The strategy of defining \floatnote is surely better.