5

When I try to use Hendrik Vogt's "\widebar" from Can I get a \widebar without using the mathabx package?, it happens that the output of

\widebar{\mathcal{I}}_{x}=\widebar{\mathcal{I}_{x}}

becomes as follows:

enter image description here.

The inside index "x" changes. But if I add an extra "{ }" like \widebar{{\mathcal{I}}_{x}}, I will get the right form

enter image description here

I have no idea how to fix the code to make it work without extra "{ }". Could anyone help please?

  • 1
    Welcome to TeX.SE. – Mico Jun 20 '22 at 03:02
  • 1
    What is your use case for including the subscript term (here: x) in the argument of \widebar? – Mico Jun 20 '22 at 03:03
  • 1
    Welcome to tex.sx. \mathcal appears to be acting here more like \bfseries than \textbf when those are used in text. If that is so (and I haven't searched out their definitions), the use of the extra braces can't be avoided. – barbara beeton Jun 20 '22 at 03:06
  • 1
    @Mico If I understand correctly, my use case is writing a mathematic survey about integral closure of ideal sheaves. – Zhijian Chen Jun 20 '22 at 03:14
  • crosslink: somewhat related question, https://tex.stackexchange.com/questions/84041/why-does-calm-n-give-m?noredirect=1&lq=1 – user202729 Jan 21 '23 at 11:50

1 Answers1

2

You get the same output as

\mathcal{I_x}

just with overline above it. You can use

\widerbar{{\mathcal{I}}_{x}}

to fix it.

I reproduce the behavior in the example code below to show that, apart from the wrong symbol being used, the output is the same as with \overline.

\documentclass{article}
\usepackage{amsmath}

\makeatletter \let\save@mathaccent\mathaccent \newcommand\if@single[3]{% \setbox0\hbox{${\mathaccent"0362{#1}}^H$}% \setbox2\hbox{${\mathaccent"0362{\kern0pt#1}}^H$}% \ifdim\ht0=\ht2 #3\else #2\fi } %The bar will be moved to the right by a half of \macc@kerna, which is computed by amsmath: \newcommand\rel@kern[1]{\kern#1\dimexpr\macc@kerna} %If there's a superscript following the bar, then no negative kern may follow the bar; %an additional {} makes sure that the superscript is high enough in this case: \newcommand\widebar[1]{@ifnextchar^{{\wide@bar{#1}{0}}}{\wide@bar{#1}{1}}} %Use a separate algorithm for single symbols: \newcommand\wide@bar[2]{\if@single{#1}{\wide@bar@{#1}{#2}{1}}{\wide@bar@{#1}{#2}{2}}} \newcommand*\wide@bar@[3]{% \begingroup \def\mathaccent##1##2{% %Enable nesting of accents: \let\mathaccent\save@mathaccent %If there's more than a single symbol, use the first character instead (see below): \if#32 \let\macc@nucleus\first@char \fi %Determine the italic correction: \setbox\z@\hbox{$\macc@style{\macc@nucleus}{}$}% \setbox\tw@\hbox{$\macc@style{\macc@nucleus}{}{}$}% \dimen@\wd\tw@ \advance\dimen@-\wd\z@ %Now \dimen@ is the italic correction of the symbol. \divide\dimen@ 3 @tempdima\wd\tw@ \advance@tempdima-\scriptspace %Now @tempdima is the width of the symbol. \divide@tempdima 10 \advance\dimen@-@tempdima %Now \dimen@ = (italic correction / 3) - (Breite / 10) \ifdim\dimen@>\z@ \dimen@0pt\fi %The bar will be shortened in the case \dimen@<0 ! \rel@kern{0.6}\kern-\dimen@ \if#31 \overline{\rel@kern{-0.6}\kern\dimen@\macc@nucleus\rel@kern{0.4}\kern\dimen@}% \advance\dimen@0.4\dimexpr\macc@kerna %Place the combined final kern (-\dimen@) if it is >0 or if a superscript follows: \let\final@kern#2% \ifdim\dimen@<\z@ \let\final@kern1\fi \if\final@kern1 \kern-\dimen@\fi \else \overline{\rel@kern{-0.6}\kern\dimen@#1}% \fi }% \macc@depth@ne \let\math@bgroup@empty \let\math@egroup\macc@set@skewchar \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}% \macc@set@skewchar\relax \let\mathaccentV\macc@nested@a %The following initialises \macc@kerna and calls \mathaccent: \if#31 \macc@nested@a\relax111{#1}% \else %If the argument consists of more than one symbol, and if the first token is %a letter, use that letter for the computations: \def\gobble@till@marker##1\endmarker{}% \futurelet\first@char\gobble@till@marker#1\endmarker \ifcat\noexpand\first@char A\else \def\first@char{}% \fi \macc@nested@a\relax111{\first@char}% \fi \endgroup } \makeatother

\linespread{1.44}

\begin{document}

$\mathcal{I_x}$

$\widebar{\mathcal{I}}{x}=\widebar{\mathcal{I}{x}}$ \quad $\widebar{\mathcal{I}}_{x}=\overline{\mathcal{I_x}}$

$\widebar{\mathcal{I}}{x}=\widebar{{\mathcal{I}}{x}}$ \quad $\widebar{\mathcal{I}}{x}=\overline{\mathcal{I}{x}}$

\end{document}

enter image description here

In the third line you can see that the output of \widebar{{\mathcal{I}}_{x}} and of \overline{\mathcal{I}_{x}} are identical.

Compare with the following, based on https://tex.stackexchange.com/a/364929/4427

\documentclass{article}
\usepackage{amsmath}

\DeclareFontFamily{U}{mathx}{\hyphenchar\font45} \DeclareFontShape{U}{mathx}{m}{n}{ <-> mathx10 }{} \DeclareSymbolFont{mathx}{U}{mathx}{m}{n} \DeclareFontSubstitution{U}{mathx}{m}{n} \DeclareMathAccent{\widebar}{\mathalpha}{mathx}{"73}

\linespread{1.44}

\begin{document}

$\widebar{\mathcal{I}}{x}=\widebar{\mathcal{I}{x}}$

$\widebar{\mathcal{I}}{x}=\overline{\mathcal{I}{x}}$

\end{document}

enter image description here

egreg
  • 1,121,712