Decimal alignment in a table with math mode












4















After reading some answers on the site, I'm trying to use dcolumn pacakge in order to add horizontal alignment to my tables.
Unfortunately without success so far.
I'm writing as a part of a group so I shouldn't added packages that may affect others, that's why I'm trying to figure it w/o adding the siunitx package.



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & Results A & Results B & Results A & Results B \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


The result is:



result table



Please help me solve this puzzle, also I need to add bold to some values in the table, and since switching to dcolumn I've removed the $n$ I've had and therefore mathbf seems not to work any more. What would be the solution in that case?










share|improve this question









New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

    – gusbrs
    2 days ago











  • @gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

    – Oleg
    2 days ago
















4















After reading some answers on the site, I'm trying to use dcolumn pacakge in order to add horizontal alignment to my tables.
Unfortunately without success so far.
I'm writing as a part of a group so I shouldn't added packages that may affect others, that's why I'm trying to figure it w/o adding the siunitx package.



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & Results A & Results B & Results A & Results B \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


The result is:



result table



Please help me solve this puzzle, also I need to add bold to some values in the table, and since switching to dcolumn I've removed the $n$ I've had and therefore mathbf seems not to work any more. What would be the solution in that case?










share|improve this question









New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.
















  • 2





    Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

    – gusbrs
    2 days ago











  • @gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

    – Oleg
    2 days ago














4












4








4


1






After reading some answers on the site, I'm trying to use dcolumn pacakge in order to add horizontal alignment to my tables.
Unfortunately without success so far.
I'm writing as a part of a group so I shouldn't added packages that may affect others, that's why I'm trying to figure it w/o adding the siunitx package.



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & Results A & Results B & Results A & Results B \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


The result is:



result table



Please help me solve this puzzle, also I need to add bold to some values in the table, and since switching to dcolumn I've removed the $n$ I've had and therefore mathbf seems not to work any more. What would be the solution in that case?










share|improve this question









New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.












After reading some answers on the site, I'm trying to use dcolumn pacakge in order to add horizontal alignment to my tables.
Unfortunately without success so far.
I'm writing as a part of a group so I shouldn't added packages that may affect others, that's why I'm trying to figure it w/o adding the siunitx package.



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & Results A & Results B & Results A & Results B \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}


The result is:



result table



Please help me solve this puzzle, also I need to add bold to some values in the table, and since switching to dcolumn I've removed the $n$ I've had and therefore mathbf seems not to work any more. What would be the solution in that case?







tables booktabs overleaf dcolumn






share|improve this question









New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.











share|improve this question









New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









share|improve this question




share|improve this question








edited 2 days ago







Oleg













New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.









asked 2 days ago









OlegOleg

236




236




New contributor




Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.





New contributor





Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.






Oleg is a new contributor to this site. Take care in asking for clarification, commenting, and answering.
Check out our Code of Conduct.








  • 2





    Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

    – gusbrs
    2 days ago











  • @gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

    – Oleg
    2 days ago














  • 2





    Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

    – gusbrs
    2 days ago











  • @gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

    – Oleg
    2 days ago








2




2





Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

– gusbrs
2 days ago





Welcome to TeX.SX! I know you stated your reasons for not using siunitx but, imho, you should take a careful look at it, for it is very well crafted and resourceful. Besides, you do load dcolumn don't you?

– gusbrs
2 days ago













@gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

– Oleg
2 days ago





@gusbrs Yes, I have added the dcolumn loading. But from my (very narrow) understanding in LaTeX it seems to me as a more basic package, that should be in the basic libraries without any further installation. Personally I work in Overleaf, but some other group members use offline editors (which I know little about) so I'm afraid that adding a more advanced package may cause some issues with them

– Oleg
2 days ago










2 Answers
2






active

oldest

votes


















5














You are probably looking for multicolumn:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


enter image description here



However, as mentioned in the comments, I think you should reconsider the case against siunitx. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn of which I'm not an user). You should, of course, decide that along with your work group.



The same table done with siunitx would be something like:



documentclass{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{siunitx}

begin{document}

begin{table}
centering
sisetup{table-format = 0.3}
begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


It does automatically take care of the leading zero, emphasized by @Denis in the comments.



enter image description here






share|improve this answer


























  • Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

    – Oleg
    2 days ago











  • btw, sorry that I can't upvote yet..

    – Oleg
    2 days ago











  • @Oleg Also note that the SI manual says that you should always write .11 as 0.11.

    – Denis
    2 days ago






  • 1





    @Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

    – Denis
    2 days ago






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    2 days ago



















4














You can (should, in my opinion) use siunitx; here I show also how to have real note markers upright that leave the exact space for them.



If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{siunitx}

NewDocumentCommand{bs}{}{fontseries{b}selectfont}

makeatletter
NewDocumentCommand{tss}{mm}{%
{m@thensuremath{%
^{mbox{fontsizesf@sizez@selectfont #1}}%
_{mbox{fontsizesf@sizez@selectfont #2}}%
}}%
}
makeatother

begin{document}

begin{table}[htp]
centering

sisetup{detect-weight,mode=text}
DeclareDocumentCommand{bfseries}{}{bs}

begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
@{}
}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
Main & The Good & bs .111 & .789tss{b}{b} & .520 & .555tss{a}{b} \
& The Bad & .111 & .636tss{al}{b} & .520 & .730tss{al}{b} \
& The Ugly & .111 & .525tss{}{b} & .520 & .696tss{}{b} \
bottomrule
end{tabular}

caption{Caption}
label{tab:my_label}

end{table}

end{document}


I wouldn't use multirow: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.



enter image description here






share|improve this answer
























  • Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

    – Oleg
    2 days ago











  • @Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

    – egreg
    2 days ago













  • In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

    – Oleg
    2 days ago






  • 1





    @Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

    – egreg
    2 days ago











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
});


}
});






Oleg is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471150%2fdecimal-alignment-in-a-table-with-math-mode%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









5














You are probably looking for multicolumn:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


enter image description here



However, as mentioned in the comments, I think you should reconsider the case against siunitx. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn of which I'm not an user). You should, of course, decide that along with your work group.



The same table done with siunitx would be something like:



documentclass{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{siunitx}

begin{document}

begin{table}
centering
sisetup{table-format = 0.3}
begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


It does automatically take care of the leading zero, emphasized by @Denis in the comments.



enter image description here






share|improve this answer


























  • Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

    – Oleg
    2 days ago











  • btw, sorry that I can't upvote yet..

    – Oleg
    2 days ago











  • @Oleg Also note that the SI manual says that you should always write .11 as 0.11.

    – Denis
    2 days ago






  • 1





    @Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

    – Denis
    2 days ago






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    2 days ago
















5














You are probably looking for multicolumn:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


enter image description here



However, as mentioned in the comments, I think you should reconsider the case against siunitx. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn of which I'm not an user). You should, of course, decide that along with your work group.



The same table done with siunitx would be something like:



documentclass{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{siunitx}

begin{document}

begin{table}
centering
sisetup{table-format = 0.3}
begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


It does automatically take care of the leading zero, emphasized by @Denis in the comments.



enter image description here






share|improve this answer


























  • Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

    – Oleg
    2 days ago











  • btw, sorry that I can't upvote yet..

    – Oleg
    2 days ago











  • @Oleg Also note that the SI manual says that you should always write .11 as 0.11.

    – Denis
    2 days ago






  • 1





    @Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

    – Denis
    2 days ago






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    2 days ago














5












5








5







You are probably looking for multicolumn:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


enter image description here



However, as mentioned in the comments, I think you should reconsider the case against siunitx. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn of which I'm not an user). You should, of course, decide that along with your work group.



The same table done with siunitx would be something like:



documentclass{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{siunitx}

begin{document}

begin{table}
centering
sisetup{table-format = 0.3}
begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


It does automatically take care of the leading zero, emphasized by @Denis in the comments.



enter image description here






share|improve this answer















You are probably looking for multicolumn:



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{multirow}
usepackage{ctable}
usepackage{tabularx}
usepackage{graphicx}
usepackage{dcolumn}
newcolumntype{d}[1]{D{.}{.}{#1} }


begin{document}

begin{table}
centering
begin{tabular}{@{}lc*{4}{d{1.5}}@{}}
toprule
{} & {} & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} & multicolumn{1}{c}{Results A} & multicolumn{1}{c}{Results B} \
midrule
multirow{3}{*}{Main}
{} & The Good & .111 & .789_{b}^{b} & .520 & .555_{b}^{a} \
{} & The Bad & .111 & .636_{b}^{al} & .520 & .730_{b}^{al} \
{} & The Ugly & .111 & .525_{b} & .520 & .696_{b} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


enter image description here



However, as mentioned in the comments, I think you should reconsider the case against siunitx. More important than being a "basic package" is the fact that it is very well crafted and zealously maintained, besides being widely used. (This is not a judgement on dcolumn of which I'm not an user). You should, of course, decide that along with your work group.



The same table done with siunitx would be something like:



documentclass{article}

usepackage{booktabs}
usepackage{multirow}
usepackage{siunitx}

begin{document}

begin{table}
centering
sisetup{table-format = 0.3}
begin{tabular}{@{}
lc
S
S[table-space-text-post = {$_{b}^{al}$}] % make it the largest post-number element
S
S[table-space-text-post = {$_{b}^{al}$}]
@{}}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
multirow{3}{*}{Main}
& The Good & .111 & .789{$_{b}^{b}$} & .520 & .555{$_{b}^{a}$} \
& The Bad & .111 & .636{$_{b}^{al}$} & .520 & .730{$_{b}^{al}$} \
& The Ugly & .111 & .525{$_{b}$} & .520 & .696{$_{b}$} \
bottomrule
end{tabular}
caption{Caption}
label{tab:my_label}
end{table}

end{document}


It does automatically take care of the leading zero, emphasized by @Denis in the comments.



enter image description here







share|improve this answer














share|improve this answer



share|improve this answer








edited 2 days ago

























answered 2 days ago









gusbrsgusbrs

7,4692840




7,4692840













  • Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

    – Oleg
    2 days ago











  • btw, sorry that I can't upvote yet..

    – Oleg
    2 days ago











  • @Oleg Also note that the SI manual says that you should always write .11 as 0.11.

    – Denis
    2 days ago






  • 1





    @Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

    – Denis
    2 days ago






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    2 days ago



















  • Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

    – Oleg
    2 days ago











  • btw, sorry that I can't upvote yet..

    – Oleg
    2 days ago











  • @Oleg Also note that the SI manual says that you should always write .11 as 0.11.

    – Denis
    2 days ago






  • 1





    @Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

    – Denis
    2 days ago






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    2 days ago

















Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

– Oleg
2 days ago





Thanks id did solved my problem, can you perhaps add a solution using siunitx ?

– Oleg
2 days ago













btw, sorry that I can't upvote yet..

– Oleg
2 days ago





btw, sorry that I can't upvote yet..

– Oleg
2 days ago













@Oleg Also note that the SI manual says that you should always write .11 as 0.11.

– Denis
2 days ago





@Oleg Also note that the SI manual says that you should always write .11 as 0.11.

– Denis
2 days ago




1




1





@Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

– Denis
2 days ago





@Oleg To be precise, this is page 44 of the SI brochure (French Edition, which is the official edition).

– Denis
2 days ago




1




1





@Oleg See edit for an siunitx equivalent.

– gusbrs
2 days ago





@Oleg See edit for an siunitx equivalent.

– gusbrs
2 days ago











4














You can (should, in my opinion) use siunitx; here I show also how to have real note markers upright that leave the exact space for them.



If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{siunitx}

NewDocumentCommand{bs}{}{fontseries{b}selectfont}

makeatletter
NewDocumentCommand{tss}{mm}{%
{m@thensuremath{%
^{mbox{fontsizesf@sizez@selectfont #1}}%
_{mbox{fontsizesf@sizez@selectfont #2}}%
}}%
}
makeatother

begin{document}

begin{table}[htp]
centering

sisetup{detect-weight,mode=text}
DeclareDocumentCommand{bfseries}{}{bs}

begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
@{}
}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
Main & The Good & bs .111 & .789tss{b}{b} & .520 & .555tss{a}{b} \
& The Bad & .111 & .636tss{al}{b} & .520 & .730tss{al}{b} \
& The Ugly & .111 & .525tss{}{b} & .520 & .696tss{}{b} \
bottomrule
end{tabular}

caption{Caption}
label{tab:my_label}

end{table}

end{document}


I wouldn't use multirow: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.



enter image description here






share|improve this answer
























  • Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

    – Oleg
    2 days ago











  • @Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

    – egreg
    2 days ago













  • In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

    – Oleg
    2 days ago






  • 1





    @Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

    – egreg
    2 days ago
















4














You can (should, in my opinion) use siunitx; here I show also how to have real note markers upright that leave the exact space for them.



If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{siunitx}

NewDocumentCommand{bs}{}{fontseries{b}selectfont}

makeatletter
NewDocumentCommand{tss}{mm}{%
{m@thensuremath{%
^{mbox{fontsizesf@sizez@selectfont #1}}%
_{mbox{fontsizesf@sizez@selectfont #2}}%
}}%
}
makeatother

begin{document}

begin{table}[htp]
centering

sisetup{detect-weight,mode=text}
DeclareDocumentCommand{bfseries}{}{bs}

begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
@{}
}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
Main & The Good & bs .111 & .789tss{b}{b} & .520 & .555tss{a}{b} \
& The Bad & .111 & .636tss{al}{b} & .520 & .730tss{al}{b} \
& The Ugly & .111 & .525tss{}{b} & .520 & .696tss{}{b} \
bottomrule
end{tabular}

caption{Caption}
label{tab:my_label}

end{table}

end{document}


I wouldn't use multirow: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.



enter image description here






share|improve this answer
























  • Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

    – Oleg
    2 days ago











  • @Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

    – egreg
    2 days ago













  • In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

    – Oleg
    2 days ago






  • 1





    @Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

    – egreg
    2 days ago














4












4








4







You can (should, in my opinion) use siunitx; here I show also how to have real note markers upright that leave the exact space for them.



If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{siunitx}

NewDocumentCommand{bs}{}{fontseries{b}selectfont}

makeatletter
NewDocumentCommand{tss}{mm}{%
{m@thensuremath{%
^{mbox{fontsizesf@sizez@selectfont #1}}%
_{mbox{fontsizesf@sizez@selectfont #2}}%
}}%
}
makeatother

begin{document}

begin{table}[htp]
centering

sisetup{detect-weight,mode=text}
DeclareDocumentCommand{bfseries}{}{bs}

begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
@{}
}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
Main & The Good & bs .111 & .789tss{b}{b} & .520 & .555tss{a}{b} \
& The Bad & .111 & .636tss{al}{b} & .520 & .730tss{al}{b} \
& The Ugly & .111 & .525tss{}{b} & .520 & .696tss{}{b} \
bottomrule
end{tabular}

caption{Caption}
label{tab:my_label}

end{table}

end{document}


I wouldn't use multirow: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.



enter image description here






share|improve this answer













You can (should, in my opinion) use siunitx; here I show also how to have real note markers upright that leave the exact space for them.



If you want to set some of the entries bold, there is a trick adapted from https://tex.stackexchange.com/a/352028/4427



documentclass{article}
usepackage[utf8]{inputenc}
usepackage{booktabs}
usepackage{siunitx}

NewDocumentCommand{bs}{}{fontseries{b}selectfont}

makeatletter
NewDocumentCommand{tss}{mm}{%
{m@thensuremath{%
^{mbox{fontsizesf@sizez@selectfont #1}}%
_{mbox{fontsizesf@sizez@selectfont #2}}%
}}%
}
makeatother

begin{document}

begin{table}[htp]
centering

sisetup{detect-weight,mode=text}
DeclareDocumentCommand{bfseries}{}{bs}

begin{tabular}{
@{}
l
c
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
S[table-format=1.3]
S[table-format=1.3,table-space-text-post=tss{al}{b}]
@{}
}
toprule
& & multicolumn{2}{c}{Group A} & multicolumn{2}{c}{Group B} \
cmidrule(lr){3-4} cmidrule(l){5-6}
Types & Character & {Results A} & {Results B} & {Results A} & {Results B} \
midrule
Main & The Good & bs .111 & .789tss{b}{b} & .520 & .555tss{a}{b} \
& The Bad & .111 & .636tss{al}{b} & .520 & .730tss{al}{b} \
& The Ugly & .111 & .525tss{}{b} & .520 & .696tss{}{b} \
bottomrule
end{tabular}

caption{Caption}
label{tab:my_label}

end{table}

end{document}


I wouldn't use multirow: blank space below “Main” means repetition. Shifting it down makes quite unclear whether “Main” refers to all rows or just the middle one.



enter image description here







share|improve this answer












share|improve this answer



share|improve this answer










answered 2 days ago









egregegreg

714k8618983184




714k8618983184













  • Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

    – Oleg
    2 days ago











  • @Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

    – egreg
    2 days ago













  • In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

    – Oleg
    2 days ago






  • 1





    @Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

    – egreg
    2 days ago



















  • Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

    – Oleg
    2 days ago











  • @Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

    – egreg
    2 days ago













  • In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

    – Oleg
    2 days ago






  • 1





    @Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

    – egreg
    2 days ago

















Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

– Oleg
2 days ago





Although it doesn't directly answer my question, but it's also a great answer. Thank you. Just one question, I've noticed that the values in the table don't appear to be in math mode, i.e not italic as it appears in the example above - can it be changed?

– Oleg
2 days ago













@Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

– egreg
2 days ago







@Oleg The sub/superscript seem better go in upright type. Of course, I don't know what they refer to, so your mileage may vary.

– egreg
2 days ago















In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

– Oleg
2 days ago





In the original file they stand for statistical significance, is this the line that controls it ? S[table-format=1.3,table-space-text-post=tss{al}{b}]

– Oleg
2 days ago




1




1





@Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

– egreg
2 days ago





@Oleg No, it's the definition of tss (short for textsupersubscript). If you want them to be in italics, change both occurrences of selectfont into itshape.

– egreg
2 days ago










Oleg is a new contributor. Be nice, and check out our Code of Conduct.










draft saved

draft discarded


















Oleg is a new contributor. Be nice, and check out our Code of Conduct.













Oleg is a new contributor. Be nice, and check out our Code of Conduct.












Oleg is a new contributor. Be nice, and check out our Code of Conduct.
















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.




draft saved


draft discarded














StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2ftex.stackexchange.com%2fquestions%2f471150%2fdecimal-alignment-in-a-table-with-math-mode%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

Paul Cézanne

UIScrollView CustomStickyHeader Resize height generates problems when scroll is too fast

Angular material date-picker (MatDatepicker) auto completes the date on focus out