I think that most people are familiar with the fact that \bar creates a bar which is much too small, yet \overline creates a bar which is too long. I recently came across this excellent answer where the new command \widebar is defined, which gets the balance perfectly:

Illustration of different bar commands

Now the problem is, one may want to write \widebar{\widebar{A}} (when writing notes about the closure of a set being idempotent, for example). However when I attempt to do this I get the following:

Illustration of doubly used bar commands

Any ideas how I can go about a double \widebar which remains the same width? I appreciate any help.

Edit: I do not wish to use \overline{\overline{...}} or \bar{\bar{...}}, because the problems when they are used once are still present: namely that one is too small and the other is too large. I would like to obtain a double \widebar.

  • I tried making combinations of the three versions to see if something good would come up. Apparently not, but things do get weird if you do \bar{\widebar{A}}. – Phelype Oleinik Jan 30 '18 at 12:02
  • I have retracted my close. – Sebastiano Jan 30 '18 at 12:55
  • @PhelypeOleinik I did not try that. I got two A's for some reason. I wonder why that happens. – Luke Collins Jan 30 '18 at 13:23
  • @LukeCollins Yes, I didn't get anything good. But as I said, things get pretty weird with \bar{\widebar{A}} :P – Phelype Oleinik Jan 30 '18 at 13:32

Although I do not fully understand the macro \widebar defined in the answer you linked to, I have managed to modify it to work for other accents (including stacked accents).

Here is the code:


%% This code is a slight modification of Hendrik Vogt's \widebar %%
%% See: https://tex.stackexchange.com/questions/16337            %%
  \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:
%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:
%Use a separate algorithm for single symbols:
%Enable nesting of accents:
%If there's more than a single symbol, use the first character instead (see below):
    \if#42 \let\macc@nucleus\first@char \fi
%Determine the italic correction:
%Now \dimen@ is the italic correction of the symbol.
    \divide\dimen@ 3
%Now \@tempdima is the width of the symbol.
    \divide\@tempdima 10
%Now \dimen@ = (italic correction / 3) - (Breite / 10)
    \ifdim\dimen@>\z@ \dimen@0pt\fi
%The bar will be shortened in the case \dimen@<0 !
%Place the combined final kern (-\dimen@) if it is >0 or if a superscript follows:
      \ifdim\dimen@<\z@ \let\final@kern1\fi
      \if\final@kern1 \kern-\dimen@\fi
  \let\math@bgroup\@empty \let\math@egroup\macc@set@skewchar
  \mathsurround\z@ \frozen@everymath{\mathgroup\macc@group\relax}%
%The following initialises \macc@kerna and calls \mathaccent:
%If the argument consists of more than one symbol, and if the first token is
%a letter, use that letter for the computations:
    \ifcat\noexpand\first@char A\else



$\widebar{A \cup B}$
$\widebarbar{A \cup B}$
\verb$\widebar{A \cup B}$
\verb$\widebarbar{A \cup B}$


and here is the output: enter image description here

Note that this also works for other combinations of accents:


    \widehat{\widebar{A}} \neq \widehatbar{A}

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.