3

I used tikz to define some custom symbols. They work fine in the text, but I have problems using them in a section title:

\documentclass{article}
\usepackage{tikz}
\newcommand{\customSymbol}[1]
{%
  \begin{tikzpicture}[#1]
    \draw (0,0) -- (1,0);
  \end{tikzpicture}
}

\begin{document}
This works fine: \customSymbol{}.
% \section{This does not work: \customSymbol{}}
\end{document}

What can I do to fix this?

jpb
  • 501

1 Answers1

3
 \DeclareRobustCommand\customSymbol[1]{...}
  • 2
    I think you are missing curly braces around the command name (i.e. use \DeclareRobustCommand{\customSymbol}[1]{...} instead). For other newbies like me, this general discussion of robust vs. new command might also be helpful – Addison Klinke Jul 26 '20 at 00:05