siunitx and XeLaTeX with OldStyle in text, but Lining in math
The attached example (not really an MWE) explains the problem better than I probably can here:
% !TeX program = xelatex
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
% detect-mode,
% detect-all,
% detect-display-math,
% math-rm=mathnormal,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
setmathfont[Numbers=Lining,Color=FF4422]{TeX Gyre Pagella Math}%lining as 'opposite' of OldStyle
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
However, textit{siunitx} does not detect the (surrounding) math font and sets its digits using the text font. Triggering textit{detect-all} does not change this either:
% sisetup{detect-all}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
Even explicitly requesting math-font does not seem to work:
begin{equation}
num{10} quad SI{20}{newton} quad SI[mode=text]{30}{newton} quad SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
end{equation}
Does not work outside of math mode either. These are expected to use math mode:
SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
This approach seems to work, since it will always use the math-font for its numbers and picks the text-font for its units, textbf{as long as we are in math-mode}:
sisetup{number-math-rm=mathnormal,unit-math-rm=mathrm,detect-mode}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
However, if we try to replicate the same for text-mode, an error is thrown:
% sisetup{number-text-rm=mathnormal,unit-text-rm=textrm}
% (SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
vspace{2baselineskip}
Also, if we use textit{mathrm} instead of textit{mathnormal}, it no longer works, and textit{siunitx} picks the text-font for its numbers again. I do not know the difference here and why it does this:
sisetup{number-math-rm=mathrm}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
end{document}
These two (Number 1 and Number 2) questions are similiar, but mode=text
does not do the trick, since then the numbers are set in OldStyle
. Inversely, mode=math
sets the units in (italic) math font.
This solution is looking for the same thing, but it seems different, since they don't use fontspec
/ unicode-math
.
I can stick with
sisetup{number-math-rm=mathnormal}
and it works for now, but it seems to be a very narrow solution that will fall apart quickly, once more sophisticated typesetting occurs. Is there a better solution?
xetex siunitx unicode-math oldstylenums liningnums
add a comment |
The attached example (not really an MWE) explains the problem better than I probably can here:
% !TeX program = xelatex
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
% detect-mode,
% detect-all,
% detect-display-math,
% math-rm=mathnormal,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
setmathfont[Numbers=Lining,Color=FF4422]{TeX Gyre Pagella Math}%lining as 'opposite' of OldStyle
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
However, textit{siunitx} does not detect the (surrounding) math font and sets its digits using the text font. Triggering textit{detect-all} does not change this either:
% sisetup{detect-all}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
Even explicitly requesting math-font does not seem to work:
begin{equation}
num{10} quad SI{20}{newton} quad SI[mode=text]{30}{newton} quad SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
end{equation}
Does not work outside of math mode either. These are expected to use math mode:
SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
This approach seems to work, since it will always use the math-font for its numbers and picks the text-font for its units, textbf{as long as we are in math-mode}:
sisetup{number-math-rm=mathnormal,unit-math-rm=mathrm,detect-mode}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
However, if we try to replicate the same for text-mode, an error is thrown:
% sisetup{number-text-rm=mathnormal,unit-text-rm=textrm}
% (SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
vspace{2baselineskip}
Also, if we use textit{mathrm} instead of textit{mathnormal}, it no longer works, and textit{siunitx} picks the text-font for its numbers again. I do not know the difference here and why it does this:
sisetup{number-math-rm=mathrm}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
end{document}
These two (Number 1 and Number 2) questions are similiar, but mode=text
does not do the trick, since then the numbers are set in OldStyle
. Inversely, mode=math
sets the units in (italic) math font.
This solution is looking for the same thing, but it seems different, since they don't use fontspec
/ unicode-math
.
I can stick with
sisetup{number-math-rm=mathnormal}
and it works for now, but it seems to be a very narrow solution that will fall apart quickly, once more sophisticated typesetting occurs. Is there a better solution?
xetex siunitx unicode-math oldstylenums liningnums
add a comment |
The attached example (not really an MWE) explains the problem better than I probably can here:
% !TeX program = xelatex
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
% detect-mode,
% detect-all,
% detect-display-math,
% math-rm=mathnormal,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
setmathfont[Numbers=Lining,Color=FF4422]{TeX Gyre Pagella Math}%lining as 'opposite' of OldStyle
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
However, textit{siunitx} does not detect the (surrounding) math font and sets its digits using the text font. Triggering textit{detect-all} does not change this either:
% sisetup{detect-all}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
Even explicitly requesting math-font does not seem to work:
begin{equation}
num{10} quad SI{20}{newton} quad SI[mode=text]{30}{newton} quad SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
end{equation}
Does not work outside of math mode either. These are expected to use math mode:
SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
This approach seems to work, since it will always use the math-font for its numbers and picks the text-font for its units, textbf{as long as we are in math-mode}:
sisetup{number-math-rm=mathnormal,unit-math-rm=mathrm,detect-mode}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
However, if we try to replicate the same for text-mode, an error is thrown:
% sisetup{number-text-rm=mathnormal,unit-text-rm=textrm}
% (SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
vspace{2baselineskip}
Also, if we use textit{mathrm} instead of textit{mathnormal}, it no longer works, and textit{siunitx} picks the text-font for its numbers again. I do not know the difference here and why it does this:
sisetup{number-math-rm=mathrm}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
end{document}
These two (Number 1 and Number 2) questions are similiar, but mode=text
does not do the trick, since then the numbers are set in OldStyle
. Inversely, mode=math
sets the units in (italic) math font.
This solution is looking for the same thing, but it seems different, since they don't use fontspec
/ unicode-math
.
I can stick with
sisetup{number-math-rm=mathnormal}
and it works for now, but it seems to be a very narrow solution that will fall apart quickly, once more sophisticated typesetting occurs. Is there a better solution?
xetex siunitx unicode-math oldstylenums liningnums
The attached example (not really an MWE) explains the problem better than I probably can here:
% !TeX program = xelatex
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
% detect-mode,
% detect-all,
% detect-display-math,
% math-rm=mathnormal,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
setmathfont[Numbers=Lining,Color=FF4422]{TeX Gyre Pagella Math}%lining as 'opposite' of OldStyle
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
However, textit{siunitx} does not detect the (surrounding) math font and sets its digits using the text font. Triggering textit{detect-all} does not change this either:
% sisetup{detect-all}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
Even explicitly requesting math-font does not seem to work:
begin{equation}
num{10} quad SI{20}{newton} quad SI[mode=text]{30}{newton} quad SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
end{equation}
Does not work outside of math mode either. These are expected to use math mode:
SI[mode=math]{40}{newton} quad SI[number-mode=math]{50}{newton}.
This approach seems to work, since it will always use the math-font for its numbers and picks the text-font for its units, textbf{as long as we are in math-mode}:
sisetup{number-math-rm=mathnormal,unit-math-rm=mathrm,detect-mode}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
However, if we try to replicate the same for text-mode, an error is thrown:
% sisetup{number-text-rm=mathnormal,unit-text-rm=textrm}
% (SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
vspace{2baselineskip}
Also, if we use textit{mathrm} instead of textit{mathnormal}, it no longer works, and textit{siunitx} picks the text-font for its numbers again. I do not know the difference here and why it does this:
sisetup{number-math-rm=mathrm}
(SI{40}{newton}) quad SI{40}{newton} quad (num{45.2(1)e-2}) quad num{45.32(12)e-27}
end{document}
These two (Number 1 and Number 2) questions are similiar, but mode=text
does not do the trick, since then the numbers are set in OldStyle
. Inversely, mode=math
sets the units in (italic) math font.
This solution is looking for the same thing, but it seems different, since they don't use fontspec
/ unicode-math
.
I can stick with
sisetup{number-math-rm=mathnormal}
and it works for now, but it seems to be a very narrow solution that will fall apart quickly, once more sophisticated typesetting occurs. Is there a better solution?
xetex siunitx unicode-math oldstylenums liningnums
xetex siunitx unicode-math oldstylenums liningnums
asked Dec 31 '18 at 13:09
Hans LolloHans Lollo
1005
1005
add a comment |
add a comment |
1 Answer
1
active
oldest
votes
You can define a new font family for the text mode (here in green):
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
number-text-rm=unitnumberfont,
detect-mode,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
newfontfamilyunitnumberfont{TeX Gyre Pagella Math}[Color=00FF00]
setmathfont[Color=FF4422,mathrm=sym]{TeX Gyre Pagella Math}%
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
begin{equation}
num{10} quad SI{20}{newton} quad SI{30}{newton} quad SI{40}{newton} quad SI{50}{newton}.
end{equation}
SI{40}{newton} quad SI{50}{newton}.
end{document}
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) saynumber-text-rm = mathfont
, which refers to the font set insetmathfont
? I also understand the meaning ofmathrm=sym
now. But sincesisetup
uses the newly created font family, wheremathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?
– Hans Lollo
Dec 31 '18 at 13:57
add a comment |
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
});
}
});
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468027%2fsiunitx-and-xelatex-with-oldstyle-in-text-but-lining-in-math%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
You can define a new font family for the text mode (here in green):
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
number-text-rm=unitnumberfont,
detect-mode,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
newfontfamilyunitnumberfont{TeX Gyre Pagella Math}[Color=00FF00]
setmathfont[Color=FF4422,mathrm=sym]{TeX Gyre Pagella Math}%
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
begin{equation}
num{10} quad SI{20}{newton} quad SI{30}{newton} quad SI{40}{newton} quad SI{50}{newton}.
end{equation}
SI{40}{newton} quad SI{50}{newton}.
end{document}
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) saynumber-text-rm = mathfont
, which refers to the font set insetmathfont
? I also understand the meaning ofmathrm=sym
now. But sincesisetup
uses the newly created font family, wheremathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?
– Hans Lollo
Dec 31 '18 at 13:57
add a comment |
You can define a new font family for the text mode (here in green):
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
number-text-rm=unitnumberfont,
detect-mode,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
newfontfamilyunitnumberfont{TeX Gyre Pagella Math}[Color=00FF00]
setmathfont[Color=FF4422,mathrm=sym]{TeX Gyre Pagella Math}%
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
begin{equation}
num{10} quad SI{20}{newton} quad SI{30}{newton} quad SI{40}{newton} quad SI{50}{newton}.
end{equation}
SI{40}{newton} quad SI{50}{newton}.
end{document}
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) saynumber-text-rm = mathfont
, which refers to the font set insetmathfont
? I also understand the meaning ofmathrm=sym
now. But sincesisetup
uses the newly created font family, wheremathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?
– Hans Lollo
Dec 31 '18 at 13:57
add a comment |
You can define a new font family for the text mode (here in green):
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
number-text-rm=unitnumberfont,
detect-mode,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
newfontfamilyunitnumberfont{TeX Gyre Pagella Math}[Color=00FF00]
setmathfont[Color=FF4422,mathrm=sym]{TeX Gyre Pagella Math}%
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
begin{equation}
num{10} quad SI{20}{newton} quad SI{30}{newton} quad SI{40}{newton} quad SI{50}{newton}.
end{equation}
SI{40}{newton} quad SI{50}{newton}.
end{document}
You can define a new font family for the text mode (here in green):
documentclass{scrreprt}
usepackage{siunitx}
sisetup{%
number-text-rm=unitnumberfont,
detect-mode,
}%
usepackage{unicode-math}
setmainfont[Numbers=OldStyle,Color=2244FF]{TeX Gyre Pagella}
newfontfamilyunitnumberfont{TeX Gyre Pagella Math}[Color=00FF00]
setmathfont[Color=FF4422,mathrm=sym]{TeX Gyre Pagella Math}%
linespread{1.3}
begin{document}
Wanted behaviour:
Text-Style numbers: 123456789. Math-Style numbers: (123456789).
In Display-Math, only the math font should be used. This works:
begin{equation}
f(x) = 23.1(2) times 10^{-2} x^2
end{equation}
begin{equation}
f(x) = num{23.1(2)e-2} x^2
end{equation}
begin{equation}
num{10} quad SI{20}{newton} quad SI{30}{newton} quad SI{40}{newton} quad SI{50}{newton}.
end{equation}
SI{40}{newton} quad SI{50}{newton}.
end{document}
answered Dec 31 '18 at 13:36
Ulrike FischerUlrike Fischer
192k8300682
192k8300682
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) saynumber-text-rm = mathfont
, which refers to the font set insetmathfont
? I also understand the meaning ofmathrm=sym
now. But sincesisetup
uses the newly created font family, wheremathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?
– Hans Lollo
Dec 31 '18 at 13:57
add a comment |
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) saynumber-text-rm = mathfont
, which refers to the font set insetmathfont
? I also understand the meaning ofmathrm=sym
now. But sincesisetup
uses the newly created font family, wheremathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?
– Hans Lollo
Dec 31 '18 at 13:57
1
1
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) say
number-text-rm = mathfont
, which refers to the font set in setmathfont
? I also understand the meaning of mathrm=sym
now. But since sisetup
uses the newly created font family, where mathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?– Hans Lollo
Dec 31 '18 at 13:57
Thank you, this is looking very clean. What keeps us from using the already existing math font family, and why is a new one required? Can't we (pseudo-command) say
number-text-rm = mathfont
, which refers to the font set in setmathfont
? I also understand the meaning of mathrm=sym
now. But since sisetup
uses the newly created font family, where mathrm=sym
is not set, what does it do for us now? Is it just a precaution / best practice?– Hans Lollo
Dec 31 '18 at 13:57
add a comment |
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.
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f468027%2fsiunitx-and-xelatex-with-oldstyle-in-text-but-lining-in-math%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
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