此代码:
\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}
给了我错误信息:
! Argument of \@caption has an extra }.
但结果看上去正是我想要的……
我应该怎么办?
答案1
你有两个选择。第一个是\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}
第二个是使用可选参数\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}
发生这种情况是因为的内容\caption
是可移动的(即易碎的),因为它们可能被使用,lof
并且您必须\protect
在参数中使用命令(防止扩展)。