How to change only the color of numbers (and not units) with numprint?
This question is related to this one: Colour only the text in a tabularx environment
I want to write as a succession of equality in blue (only the numbers) so that each line of the table has a corresponding equality line to its right.
documentclass{article}
usepackage{amsmath,numprint,tabularx,xcolor}
begin{document}
begin{minipage}{.4linewidth}
begin{tabularx}{5cm}{|*{11}{>{leavevmodecolor{blue}}X|}}
hline
multicolumn{2}{|c|}{$rm m^2$} &
multicolumn{2}{c|}{$rm dm^2$} &
multicolumn{2}{c|}{$rm cm^2$} &
multicolumn{2}{c|}{$rm mm^2$} \
hline
&&&4,&&&& \
&&&4&0&0&0& 0,\
&0,&0&4&&&& \
hline
end{tabularx}
end{minipage}quad
begin{minipage}{.2linewidth}
begin{align*}
&numprint[dm^2]{4}\
&=numprint[mm^2]{40000}\
&=numprint[m^2]{0,04}
end{align*}
end{minipage}
end{document}
In the numprint manual, there is a hack that allows you to color the negative numbers on pages 18-19, I couldn't modify it to write the numbers in blue.
makeatletter
expandafterrenewcommandcsname nprt@sign@-endcsname{%
color{red}{ensuremath{-}}}
makeatother
color numprint
add a comment |
This question is related to this one: Colour only the text in a tabularx environment
I want to write as a succession of equality in blue (only the numbers) so that each line of the table has a corresponding equality line to its right.
documentclass{article}
usepackage{amsmath,numprint,tabularx,xcolor}
begin{document}
begin{minipage}{.4linewidth}
begin{tabularx}{5cm}{|*{11}{>{leavevmodecolor{blue}}X|}}
hline
multicolumn{2}{|c|}{$rm m^2$} &
multicolumn{2}{c|}{$rm dm^2$} &
multicolumn{2}{c|}{$rm cm^2$} &
multicolumn{2}{c|}{$rm mm^2$} \
hline
&&&4,&&&& \
&&&4&0&0&0& 0,\
&0,&0&4&&&& \
hline
end{tabularx}
end{minipage}quad
begin{minipage}{.2linewidth}
begin{align*}
&numprint[dm^2]{4}\
&=numprint[mm^2]{40000}\
&=numprint[m^2]{0,04}
end{align*}
end{minipage}
end{document}
In the numprint manual, there is a hack that allows you to color the negative numbers on pages 18-19, I couldn't modify it to write the numbers in blue.
makeatletter
expandafterrenewcommandcsname nprt@sign@-endcsname{%
color{red}{ensuremath{-}}}
makeatother
color numprint
add a comment |
This question is related to this one: Colour only the text in a tabularx environment
I want to write as a succession of equality in blue (only the numbers) so that each line of the table has a corresponding equality line to its right.
documentclass{article}
usepackage{amsmath,numprint,tabularx,xcolor}
begin{document}
begin{minipage}{.4linewidth}
begin{tabularx}{5cm}{|*{11}{>{leavevmodecolor{blue}}X|}}
hline
multicolumn{2}{|c|}{$rm m^2$} &
multicolumn{2}{c|}{$rm dm^2$} &
multicolumn{2}{c|}{$rm cm^2$} &
multicolumn{2}{c|}{$rm mm^2$} \
hline
&&&4,&&&& \
&&&4&0&0&0& 0,\
&0,&0&4&&&& \
hline
end{tabularx}
end{minipage}quad
begin{minipage}{.2linewidth}
begin{align*}
&numprint[dm^2]{4}\
&=numprint[mm^2]{40000}\
&=numprint[m^2]{0,04}
end{align*}
end{minipage}
end{document}
In the numprint manual, there is a hack that allows you to color the negative numbers on pages 18-19, I couldn't modify it to write the numbers in blue.
makeatletter
expandafterrenewcommandcsname nprt@sign@-endcsname{%
color{red}{ensuremath{-}}}
makeatother
color numprint
This question is related to this one: Colour only the text in a tabularx environment
I want to write as a succession of equality in blue (only the numbers) so that each line of the table has a corresponding equality line to its right.
documentclass{article}
usepackage{amsmath,numprint,tabularx,xcolor}
begin{document}
begin{minipage}{.4linewidth}
begin{tabularx}{5cm}{|*{11}{>{leavevmodecolor{blue}}X|}}
hline
multicolumn{2}{|c|}{$rm m^2$} &
multicolumn{2}{c|}{$rm dm^2$} &
multicolumn{2}{c|}{$rm cm^2$} &
multicolumn{2}{c|}{$rm mm^2$} \
hline
&&&4,&&&& \
&&&4&0&0&0& 0,\
&0,&0&4&&&& \
hline
end{tabularx}
end{minipage}quad
begin{minipage}{.2linewidth}
begin{align*}
&numprint[dm^2]{4}\
&=numprint[mm^2]{40000}\
&=numprint[m^2]{0,04}
end{align*}
end{minipage}
end{document}
In the numprint manual, there is a hack that allows you to color the negative numbers on pages 18-19, I couldn't modify it to write the numbers in blue.
makeatletter
expandafterrenewcommandcsname nprt@sign@-endcsname{%
color{red}{ensuremath{-}}}
makeatother
color numprint
color numprint
asked Dec 27 at 16:41
AndréC
7,63011440
7,63011440
add a comment |
add a comment |
2 Answers
2
active
oldest
votes
You can locally patch numprint
to set color{black}
for the optional argument.
Note that tabularx
is not the right tool for the job.
documentclass{article}
usepackage{amsmath,numprint,array,xcolor,xpatch}
begin{document}
begingroup
makeatletter
xpatchcmd{numprint}
{defnprt@oarg{#1}}
{defnprt@oarg{color{black}#1}}
{}{}
makeatother
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}>{color{blue}}l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2vphantom{Big|}$} &
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
&&&4rlap{,}&&&&& numprint[dm^2]{4} \
&&&4&0&0&0& 0rlap{,} &= numprint[cm^2]{40000} \
&0rlap{,}&0&4&&&&& = numprint[m^2]{0,04} \
cline{1-8}
end{tabular}
endgroup
end{document}
With siunitx
:
documentclass{article}
usepackage{amsmath,siunitx,xcolor}
sisetup{
output-decimal-marker={,},
power-font=unit,
}
begin{document}
begingroup
sisetup{
number-color=blue,
}
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}l }
cline{1-8}
multicolumn{2}{|c|}{si{squaremeter}$vphantom{Big|}$} &
multicolumn{2}{c|}{si{squaredecimeter}} &
multicolumn{2}{c|}{si{squarecentimeter}} &
multicolumn{2}{c|}{si{squaremillimeter}} \
cline{1-8}
&&&4rlap{,}&&&&& SI{4}{squaredecimeter} \
&&&4&0&0&0& 0rlap{,} &= SI{40000}{squarecentimeter} \
&0rlap{,}&0&4&&&&& = SI{0,04}{squaremeter} \
cline{1-8}
end{tabular}
endgroup
end{document}
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
@AndréC I usedw{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requiresarray
). The comma is “hidden” byrlap
.
– egreg
Dec 27 at 18:50
add a comment |
Here's an option using a single tabular
for better vertical alignment:
documentclass{article}
usepackage{numprint,xcolor}
begin{document}
begin{tabular}{| *{8}{>{color{blue}}l|} >{color{blue}} l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2$rule{0pt}{normalbaselineskip}} & % added some vertical padding
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
phantom{0,} & & & 4, & & & & & {} phantom{=} numprint[color{black}dm^2]{4} \
& & & 4 & 0 & 0 & 0 & 0, & {} {color{black}=} numprint[color{black}mm^2]{40000} \
& 0, & 0 & 4 & & & & & {} {color{black}=} numprint[color{black}m^2]{0,04} \
cline{1-8}
end{tabular}
end{document}
The entire numprint
-column is set in color{blue}
with each unit set in color{black}
(as well as the =
).
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%2f467560%2fhow-to-change-only-the-color-of-numbers-and-not-units-with-numprint%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
You can locally patch numprint
to set color{black}
for the optional argument.
Note that tabularx
is not the right tool for the job.
documentclass{article}
usepackage{amsmath,numprint,array,xcolor,xpatch}
begin{document}
begingroup
makeatletter
xpatchcmd{numprint}
{defnprt@oarg{#1}}
{defnprt@oarg{color{black}#1}}
{}{}
makeatother
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}>{color{blue}}l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2vphantom{Big|}$} &
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
&&&4rlap{,}&&&&& numprint[dm^2]{4} \
&&&4&0&0&0& 0rlap{,} &= numprint[cm^2]{40000} \
&0rlap{,}&0&4&&&&& = numprint[m^2]{0,04} \
cline{1-8}
end{tabular}
endgroup
end{document}
With siunitx
:
documentclass{article}
usepackage{amsmath,siunitx,xcolor}
sisetup{
output-decimal-marker={,},
power-font=unit,
}
begin{document}
begingroup
sisetup{
number-color=blue,
}
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}l }
cline{1-8}
multicolumn{2}{|c|}{si{squaremeter}$vphantom{Big|}$} &
multicolumn{2}{c|}{si{squaredecimeter}} &
multicolumn{2}{c|}{si{squarecentimeter}} &
multicolumn{2}{c|}{si{squaremillimeter}} \
cline{1-8}
&&&4rlap{,}&&&&& SI{4}{squaredecimeter} \
&&&4&0&0&0& 0rlap{,} &= SI{40000}{squarecentimeter} \
&0rlap{,}&0&4&&&&& = SI{0,04}{squaremeter} \
cline{1-8}
end{tabular}
endgroup
end{document}
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
@AndréC I usedw{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requiresarray
). The comma is “hidden” byrlap
.
– egreg
Dec 27 at 18:50
add a comment |
You can locally patch numprint
to set color{black}
for the optional argument.
Note that tabularx
is not the right tool for the job.
documentclass{article}
usepackage{amsmath,numprint,array,xcolor,xpatch}
begin{document}
begingroup
makeatletter
xpatchcmd{numprint}
{defnprt@oarg{#1}}
{defnprt@oarg{color{black}#1}}
{}{}
makeatother
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}>{color{blue}}l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2vphantom{Big|}$} &
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
&&&4rlap{,}&&&&& numprint[dm^2]{4} \
&&&4&0&0&0& 0rlap{,} &= numprint[cm^2]{40000} \
&0rlap{,}&0&4&&&&& = numprint[m^2]{0,04} \
cline{1-8}
end{tabular}
endgroup
end{document}
With siunitx
:
documentclass{article}
usepackage{amsmath,siunitx,xcolor}
sisetup{
output-decimal-marker={,},
power-font=unit,
}
begin{document}
begingroup
sisetup{
number-color=blue,
}
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}l }
cline{1-8}
multicolumn{2}{|c|}{si{squaremeter}$vphantom{Big|}$} &
multicolumn{2}{c|}{si{squaredecimeter}} &
multicolumn{2}{c|}{si{squarecentimeter}} &
multicolumn{2}{c|}{si{squaremillimeter}} \
cline{1-8}
&&&4rlap{,}&&&&& SI{4}{squaredecimeter} \
&&&4&0&0&0& 0rlap{,} &= SI{40000}{squarecentimeter} \
&0rlap{,}&0&4&&&&& = SI{0,04}{squaremeter} \
cline{1-8}
end{tabular}
endgroup
end{document}
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
@AndréC I usedw{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requiresarray
). The comma is “hidden” byrlap
.
– egreg
Dec 27 at 18:50
add a comment |
You can locally patch numprint
to set color{black}
for the optional argument.
Note that tabularx
is not the right tool for the job.
documentclass{article}
usepackage{amsmath,numprint,array,xcolor,xpatch}
begin{document}
begingroup
makeatletter
xpatchcmd{numprint}
{defnprt@oarg{#1}}
{defnprt@oarg{color{black}#1}}
{}{}
makeatother
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}>{color{blue}}l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2vphantom{Big|}$} &
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
&&&4rlap{,}&&&&& numprint[dm^2]{4} \
&&&4&0&0&0& 0rlap{,} &= numprint[cm^2]{40000} \
&0rlap{,}&0&4&&&&& = numprint[m^2]{0,04} \
cline{1-8}
end{tabular}
endgroup
end{document}
With siunitx
:
documentclass{article}
usepackage{amsmath,siunitx,xcolor}
sisetup{
output-decimal-marker={,},
power-font=unit,
}
begin{document}
begingroup
sisetup{
number-color=blue,
}
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}l }
cline{1-8}
multicolumn{2}{|c|}{si{squaremeter}$vphantom{Big|}$} &
multicolumn{2}{c|}{si{squaredecimeter}} &
multicolumn{2}{c|}{si{squarecentimeter}} &
multicolumn{2}{c|}{si{squaremillimeter}} \
cline{1-8}
&&&4rlap{,}&&&&& SI{4}{squaredecimeter} \
&&&4&0&0&0& 0rlap{,} &= SI{40000}{squarecentimeter} \
&0rlap{,}&0&4&&&&& = SI{0,04}{squaremeter} \
cline{1-8}
end{tabular}
endgroup
end{document}
You can locally patch numprint
to set color{black}
for the optional argument.
Note that tabularx
is not the right tool for the job.
documentclass{article}
usepackage{amsmath,numprint,array,xcolor,xpatch}
begin{document}
begingroup
makeatletter
xpatchcmd{numprint}
{defnprt@oarg{#1}}
{defnprt@oarg{color{black}#1}}
{}{}
makeatother
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}>{color{blue}}l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2vphantom{Big|}$} &
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
&&&4rlap{,}&&&&& numprint[dm^2]{4} \
&&&4&0&0&0& 0rlap{,} &= numprint[cm^2]{40000} \
&0rlap{,}&0&4&&&&& = numprint[m^2]{0,04} \
cline{1-8}
end{tabular}
endgroup
end{document}
With siunitx
:
documentclass{article}
usepackage{amsmath,siunitx,xcolor}
sisetup{
output-decimal-marker={,},
power-font=unit,
}
begin{document}
begingroup
sisetup{
number-color=blue,
}
begin{tabular}{ |*{8}{>{color{blue}}w{c}{1em}|}l }
cline{1-8}
multicolumn{2}{|c|}{si{squaremeter}$vphantom{Big|}$} &
multicolumn{2}{c|}{si{squaredecimeter}} &
multicolumn{2}{c|}{si{squarecentimeter}} &
multicolumn{2}{c|}{si{squaremillimeter}} \
cline{1-8}
&&&4rlap{,}&&&&& SI{4}{squaredecimeter} \
&&&4&0&0&0& 0rlap{,} &= SI{40000}{squarecentimeter} \
&0rlap{,}&0&4&&&&& = SI{0,04}{squaremeter} \
cline{1-8}
end{tabular}
endgroup
end{document}
edited Dec 27 at 18:50
answered Dec 27 at 18:08
egreg
708k8618823164
708k8618823164
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
@AndréC I usedw{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requiresarray
). The comma is “hidden” byrlap
.
– egreg
Dec 27 at 18:50
add a comment |
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
@AndréC I usedw{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requiresarray
). The comma is “hidden” byrlap
.
– egreg
Dec 27 at 18:50
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
Why is tabularx not appropriate here? However, it allows to obtain columns of the same width, which is necessary here.
– AndréC
Dec 27 at 18:35
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
@AndréC Aren't the column the same width here?
– egreg
Dec 27 at 18:37
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
Yes, they are, but generally with tabular, they adapt. Why are they the same width here with tabular?
– AndréC
Dec 27 at 18:40
1
1
@AndréC I used
w{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requires array
). The comma is “hidden” by rlap
.– egreg
Dec 27 at 18:50
@AndréC I used
w{c}{1em}
, which is exactly how to make a 1em wide column with center alignment; (requires array
). The comma is “hidden” by rlap
.– egreg
Dec 27 at 18:50
add a comment |
Here's an option using a single tabular
for better vertical alignment:
documentclass{article}
usepackage{numprint,xcolor}
begin{document}
begin{tabular}{| *{8}{>{color{blue}}l|} >{color{blue}} l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2$rule{0pt}{normalbaselineskip}} & % added some vertical padding
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
phantom{0,} & & & 4, & & & & & {} phantom{=} numprint[color{black}dm^2]{4} \
& & & 4 & 0 & 0 & 0 & 0, & {} {color{black}=} numprint[color{black}mm^2]{40000} \
& 0, & 0 & 4 & & & & & {} {color{black}=} numprint[color{black}m^2]{0,04} \
cline{1-8}
end{tabular}
end{document}
The entire numprint
-column is set in color{blue}
with each unit set in color{black}
(as well as the =
).
add a comment |
Here's an option using a single tabular
for better vertical alignment:
documentclass{article}
usepackage{numprint,xcolor}
begin{document}
begin{tabular}{| *{8}{>{color{blue}}l|} >{color{blue}} l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2$rule{0pt}{normalbaselineskip}} & % added some vertical padding
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
phantom{0,} & & & 4, & & & & & {} phantom{=} numprint[color{black}dm^2]{4} \
& & & 4 & 0 & 0 & 0 & 0, & {} {color{black}=} numprint[color{black}mm^2]{40000} \
& 0, & 0 & 4 & & & & & {} {color{black}=} numprint[color{black}m^2]{0,04} \
cline{1-8}
end{tabular}
end{document}
The entire numprint
-column is set in color{blue}
with each unit set in color{black}
(as well as the =
).
add a comment |
Here's an option using a single tabular
for better vertical alignment:
documentclass{article}
usepackage{numprint,xcolor}
begin{document}
begin{tabular}{| *{8}{>{color{blue}}l|} >{color{blue}} l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2$rule{0pt}{normalbaselineskip}} & % added some vertical padding
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
phantom{0,} & & & 4, & & & & & {} phantom{=} numprint[color{black}dm^2]{4} \
& & & 4 & 0 & 0 & 0 & 0, & {} {color{black}=} numprint[color{black}mm^2]{40000} \
& 0, & 0 & 4 & & & & & {} {color{black}=} numprint[color{black}m^2]{0,04} \
cline{1-8}
end{tabular}
end{document}
The entire numprint
-column is set in color{blue}
with each unit set in color{black}
(as well as the =
).
Here's an option using a single tabular
for better vertical alignment:
documentclass{article}
usepackage{numprint,xcolor}
begin{document}
begin{tabular}{| *{8}{>{color{blue}}l|} >{color{blue}} l }
cline{1-8}
multicolumn{2}{|c|}{$mathrm{m}^2$rule{0pt}{normalbaselineskip}} & % added some vertical padding
multicolumn{2}{c|}{$mathrm{dm}^2$} &
multicolumn{2}{c|}{$mathrm{cm}^2$} &
multicolumn{2}{c|}{$mathrm{mm}^2$} \
cline{1-8}
phantom{0,} & & & 4, & & & & & {} phantom{=} numprint[color{black}dm^2]{4} \
& & & 4 & 0 & 0 & 0 & 0, & {} {color{black}=} numprint[color{black}mm^2]{40000} \
& 0, & 0 & 4 & & & & & {} {color{black}=} numprint[color{black}m^2]{0,04} \
cline{1-8}
end{tabular}
end{document}
The entire numprint
-column is set in color{blue}
with each unit set in color{black}
(as well as the =
).
edited Dec 27 at 17:36
answered Dec 27 at 17:21
Werner
437k649581648
437k649581648
add a comment |
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.
Some of your past answers have not been well-received, and you're in danger of being blocked from answering.
Please pay close attention to the following guidance:
- 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%2f467560%2fhow-to-change-only-the-color-of-numbers-and-not-units-with-numprint%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