0

A well-known trick in LaTeX if one wants to have math definition that is typeset in "math font", but actually appears as a single word, is to surround it with \mathit{}.

For example, compare these two renderings of functional typesetting:

two renderings of functional typesetting

The one on the bottom uses \mathit{}, which has the effect of squishing the characters together. This is particularly noticeable between f and u.

If we now switch to eulervm, we want to achieve the same. Sadly, it does not really work:

enter image description here

We can see that on top, the Euler font is used. On the bottom, it is not, since instead the regular italic text font is used. Before, we did not notice this, since the CM font for math and italic text is (almost?) the same.

The first proplem is that Euler is an upright font. Thus, we should use \mathrm instead of \mathit.

But this does not improve things, since it still uses the default text font. We can, of course, try to switch the default text font to find one that more closely resembles the Euler characters. But which font should one use for this use case? Is there a way to just directly use the Euler font, but have it kern letters properly?

PS: Since a commentor requested it, here is the code used for both pictures (the difference being one line):

\documentclass{article}
\usepackage{amsmath}
\usepackage{eulervm} % comment this line out for the first picture
\begin{document}

\begin{align*}
&functional\ typesetting\\
&\mathit{functional\ typesetting}\\
&\mathrm{functional\ typesetting} % bonus: using \mathrm, not shown in the pictures
\end{align*}

\end{document}
7
  • 1
    Please show the code that gives rise to the screenshot of interest, starting with \documentclass and ending with \end{document}.
    – Mico
    Commented Jul 20, 2023 at 21:33
  • 3
    \mathit selects the text italic font, not a math font. Commented Jul 20, 2023 at 21:44
  • @Mico I've added the code. Commented Jul 20, 2023 at 22:04
  • 1
    @JoJoModding or rather it looks different, as you show. It's not the same letters with adjusted spacing. You could, I suppose, construct a virtual text font based on euler, but with tighter spacing, but it seems less needed than with a normal math italic, it's already evenly spaced and mimcking handwriting does not have ligatures, so your example text is already readable Commented Jul 20, 2023 at 22:11
  • 1
    @JoJoModding several letters have different shapes notably v to better distinguish from Greek, and almost all have larger sidebearings. the shapes and sidebearings are not accessible from tex. to tex, it's simply a different font, there is no sense in which \mathit "has the effect of squishing the characters together." to tex it's simply a font change. As I say, you could in principle make a virtual font with smaller sidebearings, but I don't know of an existing one Commented Jul 20, 2023 at 23:13

2 Answers 2

6

When D. Knuth created his Computer Modern family, he used his Metafont for rendering the shapes. The sources for this rendering are "functions" (for each letters one function). These functions describe the shapes using Besier curves and metrics values are set too. The functions depend on many global parameters. There are 62 global parameters in Computer Modern family. A minor change of parameter values and rendering via the same functions results to the different font. For example \rm and \bf shapes are rendered with the same source functions but only different global parameters. The optical sizes are created with the same idea: only the global parameters are changed. It means that the different fonts from Computer Modern family (there are 75 fonts in it) were created by tuning the global Metafont parameters, no using only linear transformations.

There is text italic font in Computer Modern family: cmti10 and math italic font cmmi10. They are different fonts (they were rendered with different Metafont parameters) and they are intended for different purposes. The cmmi10 font is used in math mode for denoting variables and other math stuff, the cmti10 font is used for texts in italics. You show the cmmi10 in your first line (we must to read your line as f times u times n times c etc. because they are variables f, u, n, c and if they are one next to other then it means a product of variables in math formula). The cmti10 is shown in your second line (we read it as "functional typesetting"). You can see that not only spaces are different but also the shapes in your first line are slightly wider (due to the different Metafont parameters values).

The Euler font was created only for math formulas, no for text usage. So there is only math font zeurm10 and there isn't an alternative font for text usage. You can try to use it in text, but you must to copy the \fontdimen parameter used in text for spacing from another text font because these parameters are zero in math fonts:

\font\euler=zeurm10
\font\cmr=cmr10

This is normal text {\euler this is Euler without spacing parameters}.

\fontdimen2\euler=\fontdimen2\cmr % basic space
\fontdimen3\euler=\fontdimen3\cmr % stretching value
\fontdimen3\euler=\fontdimen4\cmr % shrinking value
\fontdimen7\euler=\fontdimen7\cmr % extra stretching value

And now: {\euler this is Euler with spacing parameters from cmr10}

\letterspacefont\eulersp\euler -30 % use it in pdfTeX only

\fontdimen2\eulersp=\fontdimen2\cmr % basic space
\fontdimen3\eulersp=\fontdimen3\cmr % stretching value
\fontdimen3\eulersp=\fontdimen4\cmr % shrinking value
\fontdimen7\eulersp=\fontdimen7\cmr % extra stretching value

And font: {\eulersp with smaller spaces between letters} 

\bye

The last example with \eulersp shows how you can set smaller spaces between letters, which is needed in text font. The \letterspacefont pdfTeX primitive was used here. If you are using another TeX engine then you have to use a different method for letter spacing.

Because the Euler font was intended for math typesetting, some important characters needed for text typesetting is missing here, for example comma, dot etc. So, if you want to use Euler fonts in text, you have to use a virtual font which combines the letters from various raw fonts.

3
  • +1 for letterspacefont I suggested a vf in comments but the primitive is surely easier (if you just want a few words not a full font setup) and I'd totally forgotten about it as a primitive for pdftex) Commented Jul 21, 2023 at 8:32
  • +1. The essential message here is "The Euler font was created only for math formulas, no[t] for text usage." And I note that in Fraktur text, emphasis is applied by adding letterspacing. Commented Jul 21, 2023 at 17:04
  • This is great, thanks! I only want to use it to typeset some special math identifiers (that should look "mathy" but also not be read as a multiplication) so this works great. Commented Jul 22, 2023 at 14:41
0

Using @wipet's trick with \letterspacefont, you can build the following command:

\newcommand{\eulerrm}[1]{\mathchoice%
{{\letterspacefont\eulersp=\the\textfont1 -80\relax\text{\eulersp{#1}}}}%
{{\letterspacefont\eulersp=\the\textfont1 -80\relax\text{\eulersp{#1}}}}%
{{\letterspacefont\eulersp=\the\scriptfont1 -110\relax\text{\eulersp{#1}}}}%
{{\letterspacefont\eulersp=\the\scriptscriptfont1 -130\relax\text{\eulersp{#1}}}}}

As long as the math font is the euler font, this command can be used in math mode and typesets the characters closer together. The amount by which the inter-letter space is decreased is defined by the values 80 (for normal text), 110 (for subscripts) and 130 (for double subscripts). A value of 80 means that the characters are 8% closer. These are my personal preferences, your mileage may vary.

The above command is very hacky, but I could not find a better way. I am happy to learn of a better way. One way in which it is hacky is that the characters are actually typeset as text, so using math inside \eulerrm is not supported.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .