0

How to write

$\hat{f}$

to obtain hat above italics f in better way?

enter image description here

\documentclass[article]{report}
\usepackage{amssymb}     
\usepackage{amsthm}        
\usepackage[T1]{fontenc}
\pdfmapfile{+winfonts.map}
\renewcommand\rmdefault{trebuchet}
\usepackage[cm]{sfmath}

\begin{document}
\begin{equation}
\hat{f}(\xi) 
\end{equation}
\end{document}
Sebastiano
  • 54,118
Carly
  • 3
  • 1
    Welcome to TeX.SE. The problem doesn't happen with \documentclass{article} \begin{document} $\hat{f}$ \end{document}. Please post a minimal working example (MWE) if you want others to be able to help you. – frougon Apr 11 '20 at 12:24
  • I added the MWE – Carly Apr 11 '20 at 12:29
  • 1
    Please read the link I gave. That is a minimal working example: `\documentclass{article} \usepackage[cm]{sfmath}

    \begin{document}

    $\hat{f}$

    \end{document}(BTW,\mathrel` doesn't make much sense for a function).

    – frougon Apr 11 '20 at 12:39
  • @frougon Excuse me. The cause is mine :-( – Sebastiano Apr 11 '20 at 12:40
  • 1
    @Sebastiano Just for the \mathrel, not the rest... – frougon Apr 11 '20 at 12:41
  • What is wrong with MWE? \mathrel works but not with trebuchet font as in my example. I need this font. – Carly Apr 11 '20 at 12:42
  • 1
    A minimal working example is supposed to be minimal. :-) Non-minimal examples distract the attention, obscure the real problem and waste the time of every person trying to help you. You see, I have only done that so far: giving you instruction and link, reducing your example to the real issue and trying to convince you. No time to investigate the real issue itself, and I'll have to go (personal constraints, alas). – frougon Apr 11 '20 at 12:42
  • I edited it. My question is about the hat in equation mode in trebuchet font. – Carly Apr 11 '20 at 12:46
  • @Carly Now it is correct without \mathrel :-). You read with a lot attenction the comment of frougon. – Sebastiano Apr 11 '20 at 12:47
  • \renewcommand\rmdefault{trebuchet} has no influence on the $\hat{f}$, AFAICT. It is \sfdefault that matters according to the documentation in sfmath.sty. – frougon Apr 11 '20 at 12:53
  • When I delete \usepackage[cm]{sfmath} it works but it is not trebuchet. – Carly Apr 11 '20 at 13:06
  • I don't have your winfonts.map file, but to the best of my knowledge, the f in your example is typeset in Computer Modern Sans Serif, aka cmss. You can use \showoutput to make sure. I get \OT1/cmss/m/sl/10 f with your example, which confirms my assertion. This is not a math font, and is used in horizontal mode inside an \hbox! No wonder math accents can't be placed correctly in these conditions. – frougon Apr 11 '20 at 13:21
  • Sorry, I do not understand what should I do. – Carly Apr 11 '20 at 13:22
  • I can't say “do this and you'll have what you want” (I don't know which math font you want...), but what is clear is that this setup uses a hack which prevents the math accent mechanism from working. – frougon Apr 11 '20 at 13:24
  • OK, thank you I will not use trebuchet. – Carly Apr 11 '20 at 13:26
  • I don't know trebuchet except by name, maybe it is fine. But I repeat: in your example, the f doesn't use trebuchet unless your winfonts.map overrides things in a way I can't guess (which is not clearly visible in your screenshot, anyway). – frougon Apr 11 '20 at 13:28
  • You can try sansmathaccent, like this: `\documentclass{article} \usepackage{sfmath} \usepackage{sansmathaccent}

    \begin{document}

    $\hat{f}$

    \end{document}` (found here).

    – frougon Apr 11 '20 at 13:35
  • Thank you very much – Carly Apr 11 '20 at 13:49

1 Answers1

1
  1. I don't think Trebuchet can be used as a real TeX math font (see here for a very partial workaround, i.e.: 7 symbols taken from Trebuchet plus, I guess, many letters and digits).

  2. Neiter the \hat{f} nor the \xi from your example are typeset using Trebuchet, as the \showoutput command reveals (\OT1/cmss/m/sl/10 is cmssi10, Computer Modern Sans Serif “Italic”; \OML/cmm/m/it/10 is cmmi10, Computer Modern Math Italic):

    .......\OT1/cmss/m/sl/10 f
    .....\OT1/cmss/m/n/10 (
    .....\OML/cmm/m/it/10 ^^X
    .....\kern0.46007
    .....\OT1/cmss/m/n/10 )
    
  3. That said, the sansmathaccent package appears to allow one to typeset maths in sans serif with correctly-placed accents when the sfmath package is used:

    \documentclass{article}
    \usepackage{sfmath}
    \usepackage{sansmathaccent}
    
    \begin{document}
    
    $\hat{f}$
    
    \end{document}
    

enter image description here

Note this excerpt from the sansmathaccent manual:

sansmathaccent is not a standalone package; it is a package to correct a specific problem that appears in beamer and sfmath. If neither of those packages is used, sansmathaccent will do nothing.
Observe also that sansmathaccent will only work with Computer Modern sans serif math text; if you use a package such as helvet or pxfonts to change the sans serif math font away from the default, sansmathaccent will not help you.

frougon
  • 24,283
  • 1
  • 32
  • 55