TeX - LaTeX Asked on February 27, 2021
I am working on a table, the code is:
begin{table}[t!]
small
centering
resizebox{0.45textwidth}{!}{%
begin{tabular}{@{}l|r@{ }r@{ }|r@{ }r@{ }|rrr@{ }}
toprule
{} & multicolumn{2}{c|}{bf Without
Context} & multicolumn{2}{c|}{bf Wiki} & multicolumn{2}{c}{bf Wiki 2}
midrule
bf Model & multicolumn{1}{c}{bf Test} & multicolumn{1}{c|}{bf Dev} & multicolumn{1}{c}{bf Test} & multicolumn{1}{c|}{bf Dev} & multicolumn{1}{c}{bf Test} & multicolumn{1}{c}{bf Dev}
midrule
Albanian & 565 & 755 & 1,194 & 311 & 1,194 & 311
Arabic & 1,194 & 562 & 1,194 & 1,194 & 1,194 & 311
Bulgarian & 1,100 & 1,472 & 2,344 & 593 & 1,194 & 311
bottomrule
end{tabular}
}
caption{Number of examples in the data splits based on the experimental setup.
}
label{tab:datasplits}
end{table}
Which looks like this:
But as it is visible that in dev set the values and Dev name is not aligned. How to make them aligh?
the tabular columns are right aligned but Dev is center aligned therefore the mis alignment
multicolumn{1}{c|}{bf Dev} needs to be multicolumn{1}{r|}{bf Dev}
to remove column space make use of @{}
in the line of code between Test and Dev
begin{tabular}{@{}l@{}r@{}r@{}r@{}r@{}|rrr@{}}
as rightly pointed out by David Carlisle in comments -- vertical lines should be avoided otherwise you will notice gaps since you are using toprule/midrule with the booktabs
package
Correct answer by js bibra on February 27, 2021
I would simplify and streamline the look of the table by getting rid of all vertical rules, all bf
statements, all multicolumn{1}{c}{...}
wrappers, and the resizebox
instruction. I'd also abbreviate "Without" as "w/o".
documentclass{article} % select a suitable document class
usepackage{booktabs}
begin{document}
begin{table}[t!]
small
centering
begin{tabular}{@{} l rrrrrr @{}}
toprule
{} & multicolumn{2}{c}{w/o Context}
& multicolumn{2}{c}{Wiki}
& multicolumn{2}{c@{}}{Wiki 2}
cmidrule(lr){2-3} cmidrule(lr){4-5} cmidrule(l){6-7}
Model & Test & Dev & Test & Dev & Test & Dev
midrule
Albanian & 565 & 755 & 1,194 & 311 & 1,194 & 311
Arabic & 1,194 & 562 & 1,194 & 1,194 & 1,194 & 311
Bulgarian & 1,100 & 1,472 & 2,344 & 593 & 1,194 & 311
bottomrule
end{tabular}
caption{Number of examples in the data splits based on the experimental setup.}
label{tab:datasplits}
end{table}
end{document}
Answered by Mico on February 27, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP