Is it possible to produce a hat symbol for a capital letter, between
Code: Select all
$\hat{M}$ and $\widehat{M}
Thank you.
Code: Select all
$\hat{M}$ and $\widehat{M}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p
Code: Select all
\documentclass{article}\newlength\hwhatcwidth% half wide hat's contents width\newlength\hwhatuwidth% half wide hat's contents width with contents upright\newcommand*\halfwidehat[1]{%\settowidth\hwhatcwidth{\ensuremath{#1}}%\settowidth\hwhatuwidth{\ensuremath{\mathrm{#1}}}%\addtolength\hwhatuwidth{-\hwhatcwidth}% now difference between upright/real% since the real width is usually wider for standard math italics font, this will be negative\makebox[0pt][l]{% overprint its contents with what follows after its closing brace\kern\dimexpr0.25\hwhatcwidth-0.667\hwhatuwidth\relax% left offset for shortened \widehat\ensuremath{\widehat{\vphantom{#1}\rule{0.5\hwhatcwidth}{0pt}}}% put a \widehat over nothing% this `nothing' is as high as the string to be put underneath (\vphantom{#1), but only half as wide}#1% overprint \makebox with given string}%\halfwidehat{string}\begin{document}$\hat{M}$ and $\widehat{M}$perhaps\ $\halfwidehat{M}$$\halfwidehat{ABC}$\end{document}
\halfwidehat
on strings wider than 3 characters, otherwise parts of the string will drop out of the hat Code: Select all
\usepackage{lmodern} %don't know if it is necessary\newcommand{\wh}{\widehat}
Code: Select all
\wh{} instead of \hat{} or \widehar{}
Code: Select all
\newcommand{\wh}{\widehat}
NEW: TikZ book now 40% off at Amazon.com for a short time.
And: Currently, Packt sells ebooks for $4.99 each if you buy 5 of their over 1000 ebooks. If you choose only a single one, $9.99. How about combining 3 LaTeX books with Python, gnuplot, mathplotlib, Matlab, ChatGPT or other AI books? Epub and PDF. Bundle (3 books, add more for higher discount): https://packt.link/MDH5p