1

I think the font provided by the cochineal package is excellent, and I want to write documents using it, so I use the following in my preamble:

\usepackage[osf, p]{cochineal}
\usepackage[cochineal]{newtxmath}

However I dislike one particular change that was made in the math font, namely the way that italic f is changed. See the difference in the line \textit{f} versus $f$: the visual difference in regular italics and math mode letter 'f'

As far as I can tell this is one of three changes to the lowercase italic alphabet in math mode: the letters v and w are also changed to have better distinction from the greek letter nu.

My issue is that I strongly dislike this new letter f. I understand this may have been a stylistic choice by the designer but I much prefer the reclining, two-tailed f to this one.

I can force the math f to display as the regular italic one by writing \mathit{f} rather than just f, but this is obviously not very convenient.

How can I change the way that the lowercase letter f is displayed in math mode?


Here is a minimal document to reproduce this: (compiled with pdfTeX)

\documentclass{article}

\usepackage[osf, p]{cochineal}
\usepackage[cochineal]{newtxmath}

\begin{document}
Comparison: \textit{f} versus $f$.

Default: $f(x + y) = f(2x) + f(2y) - 1$.

Forced italic: $\mathit{f}(x + y) = \mathit{f}(2x) + \mathit{f}(2y) - 1$.
\end{document}
1

Declare a new math symbol font.

\documentclass{article}

\usepackage[osf, p]{cochineal}
\usepackage[cochineal]{newtxmath}

\DeclareSymbolFont{cochinealit}{\encodingdefault}{\familydefault}{m}{it}
\DeclareMathSymbol{f}{\mathalpha}{cochinealit}{`f}
\DeclareSymbolFontAlphabet{\mathit}{cochinealit}

\begin{document}

Comparison: \textit{f} versus $f$. Also $f^2$.

Default: $f(x + y) = f(2x) + f(2y) - 1$.

Forced italic: $\mathit{f}(x + y) = \mathit{f}(2x) + \mathit{f}(2y) - 1$.

Beware: $ff+f\/f$

Math roman: $\mathrm{f}$

\end{document}

There's a small catch, shown in the last line: you need something like f\/f if two consecutive f's appear in a formula.

enter image description here

| improve this answer | |
  • This is very explanatory. I wonder if there is any way to automatically supress ligatures here? – AJFarmar Sep 4 '19 at 23:19
  • @AJFarmar Not without much labor: the font needs to be duplicated to be loaded at a slightly (but unnoticeable) different size and its internal parameter be changed. – egreg Sep 4 '19 at 23:22
1

enter image description here

\documentclass{article}
\showoutput
\usepackage[osf, p]{cochineal}
\usepackage[cochineal]{newtxmath}
\sbox0{$\mathit{abc}$}


\mathcode`f=\numexpr\mathcode`f+"700\relax

\begin{document}


Comparison: \textit{f} versus $f$.

Default: $f(x + y) = f(2x) + f(2y) - 1$.

Forced italic: $\mathit{f}(x + y) = \mathit{f}(2x) + \mathit{f}(2y) - 1$.

Forced roman: $\mathrm{f}(x + y) = \mathrm{f}(2x) + \mathrm{f}(2y) - 1$.
\end{document}
| improve this answer | |
  • Did you forget something? – egreg Sep 4 '19 at 22:07
  • @egreg there are lots of things I didn't mention, if that is what you mean. – David Carlisle Sep 4 '19 at 22:17
0

One hacky way is to change the letter f to an active character, but only in math mode. This is described in this post on the TeX FAQ.

We do this by inserting this:

% Warning: there are serious issues with this; see below.
\begingroup
\lccode`~=`f
\lowercase{\endgroup
    \def~{\text{\textit{f}}}%
}%
\mathcode`f="8000

Put simply, this replace all occurences of the solitary letter f with \text{\textit{f}} in math mode.

So, here's a full example:

\documentclass{article}

\usepackage[osf, p]{cochineal}
\usepackage[cochineal]{newtxmath}


\begingroup
\lccode`~=`f
\lowercase{\endgroup
    \def~{\text{\textit{f}}}%
}%
\mathcode`f="8000

\begin{document}
Comparison: \textit{f} versus $f$.


Default: $f(x + y) = f(2x) + f(2y) - 1$.

Forced italic: $\mathit{f}(x + y) = \mathit{f}(2x) + \mathit{f}(2y) - 1$.
\end{document}

This produces the desired result:Result with catcode change

There are serious issues with this. In particular, \mathrm{f} displays strictly in italic, so for instance \liminf has a jarring italic f at the end.

For this reason, it may be preferable simply to define \newcommand\f{\mathit{f}} and simply write \f(x) instead of f(x).

| improve this answer | |

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.