Different fonts inside and outside math-mode

The name of the pictureThe name of the pictureThe name of the pictureClash Royale CLAN TAG#URR8PPP












5















When processing the simple file:



documentclassreport

begindocument
1234567890

$1234567890$
enddocument


with pdflatex one get a PDF with one font only (CMR10), but when processing with either xelatex or lualatex the produced PDF use Latin Modern Roman 10 outside math-mode and CMR10 inside.



What are the reasons behind this?










share|improve this question

















  • 5





    Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

    – Henri Menke
    Feb 23 at 1:09












  • What is the tricky part of getting the TU encoding in math-mode?

    – Paulo Ney
    Feb 23 at 1:19






  • 1





    The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

    – Henri Menke
    Feb 23 at 1:28











  • @HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

    – Davislor
    Feb 23 at 1:35











  • To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

    – Ruixi Zhang
    Feb 23 at 2:10
















5















When processing the simple file:



documentclassreport

begindocument
1234567890

$1234567890$
enddocument


with pdflatex one get a PDF with one font only (CMR10), but when processing with either xelatex or lualatex the produced PDF use Latin Modern Roman 10 outside math-mode and CMR10 inside.



What are the reasons behind this?










share|improve this question

















  • 5





    Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

    – Henri Menke
    Feb 23 at 1:09












  • What is the tricky part of getting the TU encoding in math-mode?

    – Paulo Ney
    Feb 23 at 1:19






  • 1





    The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

    – Henri Menke
    Feb 23 at 1:28











  • @HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

    – Davislor
    Feb 23 at 1:35











  • To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

    – Ruixi Zhang
    Feb 23 at 2:10














5












5








5








When processing the simple file:



documentclassreport

begindocument
1234567890

$1234567890$
enddocument


with pdflatex one get a PDF with one font only (CMR10), but when processing with either xelatex or lualatex the produced PDF use Latin Modern Roman 10 outside math-mode and CMR10 inside.



What are the reasons behind this?










share|improve this question














When processing the simple file:



documentclassreport

begindocument
1234567890

$1234567890$
enddocument


with pdflatex one get a PDF with one font only (CMR10), but when processing with either xelatex or lualatex the produced PDF use Latin Modern Roman 10 outside math-mode and CMR10 inside.



What are the reasons behind this?







xetex pdftex luatex






share|improve this question













share|improve this question











share|improve this question




share|improve this question










asked Feb 23 at 1:05









Paulo NeyPaulo Ney

1,1551017




1,1551017







  • 5





    Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

    – Henri Menke
    Feb 23 at 1:09












  • What is the tricky part of getting the TU encoding in math-mode?

    – Paulo Ney
    Feb 23 at 1:19






  • 1





    The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

    – Henri Menke
    Feb 23 at 1:28











  • @HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

    – Davislor
    Feb 23 at 1:35











  • To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

    – Ruixi Zhang
    Feb 23 at 2:10













  • 5





    Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

    – Henri Menke
    Feb 23 at 1:09












  • What is the tricky part of getting the TU encoding in math-mode?

    – Paulo Ney
    Feb 23 at 1:19






  • 1





    The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

    – Henri Menke
    Feb 23 at 1:28











  • @HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

    – Davislor
    Feb 23 at 1:35











  • To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

    – Ruixi Zhang
    Feb 23 at 2:10








5




5





Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

– Henri Menke
Feb 23 at 1:09






Because LaTeX now supports UTF-8 by default, the font should also be able to to reflect this. Therefore, when using Xe/LuaTeX, the LaTeX format automatically switches to TU font encoding. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead. In math mode this is a little more tricky that is why standard OML/OMS encoding is retained. I don't know whether there exist any plans to make UTF-8 available in math as well.

– Henri Menke
Feb 23 at 1:09














What is the tricky part of getting the TU encoding in math-mode?

– Paulo Ney
Feb 23 at 1:19





What is the tricky part of getting the TU encoding in math-mode?

– Paulo Ney
Feb 23 at 1:19




1




1





The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

– Henri Menke
Feb 23 at 1:28





The traditional setup was to have different families, i.e. mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which switches mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time.

– Henri Menke
Feb 23 at 1:28













@HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

– Davislor
Feb 23 at 1:35





@HenriMenke Whoops, thanks for pointing out my misreading of the example. Want to post your answer?

– Davislor
Feb 23 at 1:35













To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

– Ruixi Zhang
Feb 23 at 2:10






To complement to @HenriMenke’s comment, mathbf switches to bold upright text font while mathcal switches to OMS math font. Math font encoding was never really actively developed (see LaTeX font encoding guide p. 3, the last paragraphs before Section 1.3).

– Ruixi Zhang
Feb 23 at 2:10











2 Answers
2






active

oldest

votes


















6














Since TeX Live 2018 LaTeX now UTF-8 by default, because the “Unicode revolution” has been completed1. This makes it superfluous to add usepackage[utf8]inputenc when using pdfLaTeX.



The UTF-8 support in pdfLaTeX is fake however and you cannot expect to get a meaningful output when you paste arbitrary UTF-8 characters into the input, because the underlying pdfTeX engine is inherently limited to 8-bit encoding.



This is quite different with Xe/LuaTeX. These engines support UTF-8 by default2. Traditional TeX fonts are very limited in the glyphs they offer3. This is definitely not enough to describe UTF-8, so the font also has to cover the full UTF-8 range4. To this end the TU encoding was introduced.



By default LaTeX loads the Computer Modern (CM) family of fonts. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead.



Now the question remains, why is Latin Modern not used in math mode? That is because in math mode things are a little more tricky. The traditional setup was to have different families and commands like mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which swaps mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time. That is why currently standard OML/OMS encoding is retained.




1 Everyone stores their files in UTF-8 nowadays and most software understands UTF-8. Just think of Emojies (they are everywhere). They are part of UTF-8, so everything that can display Emojies has to support UTF-8.
2 in fact LuaTeX will reject your file if it is not UTF-8
3 T1 encoding can only encode 256 glyphs
4 whether the font has the required glyph is another question






share|improve this answer























  • The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

    – Davislor
    Feb 23 at 5:52












  • I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

    – Davislor
    Feb 23 at 5:53











  • The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

    – Ulrike Fischer
    Feb 23 at 8:09











  • @UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

    – Henri Menke
    Feb 23 at 8:27











  • The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

    – Ulrike Fischer
    Feb 23 at 8:32


















4














The font setup for text and math are quite separated tasks in TeX -- text fonts has to care about things like accented chars and hyphenation, math fonts about lots of symbols and correct placement of sup- and superscripts.



Your example uses only a few glyph which in pdftex can be taken from the same font. But if you add e.g. a minus (-), or chars (abc) the used fonts will be different inside and outside math. And if you switch to the recommended T1-encoding for the text with usepackage[T1]fontenc there will be even differences for the numbers.



For the unicode engines there is a difference even in the default setup as the use of a unicode font as text font is more or less mandatory to get accented chars and hyphenation right (see e.g. https://tex.stackexchange.com/a/470987/2388). So at the begin of 2017 the LaTeX-kernel changed the default for this engines so that users weren't forced to load fontspec anymore.



In math hyphenation and accented chars are not really relevant, so the legacy math setup works find in the unicode engine. But even if the math setup is changed to use an unicode font it wouldn't be the same as the textfont but e.g. latin modern math.






share|improve this answer

























  • I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

    – Paulo Ney
    Feb 23 at 16:45











  • A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

    – Ulrike Fischer
    Feb 23 at 16:55











  • You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

    – Ulrike Fischer
    Feb 23 at 17:00











  • I do understand now and unicode-math is part of the equation. Many thanks for the details.

    – Paulo Ney
    Feb 23 at 17:06










Your Answer








StackExchange.ready(function()
var channelOptions =
tags: "".split(" "),
id: "85"
;
initTagRenderer("".split(" "), "".split(" "), channelOptions);

StackExchange.using("externalEditor", function()
// Have to fire editor after snippets, if snippets enabled
if (StackExchange.settings.snippets.snippetsEnabled)
StackExchange.using("snippets", function()
createEditor();
);

else
createEditor();

);

function createEditor()
StackExchange.prepareEditor(
heartbeatType: 'answer',
autoActivateHeartbeat: false,
convertImagesToLinks: false,
noModals: true,
showLowRepImageUploadWarning: true,
reputationToPostImages: null,
bindNavPrevention: true,
postfix: "",
imageUploader:
brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
allowUrls: true
,
onDemand: true,
discardSelector: ".discard-answer"
,immediatelyShowMarkdownHelp:true
);



);













draft saved

draft discarded


















StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476254%2fdifferent-fonts-inside-and-outside-math-mode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown

























2 Answers
2






active

oldest

votes








2 Answers
2






active

oldest

votes









active

oldest

votes






active

oldest

votes









6














Since TeX Live 2018 LaTeX now UTF-8 by default, because the “Unicode revolution” has been completed1. This makes it superfluous to add usepackage[utf8]inputenc when using pdfLaTeX.



The UTF-8 support in pdfLaTeX is fake however and you cannot expect to get a meaningful output when you paste arbitrary UTF-8 characters into the input, because the underlying pdfTeX engine is inherently limited to 8-bit encoding.



This is quite different with Xe/LuaTeX. These engines support UTF-8 by default2. Traditional TeX fonts are very limited in the glyphs they offer3. This is definitely not enough to describe UTF-8, so the font also has to cover the full UTF-8 range4. To this end the TU encoding was introduced.



By default LaTeX loads the Computer Modern (CM) family of fonts. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead.



Now the question remains, why is Latin Modern not used in math mode? That is because in math mode things are a little more tricky. The traditional setup was to have different families and commands like mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which swaps mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time. That is why currently standard OML/OMS encoding is retained.




1 Everyone stores their files in UTF-8 nowadays and most software understands UTF-8. Just think of Emojies (they are everywhere). They are part of UTF-8, so everything that can display Emojies has to support UTF-8.
2 in fact LuaTeX will reject your file if it is not UTF-8
3 T1 encoding can only encode 256 glyphs
4 whether the font has the required glyph is another question






share|improve this answer























  • The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

    – Davislor
    Feb 23 at 5:52












  • I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

    – Davislor
    Feb 23 at 5:53











  • The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

    – Ulrike Fischer
    Feb 23 at 8:09











  • @UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

    – Henri Menke
    Feb 23 at 8:27











  • The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

    – Ulrike Fischer
    Feb 23 at 8:32















6














Since TeX Live 2018 LaTeX now UTF-8 by default, because the “Unicode revolution” has been completed1. This makes it superfluous to add usepackage[utf8]inputenc when using pdfLaTeX.



The UTF-8 support in pdfLaTeX is fake however and you cannot expect to get a meaningful output when you paste arbitrary UTF-8 characters into the input, because the underlying pdfTeX engine is inherently limited to 8-bit encoding.



This is quite different with Xe/LuaTeX. These engines support UTF-8 by default2. Traditional TeX fonts are very limited in the glyphs they offer3. This is definitely not enough to describe UTF-8, so the font also has to cover the full UTF-8 range4. To this end the TU encoding was introduced.



By default LaTeX loads the Computer Modern (CM) family of fonts. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead.



Now the question remains, why is Latin Modern not used in math mode? That is because in math mode things are a little more tricky. The traditional setup was to have different families and commands like mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which swaps mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time. That is why currently standard OML/OMS encoding is retained.




1 Everyone stores their files in UTF-8 nowadays and most software understands UTF-8. Just think of Emojies (they are everywhere). They are part of UTF-8, so everything that can display Emojies has to support UTF-8.
2 in fact LuaTeX will reject your file if it is not UTF-8
3 T1 encoding can only encode 256 glyphs
4 whether the font has the required glyph is another question






share|improve this answer























  • The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

    – Davislor
    Feb 23 at 5:52












  • I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

    – Davislor
    Feb 23 at 5:53











  • The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

    – Ulrike Fischer
    Feb 23 at 8:09











  • @UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

    – Henri Menke
    Feb 23 at 8:27











  • The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

    – Ulrike Fischer
    Feb 23 at 8:32













6












6








6







Since TeX Live 2018 LaTeX now UTF-8 by default, because the “Unicode revolution” has been completed1. This makes it superfluous to add usepackage[utf8]inputenc when using pdfLaTeX.



The UTF-8 support in pdfLaTeX is fake however and you cannot expect to get a meaningful output when you paste arbitrary UTF-8 characters into the input, because the underlying pdfTeX engine is inherently limited to 8-bit encoding.



This is quite different with Xe/LuaTeX. These engines support UTF-8 by default2. Traditional TeX fonts are very limited in the glyphs they offer3. This is definitely not enough to describe UTF-8, so the font also has to cover the full UTF-8 range4. To this end the TU encoding was introduced.



By default LaTeX loads the Computer Modern (CM) family of fonts. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead.



Now the question remains, why is Latin Modern not used in math mode? That is because in math mode things are a little more tricky. The traditional setup was to have different families and commands like mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which swaps mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time. That is why currently standard OML/OMS encoding is retained.




1 Everyone stores their files in UTF-8 nowadays and most software understands UTF-8. Just think of Emojies (they are everywhere). They are part of UTF-8, so everything that can display Emojies has to support UTF-8.
2 in fact LuaTeX will reject your file if it is not UTF-8
3 T1 encoding can only encode 256 glyphs
4 whether the font has the required glyph is another question






share|improve this answer













Since TeX Live 2018 LaTeX now UTF-8 by default, because the “Unicode revolution” has been completed1. This makes it superfluous to add usepackage[utf8]inputenc when using pdfLaTeX.



The UTF-8 support in pdfLaTeX is fake however and you cannot expect to get a meaningful output when you paste arbitrary UTF-8 characters into the input, because the underlying pdfTeX engine is inherently limited to 8-bit encoding.



This is quite different with Xe/LuaTeX. These engines support UTF-8 by default2. Traditional TeX fonts are very limited in the glyphs they offer3. This is definitely not enough to describe UTF-8, so the font also has to cover the full UTF-8 range4. To this end the TU encoding was introduced.



By default LaTeX loads the Computer Modern (CM) family of fonts. The CMR10 font is not available in TU encoding (and never will be), therefore its closest relative Latin Modern Roman 10 is loaded instead.



Now the question remains, why is Latin Modern not used in math mode? That is because in math mode things are a little more tricky. The traditional setup was to have different families and commands like mathbf, mathcal, etc. switched to a different family. This is no longer possible in Unicode, because all the symbols come from a single font. Therefore the family switching approach doesn't work anymore and has to be replaced by a much more complex system which swaps mathcodes back and forth. This is implemented in the unicode-math package. You'll also notice why this is problematic because with the unicode-math package TeX is suddenly much slower due to having to reassign thousands of mathcodes all the time. That is why currently standard OML/OMS encoding is retained.




1 Everyone stores their files in UTF-8 nowadays and most software understands UTF-8. Just think of Emojies (they are everywhere). They are part of UTF-8, so everything that can display Emojies has to support UTF-8.
2 in fact LuaTeX will reject your file if it is not UTF-8
3 T1 encoding can only encode 256 glyphs
4 whether the font has the required glyph is another question







share|improve this answer












share|improve this answer



share|improve this answer










answered Feb 23 at 4:37









Henri MenkeHenri Menke

77k8169283




77k8169283












  • The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

    – Davislor
    Feb 23 at 5:52












  • I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

    – Davislor
    Feb 23 at 5:53











  • The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

    – Ulrike Fischer
    Feb 23 at 8:09











  • @UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

    – Henri Menke
    Feb 23 at 8:27











  • The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

    – Ulrike Fischer
    Feb 23 at 8:32

















  • The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

    – Davislor
    Feb 23 at 5:52












  • I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

    – Davislor
    Feb 23 at 5:53











  • The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

    – Ulrike Fischer
    Feb 23 at 8:09











  • @UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

    – Henri Menke
    Feb 23 at 8:27











  • The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

    – Ulrike Fischer
    Feb 23 at 8:32
















The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

– Davislor
Feb 23 at 5:52






The change was upstream, in the April 2018 release of LaTex, if you want to get specific about when and where. It’s therefore true of all distributions.

– Davislor
Feb 23 at 5:52














I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

– Davislor
Feb 23 at 5:53





I still personally include usepackage[utf8]inputenc in case someone tries to compile on an older distro.

– Davislor
Feb 23 at 5:53













The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

– Ulrike Fischer
Feb 23 at 8:09





The switch to TU for the unicode engines was at the begin of 2017, it is rather unrelated to the UTF8 default (added in 2018) which affects only pdftex and the other 8bit engines.

– Ulrike Fischer
Feb 23 at 8:09













@UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

– Henri Menke
Feb 23 at 8:27





@UlrikeFischer Only the team can answer this, but I'm rather sure that the TU encoding was a prerequisite for the UTF-8 default. I'm relatively sure that there is a clear relation between them.

– Henri Menke
Feb 23 at 8:27













The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

– Ulrike Fischer
Feb 23 at 8:32





The "UTF8 default" as you call it does what inputenc does in the document and inputenc is not relevant for the unicode engines.

– Ulrike Fischer
Feb 23 at 8:32











4














The font setup for text and math are quite separated tasks in TeX -- text fonts has to care about things like accented chars and hyphenation, math fonts about lots of symbols and correct placement of sup- and superscripts.



Your example uses only a few glyph which in pdftex can be taken from the same font. But if you add e.g. a minus (-), or chars (abc) the used fonts will be different inside and outside math. And if you switch to the recommended T1-encoding for the text with usepackage[T1]fontenc there will be even differences for the numbers.



For the unicode engines there is a difference even in the default setup as the use of a unicode font as text font is more or less mandatory to get accented chars and hyphenation right (see e.g. https://tex.stackexchange.com/a/470987/2388). So at the begin of 2017 the LaTeX-kernel changed the default for this engines so that users weren't forced to load fontspec anymore.



In math hyphenation and accented chars are not really relevant, so the legacy math setup works find in the unicode engine. But even if the math setup is changed to use an unicode font it wouldn't be the same as the textfont but e.g. latin modern math.






share|improve this answer

























  • I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

    – Paulo Ney
    Feb 23 at 16:45











  • A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

    – Ulrike Fischer
    Feb 23 at 16:55











  • You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

    – Ulrike Fischer
    Feb 23 at 17:00











  • I do understand now and unicode-math is part of the equation. Many thanks for the details.

    – Paulo Ney
    Feb 23 at 17:06















4














The font setup for text and math are quite separated tasks in TeX -- text fonts has to care about things like accented chars and hyphenation, math fonts about lots of symbols and correct placement of sup- and superscripts.



Your example uses only a few glyph which in pdftex can be taken from the same font. But if you add e.g. a minus (-), or chars (abc) the used fonts will be different inside and outside math. And if you switch to the recommended T1-encoding for the text with usepackage[T1]fontenc there will be even differences for the numbers.



For the unicode engines there is a difference even in the default setup as the use of a unicode font as text font is more or less mandatory to get accented chars and hyphenation right (see e.g. https://tex.stackexchange.com/a/470987/2388). So at the begin of 2017 the LaTeX-kernel changed the default for this engines so that users weren't forced to load fontspec anymore.



In math hyphenation and accented chars are not really relevant, so the legacy math setup works find in the unicode engine. But even if the math setup is changed to use an unicode font it wouldn't be the same as the textfont but e.g. latin modern math.






share|improve this answer

























  • I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

    – Paulo Ney
    Feb 23 at 16:45











  • A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

    – Ulrike Fischer
    Feb 23 at 16:55











  • You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

    – Ulrike Fischer
    Feb 23 at 17:00











  • I do understand now and unicode-math is part of the equation. Many thanks for the details.

    – Paulo Ney
    Feb 23 at 17:06













4












4








4







The font setup for text and math are quite separated tasks in TeX -- text fonts has to care about things like accented chars and hyphenation, math fonts about lots of symbols and correct placement of sup- and superscripts.



Your example uses only a few glyph which in pdftex can be taken from the same font. But if you add e.g. a minus (-), or chars (abc) the used fonts will be different inside and outside math. And if you switch to the recommended T1-encoding for the text with usepackage[T1]fontenc there will be even differences for the numbers.



For the unicode engines there is a difference even in the default setup as the use of a unicode font as text font is more or less mandatory to get accented chars and hyphenation right (see e.g. https://tex.stackexchange.com/a/470987/2388). So at the begin of 2017 the LaTeX-kernel changed the default for this engines so that users weren't forced to load fontspec anymore.



In math hyphenation and accented chars are not really relevant, so the legacy math setup works find in the unicode engine. But even if the math setup is changed to use an unicode font it wouldn't be the same as the textfont but e.g. latin modern math.






share|improve this answer















The font setup for text and math are quite separated tasks in TeX -- text fonts has to care about things like accented chars and hyphenation, math fonts about lots of symbols and correct placement of sup- and superscripts.



Your example uses only a few glyph which in pdftex can be taken from the same font. But if you add e.g. a minus (-), or chars (abc) the used fonts will be different inside and outside math. And if you switch to the recommended T1-encoding for the text with usepackage[T1]fontenc there will be even differences for the numbers.



For the unicode engines there is a difference even in the default setup as the use of a unicode font as text font is more or less mandatory to get accented chars and hyphenation right (see e.g. https://tex.stackexchange.com/a/470987/2388). So at the begin of 2017 the LaTeX-kernel changed the default for this engines so that users weren't forced to load fontspec anymore.



In math hyphenation and accented chars are not really relevant, so the legacy math setup works find in the unicode engine. But even if the math setup is changed to use an unicode font it wouldn't be the same as the textfont but e.g. latin modern math.







share|improve this answer














share|improve this answer



share|improve this answer








edited Feb 23 at 10:33

























answered Feb 23 at 9:34









Ulrike FischerUlrike Fischer

196k8302689




196k8302689












  • I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

    – Paulo Ney
    Feb 23 at 16:45











  • A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

    – Ulrike Fischer
    Feb 23 at 16:55











  • You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

    – Ulrike Fischer
    Feb 23 at 17:00











  • I do understand now and unicode-math is part of the equation. Many thanks for the details.

    – Paulo Ney
    Feb 23 at 17:06

















  • I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

    – Paulo Ney
    Feb 23 at 16:45











  • A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

    – Ulrike Fischer
    Feb 23 at 16:55











  • You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

    – Ulrike Fischer
    Feb 23 at 17:00











  • I do understand now and unicode-math is part of the equation. Many thanks for the details.

    – Paulo Ney
    Feb 23 at 17:06
















I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

– Paulo Ney
Feb 23 at 16:45





I do understand most of your argument, but I do NOT understand why the alphabet inside math-mode NEEDS to be any different from the one used in text-mode. In fact MTProII is a counter-example to that -- it uses numerals, roman and italics that are copy-cats of Time News Roman, and even though they are different fonts you end up with uniform text and formulas. Latin Modern is not Computer Modern (and never will be) and mixing the two offends the senses of almost anyone - it is that visible. Observe that we are not talking about a lot of character - is just alphabet and numbers mostly.

– Paulo Ney
Feb 23 at 16:45













A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

– Ulrike Fischer
Feb 23 at 16:55





A math font is not only a bunch of glyphs. Much more important are values needed for the placement. A standard text font in tex has normally only 7 fontdimens (e.g. the em and ex values), math fonts much more, e.g. the amount a subscript need to be shifted. Check e.g. "C Legacy TEX font dimensions" in the unicode-math documentation.

– Ulrike Fischer
Feb 23 at 16:55













You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

– Ulrike Fischer
Feb 23 at 17:00





You can quite easily get latin modern also inside math, both with legacy fonts and with unicode-math. That this is not the default is not due to some necessity but only due to the conservative nature of latex - defaults are not easily changed.

– Ulrike Fischer
Feb 23 at 17:00













I do understand now and unicode-math is part of the equation. Many thanks for the details.

– Paulo Ney
Feb 23 at 17:06





I do understand now and unicode-math is part of the equation. Many thanks for the details.

– Paulo Ney
Feb 23 at 17:06

















draft saved

draft discarded
















































Thanks for contributing an answer to TeX - LaTeX Stack Exchange!


  • Please be sure to answer the question. Provide details and share your research!

But avoid


  • Asking for help, clarification, or responding to other answers.

  • Making statements based on opinion; back them up with references or personal experience.

To learn more, see our tips on writing great answers.




draft saved


draft discarded














StackExchange.ready(
function ()
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f476254%2fdifferent-fonts-inside-and-outside-math-mode%23new-answer', 'question_page');

);

Post as a guest















Required, but never shown





















































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown

































Required, but never shown














Required, but never shown












Required, but never shown







Required, but never shown






Popular posts from this blog

How to check contact read email or not when send email to Individual?

Bahrain

Postfix configuration issue with fips on centos 7; mailgun relay