Decimals in table don't align with dcolumn when bolded
up vote
9
down vote
favorite
I am making a table using booktabs
and dcolumn
. It works perfectly until I tried to bold one of the numbers and then the decimals won't read properly.
Are there any workaround here?
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & textbf{24.0}\
bottomrule
end{tabular}
end{document}
tables booktabs dcolumn
add a comment |
up vote
9
down vote
favorite
I am making a table using booktabs
and dcolumn
. It works perfectly until I tried to bold one of the numbers and then the decimals won't read properly.
Are there any workaround here?
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & textbf{24.0}\
bottomrule
end{tabular}
end{document}
tables booktabs dcolumn
I don't know withdcolumn
, but in this answer there's a method withsiunitx
and itsS
-type column.
– egreg
Jun 10 '13 at 12:44
add a comment |
up vote
9
down vote
favorite
up vote
9
down vote
favorite
I am making a table using booktabs
and dcolumn
. It works perfectly until I tried to bold one of the numbers and then the decimals won't read properly.
Are there any workaround here?
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & textbf{24.0}\
bottomrule
end{tabular}
end{document}
tables booktabs dcolumn
I am making a table using booktabs
and dcolumn
. It works perfectly until I tried to bold one of the numbers and then the decimals won't read properly.
Are there any workaround here?
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & textbf{24.0}\
bottomrule
end{tabular}
end{document}
tables booktabs dcolumn
tables booktabs dcolumn
edited Mar 18 '17 at 21:56
David Carlisle
477k3811061840
477k3811061840
asked Jun 10 '13 at 12:36
elwc
20715
20715
I don't know withdcolumn
, but in this answer there's a method withsiunitx
and itsS
-type column.
– egreg
Jun 10 '13 at 12:44
add a comment |
I don't know withdcolumn
, but in this answer there's a method withsiunitx
and itsS
-type column.
– egreg
Jun 10 '13 at 12:44
I don't know with
dcolumn
, but in this answer there's a method with siunitx
and its S
-type column.– egreg
Jun 10 '13 at 12:44
I don't know with
dcolumn
, but in this answer there's a method with siunitx
and its S
-type column.– egreg
Jun 10 '13 at 12:44
add a comment |
1 Answer
1
active
oldest
votes
up vote
9
down vote
accepted
textbf
takes you out of math mode and gives you a text mode setting, which in principle is not using the math fonts at all (although in the computer modern setup digits and .
do in fact come from the text roman font)
You would lose the alignment anyway as dcolumn needs to see the .
at the top level not inside a group.
D
is defined via newcolumntype
so you need to define a similar column say B
that also inserts boldmath
(Note your example generates several unrelated errors when run, please test before posting!)
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{24.0}\
bottomrule
end{tabular}
end{document}
The .
will be aligned exactly using the above, but the default bold digits are wider than the standard ones so alignment will be out. this may not matter if you only have one or two digits but to use the non-extended bold easiest is to define a version of boldmath
that uses b
rather than bx
.
documentclass{article}
usepackage{booktabs,dcolumn}
DeclareMathVersion{nxbold}
SetSymbolFont{operators}{nxbold}{OT1}{cmr} {b}{n}
SetSymbolFont{letters} {nxbold}{OML}{cmm} {b}{it}
SetSymbolFont{symbols} {nxbold}{OMS}{cmsy}{b}{n}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
newcolumntype{Z}[3]{>{mathversion{nxbold}DC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 11112.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{11124.0}\
19 & multicolumn{1}{Z{.}{.}{-1}}{11124.0}\
bottomrule
end{tabular}
end{document}
1
somehow i knew you'd be the one to answer this. why don't you add this situation to thedcolumn
documentation?
– barbara beeton
Jun 10 '13 at 12:53
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
9
down vote
accepted
textbf
takes you out of math mode and gives you a text mode setting, which in principle is not using the math fonts at all (although in the computer modern setup digits and .
do in fact come from the text roman font)
You would lose the alignment anyway as dcolumn needs to see the .
at the top level not inside a group.
D
is defined via newcolumntype
so you need to define a similar column say B
that also inserts boldmath
(Note your example generates several unrelated errors when run, please test before posting!)
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{24.0}\
bottomrule
end{tabular}
end{document}
The .
will be aligned exactly using the above, but the default bold digits are wider than the standard ones so alignment will be out. this may not matter if you only have one or two digits but to use the non-extended bold easiest is to define a version of boldmath
that uses b
rather than bx
.
documentclass{article}
usepackage{booktabs,dcolumn}
DeclareMathVersion{nxbold}
SetSymbolFont{operators}{nxbold}{OT1}{cmr} {b}{n}
SetSymbolFont{letters} {nxbold}{OML}{cmm} {b}{it}
SetSymbolFont{symbols} {nxbold}{OMS}{cmsy}{b}{n}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
newcolumntype{Z}[3]{>{mathversion{nxbold}DC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 11112.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{11124.0}\
19 & multicolumn{1}{Z{.}{.}{-1}}{11124.0}\
bottomrule
end{tabular}
end{document}
1
somehow i knew you'd be the one to answer this. why don't you add this situation to thedcolumn
documentation?
– barbara beeton
Jun 10 '13 at 12:53
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
add a comment |
up vote
9
down vote
accepted
textbf
takes you out of math mode and gives you a text mode setting, which in principle is not using the math fonts at all (although in the computer modern setup digits and .
do in fact come from the text roman font)
You would lose the alignment anyway as dcolumn needs to see the .
at the top level not inside a group.
D
is defined via newcolumntype
so you need to define a similar column say B
that also inserts boldmath
(Note your example generates several unrelated errors when run, please test before posting!)
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{24.0}\
bottomrule
end{tabular}
end{document}
The .
will be aligned exactly using the above, but the default bold digits are wider than the standard ones so alignment will be out. this may not matter if you only have one or two digits but to use the non-extended bold easiest is to define a version of boldmath
that uses b
rather than bx
.
documentclass{article}
usepackage{booktabs,dcolumn}
DeclareMathVersion{nxbold}
SetSymbolFont{operators}{nxbold}{OT1}{cmr} {b}{n}
SetSymbolFont{letters} {nxbold}{OML}{cmm} {b}{it}
SetSymbolFont{symbols} {nxbold}{OMS}{cmsy}{b}{n}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
newcolumntype{Z}[3]{>{mathversion{nxbold}DC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 11112.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{11124.0}\
19 & multicolumn{1}{Z{.}{.}{-1}}{11124.0}\
bottomrule
end{tabular}
end{document}
1
somehow i knew you'd be the one to answer this. why don't you add this situation to thedcolumn
documentation?
– barbara beeton
Jun 10 '13 at 12:53
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
add a comment |
up vote
9
down vote
accepted
up vote
9
down vote
accepted
textbf
takes you out of math mode and gives you a text mode setting, which in principle is not using the math fonts at all (although in the computer modern setup digits and .
do in fact come from the text roman font)
You would lose the alignment anyway as dcolumn needs to see the .
at the top level not inside a group.
D
is defined via newcolumntype
so you need to define a similar column say B
that also inserts boldmath
(Note your example generates several unrelated errors when run, please test before posting!)
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{24.0}\
bottomrule
end{tabular}
end{document}
The .
will be aligned exactly using the above, but the default bold digits are wider than the standard ones so alignment will be out. this may not matter if you only have one or two digits but to use the non-extended bold easiest is to define a version of boldmath
that uses b
rather than bx
.
documentclass{article}
usepackage{booktabs,dcolumn}
DeclareMathVersion{nxbold}
SetSymbolFont{operators}{nxbold}{OT1}{cmr} {b}{n}
SetSymbolFont{letters} {nxbold}{OML}{cmm} {b}{it}
SetSymbolFont{symbols} {nxbold}{OMS}{cmsy}{b}{n}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
newcolumntype{Z}[3]{>{mathversion{nxbold}DC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 11112.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{11124.0}\
19 & multicolumn{1}{Z{.}{.}{-1}}{11124.0}\
bottomrule
end{tabular}
end{document}
textbf
takes you out of math mode and gives you a text mode setting, which in principle is not using the math fonts at all (although in the computer modern setup digits and .
do in fact come from the text roman font)
You would lose the alignment anyway as dcolumn needs to see the .
at the top level not inside a group.
D
is defined via newcolumntype
so you need to define a similar column say B
that also inserts boldmath
(Note your example generates several unrelated errors when run, please test before posting!)
documentclass{article}
usepackage{booktabs,dcolumn}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 12.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{24.0}\
bottomrule
end{tabular}
end{document}
The .
will be aligned exactly using the above, but the default bold digits are wider than the standard ones so alignment will be out. this may not matter if you only have one or two digits but to use the non-extended bold easiest is to define a version of boldmath
that uses b
rather than bx
.
documentclass{article}
usepackage{booktabs,dcolumn}
DeclareMathVersion{nxbold}
SetSymbolFont{operators}{nxbold}{OT1}{cmr} {b}{n}
SetSymbolFont{letters} {nxbold}{OML}{cmm} {b}{it}
SetSymbolFont{symbols} {nxbold}{OMS}{cmsy}{b}{n}
begin{document}
newcolumntype{.}{D{.}{.}{-1}}
makeatletter
newcolumntype{B}[3]{>{boldmathDC@{#1}{#2}{#3}}c<{DC@end}}
newcolumntype{Z}[3]{>{mathversion{nxbold}DC@{#1}{#2}{#3}}c<{DC@end}}
makeatother
begin{tabular}{l .}
toprule
M & multicolumn{1}{c}{N} \
midrule
5 & 11112.0 \
10 & multicolumn{1}{B{.}{.}{-1}}{11124.0}\
19 & multicolumn{1}{Z{.}{.}{-1}}{11124.0}\
bottomrule
end{tabular}
end{document}
edited Mar 18 '17 at 21:58
answered Jun 10 '13 at 12:50
David Carlisle
477k3811061840
477k3811061840
1
somehow i knew you'd be the one to answer this. why don't you add this situation to thedcolumn
documentation?
– barbara beeton
Jun 10 '13 at 12:53
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
add a comment |
1
somehow i knew you'd be the one to answer this. why don't you add this situation to thedcolumn
documentation?
– barbara beeton
Jun 10 '13 at 12:53
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
1
1
somehow i knew you'd be the one to answer this. why don't you add this situation to the
dcolumn
documentation?– barbara beeton
Jun 10 '13 at 12:53
somehow i knew you'd be the one to answer this. why don't you add this situation to the
dcolumn
documentation?– barbara beeton
Jun 10 '13 at 12:53
1
1
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
@barbarabeeton I really wish I hadn't used an @ in DC@ and DC@end but it was a long time ago:-) I suspect that people (and google) are more likely to find it here than in the package doc but I may add something...
– David Carlisle
Jun 10 '13 at 13:27
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
Thanks David Carlisle - that's really nice. Do you mind if I add it to the wikibook? I'd probably make it a non-booktabs version for simplicity - though personally I'm a (recent) convert to the booktabs style.
– Chris H
Jun 24 '13 at 9:55
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
@ChrisH sure, see this link
– David Carlisle
Jun 24 '13 at 14:16
add a comment |
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%2f118458%2fdecimals-in-table-dont-align-with-dcolumn-when-bolded%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
I don't know with
dcolumn
, but in this answer there's a method withsiunitx
and itsS
-type column.– egreg
Jun 10 '13 at 12:44