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




















  • 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
    Jan 21 at 16:00











  • @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
    Jan 21 at 16:05
















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




















  • 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
    Jan 21 at 16:00











  • @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
    Jan 21 at 16:05














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
















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















share|improve this question













share|improve this question




share|improve this question








edited Jan 21 at 15:54







Oleg

















asked Jan 21 at 15:48









OlegOleg

236




236








  • 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
    Jan 21 at 16:00











  • @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
    Jan 21 at 16:05














  • 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
    Jan 21 at 16:00











  • @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
    Jan 21 at 16:05








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
Jan 21 at 16:00





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
Jan 21 at 16:00













@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
Jan 21 at 16:05





@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
Jan 21 at 16:05










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
    Jan 21 at 16:22











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

    – Oleg
    Jan 21 at 16:25











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

    – Denis
    Jan 21 at 16:26






  • 1





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

    – Denis
    Jan 21 at 16:37






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    Jan 21 at 16:45



















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
    Jan 21 at 17:31











  • @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
    Jan 21 at 17:57













  • 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
    Jan 21 at 18:13






  • 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
    Jan 21 at 18:18











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


}
});














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
    Jan 21 at 16:22











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

    – Oleg
    Jan 21 at 16:25











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

    – Denis
    Jan 21 at 16:26






  • 1





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

    – Denis
    Jan 21 at 16:37






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    Jan 21 at 16:45
















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
    Jan 21 at 16:22











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

    – Oleg
    Jan 21 at 16:25











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

    – Denis
    Jan 21 at 16:26






  • 1





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

    – Denis
    Jan 21 at 16:37






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    Jan 21 at 16:45














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 Jan 21 at 17:07

























answered Jan 21 at 16:07









gusbrsgusbrs

7,9792841




7,9792841













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

    – Oleg
    Jan 21 at 16:22











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

    – Oleg
    Jan 21 at 16:25











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

    – Denis
    Jan 21 at 16:26






  • 1





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

    – Denis
    Jan 21 at 16:37






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    Jan 21 at 16:45



















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

    – Oleg
    Jan 21 at 16:22











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

    – Oleg
    Jan 21 at 16:25











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

    – Denis
    Jan 21 at 16:26






  • 1





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

    – Denis
    Jan 21 at 16:37






  • 1





    @Oleg See edit for an siunitx equivalent.

    – gusbrs
    Jan 21 at 16:45

















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

– Oleg
Jan 21 at 16:22





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

– Oleg
Jan 21 at 16:22













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

– Oleg
Jan 21 at 16:25





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

– Oleg
Jan 21 at 16:25













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

– Denis
Jan 21 at 16:26





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

– Denis
Jan 21 at 16:26




1




1





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

– Denis
Jan 21 at 16:37





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

– Denis
Jan 21 at 16:37




1




1





@Oleg See edit for an siunitx equivalent.

– gusbrs
Jan 21 at 16:45





@Oleg See edit for an siunitx equivalent.

– gusbrs
Jan 21 at 16:45











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
    Jan 21 at 17:31











  • @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
    Jan 21 at 17:57













  • 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
    Jan 21 at 18:13






  • 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
    Jan 21 at 18:18
















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
    Jan 21 at 17:31











  • @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
    Jan 21 at 17:57













  • 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
    Jan 21 at 18:13






  • 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
    Jan 21 at 18:18














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 Jan 21 at 17:00









egregegreg

722k8719153215




722k8719153215













  • 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
    Jan 21 at 17:31











  • @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
    Jan 21 at 17:57













  • 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
    Jan 21 at 18:13






  • 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
    Jan 21 at 18:18



















  • 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
    Jan 21 at 17:31











  • @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
    Jan 21 at 17:57













  • 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
    Jan 21 at 18:13






  • 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
    Jan 21 at 18:18

















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
Jan 21 at 17:31





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
Jan 21 at 17:31













@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
Jan 21 at 17:57







@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
Jan 21 at 17:57















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
Jan 21 at 18:13





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
Jan 21 at 18:13




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
Jan 21 at 18:18





@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
Jan 21 at 18:18


















draft saved

draft discarded




















































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

Mario Kart Wii

What does “Dominus providebit” mean?

Antonio Litta Visconti Arese