# How to use scalebox in captions? [duplicate]

This code:

\documentclass[a4paper,twoside,12pt]{scrreprt}
\usepackage{fontspec}
\begin{document}
Test \scalebox{3.0}{$\int$} test.
\begin{table}
\centering
\begin{tabular}{cc}
A & B \\
C & D
\end{tabular}
\caption{Test \scalebox{3.0}{$\int$} test.}
\end{table}
\end{document}


gives me the error message:

! Argument of \@caption has an extra }.


The result looks how I want it to, though...

What should I do?

• – Gonzalo Medina Aug 3 '14 at 2:06
• Is there a reason why you won't use $\displaystyle\int$ in the caption? The enlarged text-style integral one gets via \scalebox{3.0}{$\int$} is not at all centered on the math axis, making it look accidentally comical. This is an effect you are (I would hope!) not actively trying to create, right? – Mico Aug 3 '14 at 4:31

You have two options. First one is to \protect \scalebox:

\documentclass[a4paper,twoside,12pt]{scrreprt}
\usepackage{graphicx}
%\usepackage{fontspec}
\begin{document}
Test \scalebox{3.0}{$\int$} test.
\begin{table}
\centering
\begin{tabular}{cc}
A & B \\
C & D
\end{tabular}
\caption{Test \protect\scalebox{3.0}{$\int$} test.}
\end{table}
\end{document}


Second one is to use the optional argument of \caption:

\documentclass[a4paper,twoside,12pt]{scrreprt}
\usepackage{graphicx}
%\usepackage{fontspec}
\begin{document}
Test \scalebox{3.0}{$\int$} test.
\begin{table}
\centering
\begin{tabular}{cc}
A & B \\
C & D
\end{tabular}
\caption[Test $\int$ test.]{Test \scalebox{3.0}{$\int$} test.}
\end{table}
\end{document}


This happens as the contents of \caption are movable (i.e., fragile) as they may be used in lof and you have to \protect commands (from expanding) used inside the argument.

• I strongly recommend your second method, as there's probably little point in producing an enlarged text-style integral sign in the List of Tables. However, I think that a third option -- \displaystyle\int -- is still better: the integral sign will then be set correctly on the math axis rather stick out bizarely above it. – Mico Aug 3 '14 at 4:34