I was trying to use Hendrik Vogt’s \widebar in my re-definitions of some macros in the actuarialsymbol package. The package offers commands that come with * variants which produce \bar{<principal symbol>}, and some that come with ** variants which produce \ddot{<principal symbol>}.

When I replaced the * variant with \overline{<principal symbol>}, everything worked just fine. But when I tried \widebar{<principal symbol>}, the starred command seemed to gobble the first optional argument and left some weird spaces in front of the principal symbol.

Here is a MWE:

\usepackage{actuarialsymbol} % actuarialsymbol loads amsmath internally

% Hendrik Vogt's \widebar: https://tex.stackexchange.com/a/60253/164314
% Depends on the amsmath package!
  \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#32 \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
% End of \widebar


\linespread{1.5}\selectfont % More visible

% Default:
$\Ax[u|][2]{\termxn}$, $\Ax*[u|]{\termxn}$, $\Ax*[u|][2]{\termxn}$, works fine.

% Change the one starred version to \overline:

$\Ax[u|][2]{\termxn}$, $\Ax*[u|]{\termxn}$, $\Ax*[u|][2]{\termxn}$, works fine as well.

% Change the one starred version to \widebar:

$\Ax[u|][2]{\termxn}$, $\Ax*[u|]{\termxn}$, $\Ax*[u|][2]{\termxn}$, what happened?


EDIT Here is the output of the MWE using pdfLaTeX: LaTeX output of MWE

  • Calling directly the internal symbol construction function @actsymboldoes not help. The bad interaction between \widebar and actuarialsymbol must be at this line in actuarialsymbol.sty that positions the left subscript and superscript next to an invisible symbol: \mathopen{\vphantom{\textstyle #4}^{\box\tw@}\sb{\box\@ne}}. I don't know how \widehatgobbles the subscript, though. @hendrik-vogt? – Vincent Goulet Jun 5 '18 at 2:30

Your Answer

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

Browse other questions tagged or ask your own question.