0

I have a long table with a height of 0.75 page height. I want all columns be left aligned. I tried this:

\documentclass{cta-author}

\usepackage{booktabs}
\usepackage{subcaption}
\usepackage{threeparttable}
\usepackage{pifont}
\usepackage{hyperref}


\begin{document}
\begin{table}[htp]

\begin{threeparttable}
\caption{My table}\label{tab:1}
\begin{tiny}
\begin{tabular}[width=\linewidth]{p{0.12\linewidth}p{0.3\linewidth}p{0.06\linewidth}p{0.07\linewidth}p{0.09\linewidth}p{0.09\linewidth}}
\toprule
Paper&method&p1&p2&p3&p4\\
\midrule 


\cite{c1} &method1 method1 method 1&\checkmark & \checkmark&\checkmark &\ding{55}\\
\rule{0pt}{4ex}

\cite{c2} &method2&\checkmark &\checkmark &\ding{55}&\ding{55}\\
\rule{0pt}{4ex}

\cite{c3}&method3 method3 method3 method3 &\ding{55} & \checkmark &\checkmark &\ding{55}\\
\rule{0pt}{4ex}
\midrule
my experiment test 123&method 4 method4&\checkmark &\ding{55} & \checkmark &\checkmark\\
\bottomrule
\end{tabular}
\begin{tablenotes}
\item *note
\end{tablenotes}


\end{tiny}
\end{threeparttable}
\end{table}


\end{document}

But using this all the columns are left aligned except the first column which contains paper citations. When I try using lp instead of p ( \begin{tabular}[width=\linewidth]{lp{0.12\linewidth}lp{0.3\linewidth}lp{0.06\linewidth}lp{0.07\linewidth}lp{0.09\linewidth}lp{0.09\linewidth}}) although all cells get left aligned correctly, but my table width gets more than one column and violates to the second column context. How can I have a one column width- left aligned threeparttable in a twoColumn page?

I am using IET paper template which is IET-Submission-DoubleColumn-Template.

This is my first column which has problem (all other columns are left aligned): enter image description here

I used Foxit gridlines here, but in TexWorks pdf output is the same.

4
  • 1
    Welcome to TeX.SE. What the \rule{0pt}{4ex} instructions at the beginning of various rows supposed to accomplish? Separately, isn't \begin{tabular}[width=\linewidth]{...} generating quite a few error and warning messages?
    – Mico
    Commented Aug 5, 2020 at 15:00
  • @Mico Thanks. I used \rule{0pt}{4ex} to add small vertical space between the rows. I don't receive any error but this warning at the header row of the table(Paper&method&p1&p2&p3&p4\`): Underfull \hbox (badness 10000) in paragraph at lines 533--533 []|\T1/ptm/m/n/6 `
    – m123
    Commented Aug 5, 2020 at 15:13
  • Thanks for providing these explanations. The \rule{0pt}{4ex} are on lines by themselves that aren't terminated with % (the comment symbol); the failure to add the comment symbols instructs LaTeX to insert a space in all three instances.
    – Mico
    Commented Aug 5, 2020 at 15:20
  • @Mico: Awesome! It was exactly the reason of the problem. I am really appreciated. Could you please write it as an answer? If you like.
    – m123
    Commented Aug 5, 2020 at 15:57

2 Answers 2

1

The reason why some, but not all, cells in the first column are indented slightly is that you didn't terminate the \rule{0pt}{4ex} instructions on the preceding lines with % characters. TeX converts the newline characters that follow the \rule{0pt}{4ex} instructions into whitespace, and that's what's showing up in your table.

I would also replace \begin{tabular}[width=\linewidth]{...} with \begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} ...} and, relatedly, \end{tabular} with \end{tabular*}.

A separate issue: Since you don't use \tnote instructions, it's not clear to me why you use a tablenotes environment.

enter image description here

\documentclass{article}% %% I don't have the "cta-author" document class file(s)

\usepackage{booktabs}
\usepackage[skip=0.333\baselineskip]{caption}
\usepackage{threeparttable}
\usepackage{pifont}

\usepackage{array} % for "\newcolumntype" macro
\newcolumntype{P}[1]{>{\raggedright\arraybackslash}p{#1}}
\newcolumntype{C}[1]{>{\centering\arraybackslash}p{#1}}

\usepackage{hyperref}
\begin{document}

\begin{table}[htp]
\begin{threeparttable}
\caption{My table}\label{tab:1}
%\tiny %% why "\tiny"?
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}} 
  P{0.20\linewidth} P{0.30\linewidth} *{4}{C{0.06\linewidth}} }
\toprule
Paper&method&p1&p2&p3&p4\\
\midrule 
\cite{c1} &method1 method1 method1\tnote{*}&\ding{51} & \ding{51}&\ding{51}&\ding{55}\\
\rule{0pt}{4ex}% % <-- note the comment symbol at end of line
\cite{c2} &method2&\ding{51}&\ding{51}&\ding{55}&\ding{55}\\
\rule{0pt}{4ex}% % <-- note the comment symbol at end of line
\cite{c3}&method3 method3 method3 method3 &\ding{55} & \ding{51} &\ding{51} &\ding{55}\\
\midrule % <-- "\midrule" must come before "\rule{0pt}{4ex}"
\rule{0pt}{4ex}% % <-- note the comment symbol at end of line
my experiment test 123&method 4 method4&\ding{51} &\ding{55} & \ding{51} &\ding{51}\\
\bottomrule
\end{tabular*}

\smallskip
\begin{tablenotes}[flushleft]
\item[*] Note
\end{tablenotes}

\end{threeparttable}
\end{table}
\end{document}
1
  • @ Mico: I used tablenotes for some abbreviations in the methods 1, 2,... Thank you again. Nice answer.
    – m123
    Commented Aug 5, 2020 at 16:02
2
  • Sorry, I haven't document class which you use. I replace it with article.
  • To me is not very clear, what is your problem beside erroneous use of table width and rule for distance between table rows
  • if you like to have more vertical space, you can use \addlinespace from the booktabs. It can have options for more vertical space, for example \addlinespace[4ex] which inser vertical space of 4x between rows (why you like to have so much space?)

enter image description here

\documentclass{article}%{cta-author}
\usepackage{pifont}
\usepackage{amssymb}
\usepackage{array, booktabs, threeparttable}
\usepackage[skip=1ex]{caption}
\usepackage{hyperref}


\begin{document}
    \begin{table}[htp]
    \setlength\tabcolsep{0pt}
\begin{threeparttable}
\caption{My table}
\label{tab:1}
\begin{tabular*}{\linewidth}{@{\extracolsep{\fill}}
                             l >{\raggedright}p{0.5\linewidth} c c c c}
    \toprule
Paper       & method    
                & p1            & p2            & p3            & p4        \\
    \midrule
\cite{c1}   & method1 method1 method 1                        
                & \checkmark    & \checkmark    & \checkmark    & \ding{55} \\
    \addlinespace
\cite{c2}   & method2
                & \checkmark    & \checkmark    & \ding{55}     & \ding{55} \\
    \addlinespace
\cite{c3}   & method3 method3 method3 method3 method3 method3 method3 method3 
                & \ding{55}     & \checkmark    & \checkmark    & \ding{55} \\
    \midrule
my experiment test 123
            & method4 method4
                & \checkmark    & \ding{55}     & \checkmark    & \checkmark\\
\bottomrule
\end{tabular*}
\begin{tablenotes}[flushleft]\footnotesize
\item *note
\end{tablenotes}
\end{threeparttable}
    \end{table}
\end{document}
6
  • Thanks, but again with this code the first column is not left alinged. I have added the image of my problem to my question.
    – m123
    Commented Aug 5, 2020 at 15:37
  • @m123, sorry, but first column, as you can see from provided image of table, is left aligned.
    – Zarko
    Commented Aug 5, 2020 at 16:25
  • Yes, you right and thanks. But this is correct If I completely use your code it. But since I needed more spaces between the rows, It faced me with the same problem after joining the codes to add spaces. As Mico mentioned, the problem in my code aroused exactly by my wrong way of adding vertical spaces!
    – m123
    Commented Aug 5, 2020 at 16:32
  • @m123, if you reed my answer, you should find note, how to increase vertical space between rows. To my taste is sufficient add \addlinespace, but if you like to have more vertical space, you can use for example \addlinespace[4ex].
    – Zarko
    Commented Aug 5, 2020 at 16:38
  • As I mentioned your answer and your code is right. But Mico's answer exactly mentions: 1. which part of my code causes the problem 2. Why it causes that reault 3. The solution. These parameters makes his answer more complete. Although I am really appreciated for your correct answer which could really solve my problem. But since both answers (yours and Mico's) were written in close time I have chosen more affirmative one. Really thanks.
    – m123
    Commented Aug 5, 2020 at 16:49

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .