12

When I am using \caption{$\E_\A(D)$ where $\ora{UF}\!_n$} inside a table environment there shows some errors.

Error :

Only one # is allowed per tab. ...crcr }}}_n$\relax }}{95}{table.caption.41}

Error :

Illegal parameter number in definition of \reserved@a. \caption{$\E_\A(D)$ where $\ora{UF}\!_n$}

Here \E stands for \mathscr{E}, \A stands for \text{\k{A}}, \ora for \overrightarrow.

Please help resolving this problem.

2
  • 2
    I think defining new commands of only one letter is a bad idea. However, please add a complete MWE (since you're member for more than one year you should know it's necessary).
    – CarLaTeX
    Commented Aug 24, 2017 at 5:05
  • This problem is similar in nature to \overleftarrow in subfigure caption. Different environment, but it's the same cause and therefore a similar solution.
    – Werner
    Commented Aug 24, 2017 at 15:04

1 Answer 1

15

\overrightarrow is not robust and breaks in moving arguments. Protect it with \protect:

\documentclass{article}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{caption}
\usepackage[mathscr]{euscript}
\usepackage[T1]{fontenc}
\usepackage{hyperref}
\newcommand*{\A}{\text{\k{A}}}
\newcommand*{\E}{\mathscr{E}}
\newcommand*{\ora}{\overrightarrow}
\begin{document}
\listoffigures
\begin{figure}
\caption{$\E_\A(D)$ where $\protect\ora{UF}\!_n$}
\end{figure}
\end{document}

Result

Alternative:

\DeclareRobustCommand*{\ora}{\overrightarrow}

Then \ora is robust and \protect is not needed.

This site is temporarily in read-only mode and not accepting new answers.

Not the answer you're looking for? Browse other questions tagged .