0

I use this answer to fit the table into the page. On the other hand, I tried to use his/her suggestion to create yet another table as follows:

\documentclass{article}
\usepackage{booktabs,caption,siunitx}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}
\small
\medskip
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}} *{2}{l*{5}{r}}}
\toprule
\textbf{lang} & \mc{\textbf{MymcNet}} & \mc{\textbf{Bazilat et al}} 
  & \mc{\textbf{My-Pipe}}  &
\textbf{lang} & \mc{\textbf{MymcNet}} & \mc{\textbf{Bazilat et al}} 
  & \mc{\textbf{My-Pipe}} \\
\cmidrule{1-4} \cmidrule{5-8} 
ar & 88.23   & 55.12 & 24.23 & 
es & 12.12 & 90.22 & 12.13  \\
bg &   &   &   & 
pt &  &  &   \\
cs &  &   &  & 
sk &   &  &   \\
en &     &   &    &  
sl &     &   &      \\
et &     &   &    &    
ru &     &   &       \\
fr &     &   &    &   
hi &     &   &       \\
hu &     &   &    &    
lv &     &   &        \\
ro &     &   &    &    
nl &     &   &         \\
tr &     &   &    &     
pl &     &   &          \\
hr &     &   &    &    
de &     &   &          \\
it &     &   &    &    
gr &     &   &         \\
da &     &   &    &   
la &     &   &          \\
ca &     &   &    &     
ko &     &   &         \\
fi &     &   &    &     
ir &     &   &       \\
\bottomrule
\end{tabular*}
\captionsetup{font=small,skip=0.333\baselineskip}
\caption{Test set scores.}
\end{table}
\end{document}

Unfortunatelly, I was not able to align the values with the header of each column as shown below:

enter image description here

For example, 55.12 is not aligned with "Bazilat et al". How can I fix it too ? Thanks a lot for all your helps

Mico
  • 506,678
zwlayer
  • 211
  • 1
    Since there are now 3 rather than 5 numeric columns in each half of the table, you should change *{2}{l*{5}{r}} to *{2}{l*{3}{r}}. – Mico Apr 14 '18 at 10:42

1 Answers1

1

Compared to the table you posted in your earlier query, the new table has fewer numeric columns: 6 rather than 10. An immediate fix would consist of changing

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{2}{l*{5}{r}}}

to

\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}*{2}{l*{3}{r}}}

Some additional suggestions:

  • For the new table, centering of the numbers seems preferable to right-aligning them. Moreover, the numbers should be aligned on their respective decimal markers. I suggest you load the siunitx package and use the S column type, as is shown in the following code, rather than the r column type.

  • Try to make the columns (roughly) of equal width, by moving the "et al" parts to a separate line in the header.

  • It's no longer necessary to impose \small on the table itself, and thus it's also no longer necessary to specify font=small when running \captionsetup.

enter image description here

\documentclass{article}
\usepackage{booktabs,caption,siunitx}
\newcommand\mc[1]{\multicolumn{1}{c}{#1}} % handy shortcut macro
\begin{document}
\begin{table}
\setlength\tabcolsep{0pt}
\begin{tabular*}{\textwidth}{@{\extracolsep{\fill}}
    *{2}{l*{3}{S[table-format=2.2]}}}
\cmidrule{1-4} \cmidrule{5-8} % instead of \toprule
\textbf{lang} & \mc{\textbf{MymcNet}} & \mc{\textbf{Bazilat}} 
   & \mc{\textbf{My-Pipe}} &
\textbf{lang} & \mc{\textbf{MymcNet}} & \mc{\textbf{Bazilat}} 
   & \mc{\textbf{My-Pipe}} \\
& & \mc{\textbf{et al}} & & & & \mc{\textbf{et al}}\\
\cmidrule{1-4} \cmidrule{5-8} 
ar & 88.23 & 55.12 & 24.23 & es & 12.12 & 90.22 & 12.13  \\
bg &     &   &    & pt &     &   &    \\
cs &     &   &    & sk &     &   &    \\
en &     &   &    & sl &     &   &    \\
et &     &   &    & ru &     &   &    \\
fr &     &   &    & hi &     &   &    \\
hu &     &   &    & lv &     &   &    \\
ro &     &   &    & nl &     &   &    \\
tr &     &   &    & pl &     &   &    \\
hr &     &   &    & de &     &   &    \\
it &     &   &    & gr &     &   &    \\
da &     &   &    & la &     &   &    \\
ca &     &   &    & ko &     &   &    \\
fi &     &   &    & ir &     &   &    \\
\cmidrule{1-4} \cmidrule{5-8} % instead of \bottomrule
\end{tabular*}
\captionsetup{skip=0.333\baselineskip}
\caption{Test set scores.}
\end{table}
\end{document}
Mico
  • 506,678
  • is there any way to add a constant line after the fourth column ? I mean, a line that comes afterthe First My-Pipe column ? – zwlayer May 29 '18 at 19:35
  • @zwlayer - I'm afraid I don't understand your questions. For instance, what is a "constant line"? E.g., is it supposed to be horizontal or vertical line (or something else)? Please clarify. – Mico May 29 '18 at 19:52
  • Sure, as you prefer separate queries, I opened a new question. I will add an image in a minute to explain my question – zwlayer May 29 '18 at 19:53
  • I edit my question. You can find it here: https://tex.stackexchange.com/q/434027/160757 – zwlayer May 29 '18 at 19:59