1

How can I define a command that would put hat with parenthesis over its argument? The command has to work in a math mode. I know that question is very similar to this one but I did not manage to modify any of the proposed solutions to fit my problem.

1
  • 1
    Welcome to TeX.SE. Commented Oct 11, 2022 at 12:58

1 Answer 1

2

Linespacing will be badly affected if you use this inline, but you could make a new accent with the accents package. To get the spacing within the parentheses right I used trimbox from the trimclip package to remove whitespace below the ^.

enter image description here

\documentclass{article} \usepackage{accents} \usepackage{trimclip} \DeclareRobustCommand*{\phat}[1]{{\accentset{(\!\trimbox{0pt 1.1ex}{\ensuremath{\string^}}\!)}{#1}}} \begin{document} $\phat{A}$ \end{document} 

For a wider hat, you could use \scalebox with a horizontal (but not vertical) stretch factor. Here it is set to 2:

\DeclareRobustCommand*{\phat}[1]{{\accentset{(\!\!\trimbox{0pt 1.1ex}{\scalebox{2}[1]{\ensuremath{\string^}}}\!\!)}{#1}}} 

enter image description here

2
  • Thanks a lot! Is it possible, though, to make the "hat" wider? Commented Oct 11, 2022 at 13:04
  • @wedelfach: You could use \scalebox{1.5}[1]{\ensuremath{\string^}} (or any stretch factor you want). Commented Oct 11, 2022 at 13:29

You must log in to answer this question.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.