I have posted this question \bar and \overline
When I put \Xbar
in tableofcontents I get this error :
Missing number, treated as zero. ... }\copy 2 }_{n_2}$}{18}{subsection.1.12.4}
what's wrong ?
Any advice ?
My MWE
\documenclass{article}
\usepackage{amsmath,amsfonts,mathtools}
\usepackage{hyperref}
\makeatletter
\newcommand*{\Xbar}{%
\mathpalette\@Xbar{}%
}
\newcommand*{\@Xbar}[2]{%
% #1: math style
% #2: unused (empty)
\sbox0{$#1\mathrm{X}\m@th$}%
\sbox2{$#1X\m@th$}%
\rlap{%
\hbox to\wd2{%
\hfill
$\overline{%
\vrule width 0pt height\ht0 %
\vrule width 0pt height\ht0 %
\kern\wd0 %
}$%
}%
}%
\copy2 %
}
\makeatother
\begin{document}
\tableofcontents
\section{Test of \texorpdfstring{$\Xbar_{n_1}$}{} and \texorpdfstring{$\Xbar_{n_2}{}}
\section{another section}
\section{Third section}
$\Xbar$
\end{document}
\protect\Xbar
when in a section title.0'. (If you can't figure out why I needed to see a number, look up
weird error' in the index to The TeXbook.)