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}


Bolded numbers










share|improve this question
























  • 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















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}


Bolded numbers










share|improve this question
























  • 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













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}


Bolded numbers










share|improve this question















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}


Bolded numbers







tables booktabs dcolumn






share|improve this question















share|improve this question













share|improve this question




share|improve this question








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 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
















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










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!)



enter image description here



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.



enter image description here



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}





share|improve this answer



















  • 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






  • 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











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',
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%2f118458%2fdecimals-in-table-dont-align-with-dcolumn-when-bolded%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








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!)



enter image description here



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.



enter image description here



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}





share|improve this answer



















  • 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






  • 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















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!)



enter image description here



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.



enter image description here



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}





share|improve this answer



















  • 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






  • 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













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!)



enter image description here



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.



enter image description here



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}





share|improve this answer














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!)



enter image description here



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.



enter image description here



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}






share|improve this answer














share|improve this answer



share|improve this answer








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 the dcolumn 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




    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




    @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


















 

draft saved


draft discarded



















































 


draft saved


draft discarded














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





















































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

Biblatex bibliography style without URLs when DOI exists (in Overleaf with Zotero bibliography)

ComboBox Display Member on multiple fields

Is it possible to collect Nectar points via Trainline?