1

I have the following table. I want to make all cells alignment to the right except the first row where the table's headers, I need the alignment centre. I used \multicol{1}{c}{col.} for the header cells, but I am wondering, is there a better way without adding too much text to the table header's code? I want the code to be clean.

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{booktabs}
\usepackage{array, makecell} 

\begin{document}

\title{Title}

\begin{abstract}
Abstract  
\end{abstract}

\maketitle

\begin{table}
    \caption{Table's caption.}
    \label{tab:table1}
    \begin{tabular}{llll}
        \toprule
        Col 1   & Col 2  & Col 3    & Col 4    \\
        \midrule
        item1   & item2  & item3    & item4 \\
        \hline
        item11  & item22 & item33   & item44     \\
        \hline
        item111 & item222 & item333 & item444     \\
        \bottomrule
    \end{tabular}   
\end{table}

\end{document}
1

since you use makecell in your document, let exploit its macro \thead:

\documentclass[11pt,twoside,a4paper]{article}
\usepackage{booktabs, makecell}
\renewcommand\theadfont{\normalsize}
\renewcommand\theadgape{}

\begin{document}

\title{Title}
\maketitle

\begin{table}[htb]
\centering
    \caption{Table's caption.}
    \label{tab:table1}
    \begin{tabular}{llll}
        \toprule
    \thead{Col 1}   & \thead{Col 2}  & \thead{Col 3}    & \thead{Col 4}    \\
        \midrule
        item1   & item2  & item3    & item4 \\
        \hline
        item11  & item22 & item33   & item44     \\
        \hline
        item111 & item222 & item333 & item444     \\
        \bottomrule
    \end{tabular}
\end{table}

enter image description here

edit: of-topic, i would not use `\hline in your table. without them table will looks nicer (to my opinion, of course):

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.