Problems with numbers (result of calculations) alignment using siunitx package inside tabular...
How to avoid grep command finding commented out strings in the source file?
Is thermodynamics only applicable to systems in equilibrium?
System.QueryException: unexpected token: results
How do I tell my manager that his code review comment is wrong?
Is it appropriate to refer to God as "It"?
Shoteh in the gemara
Why was Germany not as successful as other Europeans in establishing overseas colonies?
Stark VS Thanos
A non-technological, repeating, visible object in the sky, holding its position in the sky for hours
Printing a string when grep does not get a match
CRT Oscilloscope - part of the plot is missing
Field Length Validation for Desktop Application which has maximum 1000 characters
Plagiarism in class. Could it be my fault?
Binary Numbers Magic Trick
What happened to Rhaegal?
Declining lunch invitation from new work because I will be fasting
Copying spell into spellbook time required, consecutive or disparate?
Method and way to highlight the validation message in the web page by using Selenium IDE
Any examples of headwear for races with animal ears?
Hang 20lb projector screen on hardieplank
How to creep the reader out with what seems like a normal person?
Is Cola "probably the best-known" Latin word in the world? If not, which might it be?
What word means "to make something obsolete"?
Write to EXCEL from SQL DB using VBA script
Problems with numbers (result of calculations) alignment using siunitx package inside tabular environment
siunitx: Alignment Problems with numbers in parenthesisTabular and grid typesettingProblems with siunitx package?siunitx tabular numbers with separated uncertaintyBasic S Column Alignment with siunitx packagephantomsection inside tabular: alignment problems`siunitx` interferes with `array` and `tabular environment`Problems loading siunitx package“Undefined control sequence” Regression table from StataTable using siunitx number alignment affecting rows without numbers
I'm having some problems when try align numbers, results from calculations, using siunitx package. That is my code.
documentclass{article}
usepackage{siunitx}
usepackage{fp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[2][2]{%
FPevaltempKtoC{round((#2-273.15):#1)}%
num{tempKtoC}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & {KelvinToCelsius{10.3}} \
200.34 & {KelvinToCelsius{200.34}} \
500.26 & {KelvinToCelsius{500.26}} \
1200.5 & {KelvinToCelsius[1]{1200.5}}\
12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}
Which produces:

Note that the numbers in second column don't be align.
How to solve this?
tables siunitx
add a comment |
I'm having some problems when try align numbers, results from calculations, using siunitx package. That is my code.
documentclass{article}
usepackage{siunitx}
usepackage{fp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[2][2]{%
FPevaltempKtoC{round((#2-273.15):#1)}%
num{tempKtoC}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & {KelvinToCelsius{10.3}} \
200.34 & {KelvinToCelsius{200.34}} \
500.26 & {KelvinToCelsius{500.26}} \
1200.5 & {KelvinToCelsius[1]{1200.5}}\
12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}
Which produces:

Note that the numbers in second column don't be align.
How to solve this?
tables siunitx
Maybe section 7.2 "Expanding content in tables" of thesiunitxmanual can help you.
– leandriis
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago
add a comment |
I'm having some problems when try align numbers, results from calculations, using siunitx package. That is my code.
documentclass{article}
usepackage{siunitx}
usepackage{fp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[2][2]{%
FPevaltempKtoC{round((#2-273.15):#1)}%
num{tempKtoC}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & {KelvinToCelsius{10.3}} \
200.34 & {KelvinToCelsius{200.34}} \
500.26 & {KelvinToCelsius{500.26}} \
1200.5 & {KelvinToCelsius[1]{1200.5}}\
12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}
Which produces:

Note that the numbers in second column don't be align.
How to solve this?
tables siunitx
I'm having some problems when try align numbers, results from calculations, using siunitx package. That is my code.
documentclass{article}
usepackage{siunitx}
usepackage{fp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[2][2]{%
FPevaltempKtoC{round((#2-273.15):#1)}%
num{tempKtoC}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & {KelvinToCelsius{10.3}} \
200.34 & {KelvinToCelsius{200.34}} \
500.26 & {KelvinToCelsius{500.26}} \
1200.5 & {KelvinToCelsius[1]{1200.5}}\
12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}
Which produces:

Note that the numbers in second column don't be align.
How to solve this?
tables siunitx
tables siunitx
asked 3 hours ago
GRSousaJrGRSousaJr
3257
3257
Maybe section 7.2 "Expanding content in tables" of thesiunitxmanual can help you.
– leandriis
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago
add a comment |
Maybe section 7.2 "Expanding content in tables" of thesiunitxmanual can help you.
– leandriis
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago
Maybe section 7.2 "Expanding content in tables" of the
siunitx manual can help you.– leandriis
2 hours ago
Maybe section 7.2 "Expanding content in tables" of the
siunitx manual can help you.– leandriis
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago
add a comment |
2 Answers
2
active
oldest
votes
Use the full power of expl3; the KelvinToCelsius command must be expandable and you can have it even with an optional argument.
Using fpeval frees you from fp.
documentclass{article}
usepackage{siunitx,xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
NewExpandableDocumentCommand{KelvinToCelsius}{O{2}m}{%
fpeval{round(#2-273.15,#1)}%
}
begin{document}
begin{tabular}{
S[table-format=5.2]
S[table-format=5.2]
}
toprule
{si{kelvin}} & {si{celsius}} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
1200.5 & KelvinToCelsius[1]{1200.5}\
12345 & KelvinToCelsius[0]{12345} \
bottomrule
end{tabular}
end{document}

add a comment |
The commands must be expandable so that siunitx sees "pure numbers". Better use the xfp package for the calculations and avoid optional arguments.
documentclass{article}
usepackage{siunitx}
usepackage{xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[1]{% no optional argument
fpeval{round((#1-273.15)/2,2)}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
%1200.5 & {KelvinToCelsius[1]{1200.5}}\
%12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}

Why no optional argument?;-)
– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
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%2f488277%2fproblems-with-numbers-result-of-calculations-alignment-using-siunitx-package-i%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
Use the full power of expl3; the KelvinToCelsius command must be expandable and you can have it even with an optional argument.
Using fpeval frees you from fp.
documentclass{article}
usepackage{siunitx,xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
NewExpandableDocumentCommand{KelvinToCelsius}{O{2}m}{%
fpeval{round(#2-273.15,#1)}%
}
begin{document}
begin{tabular}{
S[table-format=5.2]
S[table-format=5.2]
}
toprule
{si{kelvin}} & {si{celsius}} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
1200.5 & KelvinToCelsius[1]{1200.5}\
12345 & KelvinToCelsius[0]{12345} \
bottomrule
end{tabular}
end{document}

add a comment |
Use the full power of expl3; the KelvinToCelsius command must be expandable and you can have it even with an optional argument.
Using fpeval frees you from fp.
documentclass{article}
usepackage{siunitx,xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
NewExpandableDocumentCommand{KelvinToCelsius}{O{2}m}{%
fpeval{round(#2-273.15,#1)}%
}
begin{document}
begin{tabular}{
S[table-format=5.2]
S[table-format=5.2]
}
toprule
{si{kelvin}} & {si{celsius}} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
1200.5 & KelvinToCelsius[1]{1200.5}\
12345 & KelvinToCelsius[0]{12345} \
bottomrule
end{tabular}
end{document}

add a comment |
Use the full power of expl3; the KelvinToCelsius command must be expandable and you can have it even with an optional argument.
Using fpeval frees you from fp.
documentclass{article}
usepackage{siunitx,xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
NewExpandableDocumentCommand{KelvinToCelsius}{O{2}m}{%
fpeval{round(#2-273.15,#1)}%
}
begin{document}
begin{tabular}{
S[table-format=5.2]
S[table-format=5.2]
}
toprule
{si{kelvin}} & {si{celsius}} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
1200.5 & KelvinToCelsius[1]{1200.5}\
12345 & KelvinToCelsius[0]{12345} \
bottomrule
end{tabular}
end{document}

Use the full power of expl3; the KelvinToCelsius command must be expandable and you can have it even with an optional argument.
Using fpeval frees you from fp.
documentclass{article}
usepackage{siunitx,xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
NewExpandableDocumentCommand{KelvinToCelsius}{O{2}m}{%
fpeval{round(#2-273.15,#1)}%
}
begin{document}
begin{tabular}{
S[table-format=5.2]
S[table-format=5.2]
}
toprule
{si{kelvin}} & {si{celsius}} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
1200.5 & KelvinToCelsius[1]{1200.5}\
12345 & KelvinToCelsius[0]{12345} \
bottomrule
end{tabular}
end{document}

answered 2 hours ago
egregegreg
738k8919393269
738k8919393269
add a comment |
add a comment |
The commands must be expandable so that siunitx sees "pure numbers". Better use the xfp package for the calculations and avoid optional arguments.
documentclass{article}
usepackage{siunitx}
usepackage{xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[1]{% no optional argument
fpeval{round((#1-273.15)/2,2)}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
%1200.5 & {KelvinToCelsius[1]{1200.5}}\
%12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}

Why no optional argument?;-)
– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
add a comment |
The commands must be expandable so that siunitx sees "pure numbers". Better use the xfp package for the calculations and avoid optional arguments.
documentclass{article}
usepackage{siunitx}
usepackage{xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[1]{% no optional argument
fpeval{round((#1-273.15)/2,2)}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
%1200.5 & {KelvinToCelsius[1]{1200.5}}\
%12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}

Why no optional argument?;-)
– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
add a comment |
The commands must be expandable so that siunitx sees "pure numbers". Better use the xfp package for the calculations and avoid optional arguments.
documentclass{article}
usepackage{siunitx}
usepackage{xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[1]{% no optional argument
fpeval{round((#1-273.15)/2,2)}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
%1200.5 & {KelvinToCelsius[1]{1200.5}}\
%12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}

The commands must be expandable so that siunitx sees "pure numbers". Better use the xfp package for the calculations and avoid optional arguments.
documentclass{article}
usepackage{siunitx}
usepackage{xfp}
usepackage{booktabs}
% #1: decimal places (default=2), #2: value
newcommand*{KelvinToCelsius}[1]{% no optional argument
fpeval{round((#1-273.15)/2,2)}%
}
begin{document}
begin{tabular}{S S}
toprule
si{kelvin} & si{celsius} \
midrule
10.3 & KelvinToCelsius{10.3} \
200.34 & KelvinToCelsius{200.34} \
500.26 & KelvinToCelsius{500.26} \
%1200.5 & {KelvinToCelsius[1]{1200.5}}\
%12345 & {KelvinToCelsius[0]{12345}} \
bottomrule
end{tabular}
end{document}

answered 2 hours ago
Ulrike FischerUlrike Fischer
202k9310695
202k9310695
Why no optional argument?;-)
– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
add a comment |
Why no optional argument?;-)
– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
Why no optional argument?
;-)– egreg
2 hours ago
Why no optional argument?
;-)– egreg
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
@egreg because I was too lazy to check if it would work with xparse.
– Ulrike Fischer
2 hours ago
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%2f488277%2fproblems-with-numbers-result-of-calculations-alignment-using-siunitx-package-i%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
Maybe section 7.2 "Expanding content in tables" of the
siunitxmanual can help you.– leandriis
2 hours ago
You need something expandable, use the xfp package instead of fp and avoid optional arguments.
– Ulrike Fischer
2 hours ago