4

So $\hat x$ and $\widehat x$ give upper hats of different length, however, unlike \overbrace{} had an \underbrace{}, one sometimes needs an \uhat and \uwidehat.

What is the best (cleanest, fewest conflicts with possible usage, e.g, as interval endpoints in a definite integral, ie, scale properly) to get a underhat and underwide hat (same hats, but flipped, and below the symbol in question).

I suppose one can use

\documentclass{article}\usepackage{amsmath,mathtools,amssymb}
\newcommand*{\uhat}{\underset{\mathrel{\text{\raisebox{.25ex}{\rotatebox[origin=c]{180}{$\wedge$}}}}}}
\newcommand*{\uwidehat}{\underset{\mathrel{\text{\raisebox{.25ex}{\rotatebox[origin=c]{180}{$\widehat{~}$}}}}}}
\begin{document}
$\uhat x ~ ~ \uwidehat X$
\end{document}

But there must be better ways.

  • 1
    you say "flipped", and your code indicates a 180 degree rotation. i'd interpret that to mean an "undercheck" and an "under widecheck" (not that they exist either). can you clarify which way the "point" is supposed to point? (unicode has an "under circumflex" at U+032D. is this what you want for the narrow one?) – barbara beeton May 2 '15 at 20:21
  • i used 180 for no particular reason, just as a temporary macro for the paper im writing now. i suppose I should have scaled them by -1 to actually strictly reflect them to get them lining up below with the ordinary versions. i don't know if U+032D will look proper or not in general, perhaps that is one option. the key thing is not to load any language packages or require XeTeX. – Guido Jorg May 2 '15 at 20:31
  • 1
    the reason i asked about the shape + name is that U+032D should be in the xits/stix fonts with the command name \textsubcircum. (confusing name, i know, but it was already assigned in the tipa fonts, and there has been an effort made to avoid assigning additional names. take a look in the comprehensive symbols list.) – barbara beeton May 2 '15 at 20:42
  • so \usepackage{tipa}? I looked in the symbols list, many convenient marks there. But on linux i seem not to have tipa.sty installed. What general category of packages is it in? Because tipa.sty I see needs some other files to work – Guido Jorg May 2 '15 at 21:05
2

For the under hat just use \underaccent{\check}; for the wide under hat, typeset the wide hat over a phantom of the argument, then flip it vertically, raising it by a suitable amount. Then overlap the flipped accent to the text.

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\usepackage{graphicx}

\newcommand{\uhat}{\underaccent{\check}}

\newcommand{\uwidehat}[1]{%
  \mathpalette\douwidehat{#1}%
}

\makeatletter
\newcommand{\douwidehat}[2]{%
  \sbox0{$\m@th#1\widehat{\hphantom{#2}}$}%
  \sbox2{$\m@th#1x$}
  \sbox4{$\m@th#1#2$}
  \dimen0=\ht0
  \advance\dimen0 -.8\ht2
  \dimen2=\dp4
  \rlap{%
    \raisebox{\dimexpr\dimen0-\dimen2}{%
      \scalebox{1}[-1]{\box0}%
    }%
  }%
  {#2}%
}
\makeatother

\begin{document}

$\hat{a}\uhat{a}$

$\uwidehat{aaa}\uwidehat{fg}X_{\uwidehat{abc}}$

\end{document}

enter image description here

According to Barbara Beeton's, Unicode recommends that accents should not be flipped if set below. So I provide also a non flipped version.

\documentclass{article}
\usepackage{amsmath}
\usepackage{accents}
\usepackage{graphicx}

\newcommand{\uhat}{\underaccent{\hat}}

\newcommand{\uwidehat}[1]{%
  \mathpalette\douwidehat{#1}%
}
\makeatletter
\newcommand{\douwidehat}[2]{%
  \sbox0{$\m@th#1\widehat{\hphantom{#2}}\vphantom{t}$}%
  \sbox2{$t$}%
  \dimen2=\ht0
  \advance\dimen2 -\ht2
  \sbox2{$#2$}%
  \dimen0=\ht0
  \rlap{%
    \raisebox{\dimexpr-\dimen0-\dp2-1pt}[0pt][\dimexpr\dimen2+\dp2]{\box0}%
  }
  {#2}%
}
\makeatother

\begin{document}

$\hat{a}\uhat{a}$

$\uwidehat{aaa}\uwidehat{fg}X_{\uwidehat{abc}}$

\end{document}

enter image description here

Note that the whole construction is turned into an ordinary atom (which always happens with other underaccents), so in case you want to use it for an operation or relation symbol, you have to say something like

$a \mathbin{\uwidehat{+}} b$

that will produce

enter image description here

I used the second version, but it's the same for the flipped version. (Thanks to wipet for noting the problem in the original version.)

  • but i wouldn't call that a "wide hat"; i'd call it a "wide check". there's some terminology that needs to be normalized here. (cf unicode U+032C which has the name "combining caron below".) – barbara beeton May 2 '15 at 21:22
  • @barbarabeeton I used the same term as the OP. – egreg May 2 '15 at 21:23
  • The $a \uwidehat+ b$ will not work. – wipet May 3 '15 at 5:52
  • 1
    @wipet for noting (verb to note). – egreg May 3 '15 at 10:09
3

You can easily do that with the accents package:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{mathtools,amssymb}

\usepackage{accents}
\newcommand*{\uhat}[1]{\underaccent{\hat}{#1}}
\newcommand*{\uwidehat}[1]{\underaccent{\widehat{\hphantom{#1}}}{#1}}

\begin{document}

  $ \uhat{x}\enspace \uwidehat X$

\end{document} 

enter image description here

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.