1

I found that the line is not the equal length in second row and the first row. Is it possible to make it same line length.

\documentclass{article}
\usepackage{tabularx, caption}           % Load package caption for decent foramtting and spacing
\usepackage{booktabs, ragged2e}       % Use booktabs rules and get rid og vertical rules, ragged2e to ragged text
\setlength\extrarowheight{1pt}          % Both line necessary for decent spacing, unless you are using booktabs rules.
\renewcommand{\arraystretch}{1.2}


\begin{document}

\newcolumntype{A}{>{\RaggedRight\arraybackslash\hsize=0\hsize\linewidth=\hsize}X}
\newcolumntype{B}{>{\RaggedRight\arraybackslash\hsize=0.65\hsize\linewidth=\hsize}X}
\begin{table}[!ht]

    \begin{tabularx}{\textwidth}{@{}A*{5}{B}@{}}
    \toprule
     & & \multicolumn{3}{c}{\textbf{ATest Combination}} \\
     \cmidrule(lr){3-5}
     & & \small Mean (\%)
     & \small Std. Deviation (\%)& \small Std. Error Mean(\%) \\
\midrule
    \multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB) 
    & 312314.20\% & 321321.36\% & 4.321354\%  \\
    \bottomrule
    \end{tabularx}
\caption{dsadsa dsadasd%
    \label{tab:test123}% 
    }  
\end{table}


\end{document}

The outcome:

enter image description here

And also, how to make the outcome of the word in whole words without being break out automaticall using '-'?

For example:

Transpor Example 
Dataset (AA) - 
Transpor Example 
Dataset (BB)

and not

Transpor Exam-
ple Data -
set (AA) - 
Trans- 
por Example 
Dataset (BB)
aan
  • 2,663
  • 2
    Regarding the horizontal line: replace \cmidrule(lr){3-5} with \cmidrule(l){3-5} or (\cmidrule{3-5}) – leandriis Aug 06 '19 at 19:11
  • @leandriis, thanks. It works. Between, what is the meaning of lr and l in this part? Any source for reading this, cannot find it. – aan Aug 06 '19 at 19:14
  • 1
    r = shorten the line on the right, l= shorten the line on the left. This is especially useful if you have more than one cmidrule next to each other. Without the lr two adjacent cmidrules would appear as one line instead of two. For a more in depth description, please see page 4 of the booktabs manual. – leandriis Aug 06 '19 at 19:16
  • Could you please expllain the purpose of the A type column in your table? – leandriis Aug 06 '19 at 19:20
  • @leandriis. Actually, i just copy from the references code for {@{}A*{5}{B}@{}} and I still cannot figure out the meaning in whole. So, i just edit hsize=0 to look more nice in output table. \begin{tabularx}{\textwidth}{@{}A*{5}{B}@{}} = \begin{tabular}[pos]{cols} and I checked https://www.overleaf.com/learn/latex/Tables. Not sure why [pos] can be {\testwidth}. – aan Aug 06 '19 at 19:28
  • You seem to mix up the tabular and tabularx environments. Also, I don't think that the A and B columns are really useful in your table, so I have replaced them in my answer with a more suitable choice. – leandriis Aug 06 '19 at 19:36
  • 1
  • @leandriis, thanks. I need some time to digest it all. Between can I save this post and come back later to read it? – aan Aug 06 '19 at 20:17

1 Answers1

2

Here are three different versions of your table:

In all of the following example, I have corrected the trimming commands of the cmidrule command ((lr), (l), (r), For a detailed explanation please see page 4 of the booktabs manual.)

In the first example, I have also replaced the column specifiers {@{}A*{5}{B}@{}} by the more reasonable {l>{\raggedright\arraybackslash}Xccc}.

In the second table, I have alternatively used S type columns from the siunitx package in order to allow the numbers to be centered with respect to their decimal separator. Additionally, I have removed repeated % signs that are superfluous since they are already mentioned in the column headers.

In the last example, I have used a slightly smaller font size and decreased the horizontal white space between adjacent columns. With this, the contents of the second column can even fit into two lines instead of 4.

enter image description here

\documentclass{article}
\usepackage{tabularx, caption}
\usepackage{booktabs, ragged2e}

\usepackage{makecell,siunitx}

\begin{document}

\begin{table}

    \begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xccc}
    \toprule
    & & \multicolumn{3}{c}{\textbf{ATest Combination}} \\
     \cmidrule{3-5}
     & & \small Mean (\%)
     & \makecell{\small Std. Deviation\\ (\%)}& \makecell{\small Std. Error \\ Mean (\%)} \\
\midrule
    \multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB) 
    & 312314.20\% & 321321.36\% & 4.321354\%  \\
    \bottomrule
    \end{tabularx}
\caption{dsadsa dsadasd%
    \label{tab:test123}% 
    }  
\end{table}

\begin{table}
    \begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}XS[table-format=6.2]S[table-format=6.2]S[table-format=1.6]}
    \toprule
    & & \multicolumn{3}{c}{ATest Combination} \\
     \cmidrule{3-5}
     & &  {Mean (\%)}
     & {\makecell{ Std. Deviation\\ (\%)}}& {\makecell{ Std. Error \\ Mean (\%)}} \\
\midrule
    \multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB) 
    & 312314.20 & 321321.36 & 4.321354  \\
    \bottomrule
    \end{tabularx}
\caption{dsadsa dsadasd%
    \label{tab:test123}% 
    }  
\end{table}

\begin{table}
\small \setlength{\tabcolsep}{3.5pt}
    \begin{tabularx}{\textwidth}{l>{\raggedright\arraybackslash}Xccc}
    \toprule
    & & \multicolumn{3}{c}{ATest Combination} \\
     \cmidrule{3-5}
     & &  Mean (\%)
     & \makecell{ Std. Deviation\\ (\%)}& \makecell{ Std. Error \\ Mean (\%)} \\
\midrule
    \multicolumn{1}{l}{Pair 1} & Transpor Example Dataset (AA) - Transpor Example Dataset (BB) 
    & 312314.20 & 321321.36 & 4.321354  \\
    \bottomrule
    \end{tabularx}
\caption{dsadsa dsadasd%
    \label{tab:test123}% 
    }  
\end{table}




\end{document}
leandriis
  • 62,593
  • thanks. It is possible to bold the words in first 2 example? & \makecell{\small Std. Deviation\\ (\%)}& \makecell{\small Std. Error \\ Mean (\%)} \\ . I had tried to & \makecell{\small {\textbf{std. Deviation}}\\ \{\textbf{(\%)}}& \makecell{\small {\textbf{Std. Error}}} \\ {\textbf{Mean (\%)}} \\ .But it seemed not working. – aan Aug 06 '19 at 20:30
  • 2
    @aan, in table you shpuld instead \makecell use \thead and in preamble define \renewcommand\theadfont{\small}. – Zarko Aug 06 '19 at 21:06
  • @Zarko, thanks. Is it means that we created a new command name \thead OR put \small into \threadfont? – aan Aug 06 '19 at 21:21
  • 2
    @ann: No, the \theadcommand is defined by the makecell package (intended for columns heads), as it is \makecell command. – Zarko Aug 06 '19 at 21:30