TransWikia.com

Centering column values in a table that's already centered?

TeX - LaTeX Asked on June 19, 2021

I am working with the following code for a table :

begin{table}[!h]
    centering
    begin{tabular}{@{} lllll }
    toprule
     textbf{mytab{DM}}
      & multicolumn{3}{c|}{textbf{mytab{Epistemic $>$ Root}}} &  multicolumn{1}{c}{textbf{mytab{Root $>$ Epistemic}}}
      midrule
       & textbf{mytab{E--E}} & textbf{mytab{E--R}} & textbf{mytab{R--R}} &  textbf{mytab{R--E}} 
      midrule 
      textit{mytab{Must Used to (...) Will Ought to}} & .27 & .25 & .23 & .22
      bottomrule
    end{tabular}
    caption{Proportions of semantic ordering of DMs with 5 tokens or less, from textit{Must Used to} to textit{Will Ought to} (n=59)}
    label{tab:low_freq_DM_semantics}
end{table}
FloatBarrier

As can be seen in the output, the values in the second column (Root > Epistemic) are left-aligned and I would like to center them within that large column to make them stand out from the values in the first. I have tried using centering inside the column but also manual commands like hskip, qquad, but nothing happens when I do this. Would appreciate some help as I sometimes struggle wrapping my head around Latex tables, although I expect the solution to this problem is pretty simple!

All the best,

Cameron

2 Answers

Is this what you have in mind? The third column has been made artificially larger by enclosing its header in a wider box.

documentclass{article}
usepackage{booktabs,siunitx}

begin{document}

begin{table}[!htp]
centering

begin{tabular}{
  @{}
  l
  *{4}{S[table-format=1.2]}
  @{}
}
toprule
textbf{DM} &
  multicolumn{3}{c}{textbf{Epistemic $>$ Root}} &
  {textbf{Root $>$ Epistemic}}
cmidrule(r){2-4} cmidrule(l){5-5}
& {textbf{E--E}} & {makebox[6em]{textbf{E--R}}} & {textbf{R--R}} &  {textbf{R--E}} 
midrule 
textit{Might Can}   & .27 & .25 & .23 & .22 
textit{Might Could} & .34 & .66 & 0   & 0   
textit{Can Could}   & .24 & 0   & .75 & 0   
bottomrule
end{tabular}

caption{Proportions of semantic ordering of DMs with 5 tokens or less, 
  from textit{Must Used to} to textit{Will Ought to} ($n=59$)}
label{tab:low_freq_DM_semantics}

end{table}

end{document}

enter image description here

Always keep the leading zero in front of decimal numbers. As you see, siunitx does this automatically anyway.

Correct answer by egreg on June 19, 2021

Pure guessing ...

documentclass[varwidth, border=3.141592]{standalone}
usepackage{booktabs, makecell, multirow}
renewcommandtheadfont{bfseries}
renewcommandtheadgape{}
NewExpandableDocumentCommandmcc{O{1}m}{multicolumn{#1}{c}{#2}}
usepackage{siunitx}

begin{document}
    begin{table}[!h]
    centering
begin{tabular}{@{} >{itshape}l SSSS }
    toprule
thead{DM}
    & mcc[3]{textbf{Epistemic $>$ Root}}
            &  mcc{thead{Root $>$ Epistemic}}                     
      cmidrule(r){2-4}cmidrule(l){5-5}
    &{thead{E--E}} &{thead{E--R}} &{thead{R--R}} &{thead{R--E}}
      midrule
makecell[l]{Must Used to (...)
          Will Ought to   }
    & .27           & .25           & .23           & .22
      bottomrule
    end{tabular}
caption{Proportions of semantic ordering of DMs with 5 tokens or less, from textit{Must Used to} to textit{Will Ought to} (n=59)}
label{tab:low_freq_DM_semantics}
    end{table}
end{document}

enter image description here

Answered by Zarko on June 19, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP