I would like to insert a copyleft sign inside a \caption
. The following command, given here, works outside \caption
:
\reflectbox{\sffamily{\copyright}}
and does what I would like.
But this:
\caption{A caption \reflectbox{\sffamily{\copyright}}}
leads to an error. What surprises me most is that
\documentclass{article}
\usepackage{graphicx}
\newcommand{\copyleft}{\reflectbox{\sffamily{\copyright}}}
\begin{document}
\begin{figure}
\caption{A simple caption \copyleft}
\end{figure}
\end{document}
yields the error:
Undefined control sequence.
\Gscale@box #1[#2]#3->\leavevmode \def \Gscale@x
{#1}\def \Gscale@y {#2}\set...
l.9 \caption{A simple caption \copyleft}
The control sequence at the end of the top line
of your error message was never \def'ed. If you have
misspelled it (e.g., `\hobx'), type `I' and the correct
spelling (e.g., `I\hbox'). Otherwise just continue,
and I'll forget about whatever was undefined.
[...]
but this one works !
\documentclass{article}
\usepackage{graphicx}
\newcommand{\copyleft}{\reflectbox{\sffamily{\copyright}}}
\begin{document}
\copyleft
\begin{figure}
\caption{A simple caption \copyleft}
\end{figure}
\end{document}
Any ideas or suggestions? I just want to include a copyleft sign in a caption, using latex.
Best Answer
\reflectbox
is a “fragile” command (see What is the difference between Fragile and Robust commands?), so it needs protection when used (directly or indirectly) in a moving argument.So you have to do either
that is, using
\protect
in front of\copyleft
whenever it is in a moving argument (captions and titles, mostly), orAs an aside, notice that
\sffamily
doesn't take an argument: it is a declaration that remains in force until the group it is in ends; a box command, such as\reflectbox
, builds its contents in a group. The version with an argument is\textsf
.