1

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}
8
  • Please edit your example, there is errors not related to the issue.
    – touhami
    Commented Jun 27, 2016 at 23:04
  • Use \protect\Xbar when in a section title.
    – egreg
    Commented Jun 27, 2016 at 23:08
  • I used \protect without success I get this message error in my system (Miktex 2.9) :
    – Aviroum
    Commented Jun 28, 2016 at 1:08
  • ! Missing number, treated as zero. <to be read again> } ! Missing number, treated as zero. <to be read again> } l.29 ... }\copy 2 }_{n_2}$}{18}{subsection.1.12.4} A number should have been here; I inserted 0'. (If you can't figure out why I needed to see a number, look up weird error' in the index to The TeXbook.)
    – Aviroum
    Commented Jun 28, 2016 at 1:09
  • ! Color stack action is missing. <to be read again> } l.29 ... }\copy 2 }_{n_2}$}{18}{subsection.1.12.4} The expected actions for \pdfcolorstack: set, push, pop, current I'll ignore the color stack command.
    – Aviroum
    Commented Jun 28, 2016 at 1:09

0

You must log in to answer this question.

Browse other questions tagged .