TransWikia.com

Cannot add hat over smashed hat

TeX - LaTeX Asked on December 15, 2020

Why does the following simple code raise Undefined control sequence error?

documentclass{article}
usepackage{amsmath}
begin{document}
$hat{smash{hat f}}$
end{document}

3 Answers

As Steven says using smash here probably doesn't work well in any case, but it should not give an internal command undefined error.

I haven't fully traced it but at one point the internal accent nesting counter gets set to 5 presumably because it is confused by teh mathchoice in smash evaluating its argument 4 times (in each of the styles display, text, script and scriptscript)

The simplest, although not necessarily best fix is to give the internal lengths a default setting of 0pt so if you end up here they just add a zero kern rather than error.

documentclass{article}
usepackage{amsmath}
makeatletter
letmacc@kernaz@
letmacc@kernbz@
letmacc@nucleus@empty
makeatother
begin{document}

$hat{smash{hat f}}$
end{document}

Correct answer by David Carlisle on December 15, 2020

Trying to place a hat on a smashed quantity makes no sense, as the height of the smashed quantity is set to 0pt. In the 3rd line, I emulate such an attempt. Yuck. First 2 lines are recommended...either remove the smash, or only smash at the end of the process.

documentclass{article}
usepackage{amsmath}
parskip 1ex
begin{document}
$hat{hat f}$ no smash

$smash{hat{hat f}}$ final result smashed

$sbox0{$smash{hat f}$}hat{box0}$ hatting a smash makes no sense
end{document}

enter image description here

Answered by Steven B. Segletes on December 15, 2020

Thank Steven and David for your answers.

The simplest fix I found so far is usepackage{accents}. (Though unfortunately for me, accents is not compatible with a conference template I'm using.)

Answered by Tianren Liu on December 15, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP