Conflict between hand-made symbol and caption environment [duplicate]

I tried to create my own hand-made symbol by modifying the standard symbol "{".

It works... but not always. LaTeX barfs at me when my hand-made symbol is inside a caption environment in a figure.

\documentclass{report}

\newcommand{\bmark}{\raisebox{.53ex}{\rule{.2em}{.1ex}}}
\newcommand{\bopen}{{\ooalign{\{\cr\hfil\bmark\hfil\cr}}}

\begin{document}
\begin{figure}
\caption{My caption. $\bopen$}
\end{figure}
\end{document}


How can I fix this? Is there a better way of doing this?

• The macro \bopen is "fragile", in the LaTeX-specific meaning of the word. Either \protect it or \robustify it if you wish to use it in the argument of commands such as \caption. – Mico Feb 27 '18 at 15:17
• Off-topic: You use \textbraceleft instead of \{ as the first item in the argument of \ooalign. – Mico Feb 27 '18 at 15:20

Just \protect the \ooalign.

Note: you don't necessarily need math mode for \bopen either, nor the extra surrounding group, but I left them intact as the OP had specified.

\documentclass{report}

\newcommand{\bmark}{\raisebox{.53ex}{\rule{.2em}{.1ex}}}
\newcommand{\bopen}{{\protect\ooalign{\{\cr\hfil\bmark\hfil\cr}}}

\begin{document}
\begin{figure}
\caption{My caption. $\bopen$}
\end{figure}
\end{document}