create table with only header bold and center

Tabular does not have a concept of a header. If you want to have one, you have to modify the first row yourself. As Mico pointed out

\begin{tabular}{|l|l|l|l|}
\hline
\multicolumn{1}{c}{\bfseries <Header 1>} & \multicolumn{1}{c}{\bfseries <Header 2>} & \multicolumn{1}{c}{\bfseries <Header 3>} & \multicolumn{1}{c}{\bfseries <Header 4>} \\ \hline
a & b & c & d \\ \hline
a & b & c & d \\ \hline
\end{tabular}

Of course, this is somewhat verbose and cumbersome. Two possible simplifications:

  1. First possibility: Define a macro for this

    \newcommand*{\thead}[1]{\multicolumn{1}{c}{\bfseries #1}}
    

    and then use it:

    \begin{tabular}{|l|l|l|l|}
    \hline
    \thead{<Header 1>} & \thead{<Header 2>} & \thead{<Header 3>} & \thead{<Header 4>} \\ \hline
    a & b & c & d \\ \hline
    a & b & c & d \\ \hline
    \end{tabular}
    
  2. Second possibiliy: Alternatively, use the tabu package, which allows to specify individual row formating via the \rowfont command

    \begin{tabu}{|l|l|l|l|}
    \hline
    \rowfont[c]{\bfseries} <Header 1> & <Header 2> & <Header 3> & <Header 4> \\ \hline
    a & b & c & d \\ \hline
    a & b & c & d \\ \hline
    \end{tabu}
    

With use of package makecell and its macro \thead it is simple to fulfill requested table format:

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{makecell}
\renewcommand\theadfont{\bfseries\sffamily}

\begin{document}
    \begin{tabular}{|l|l|l|l|}
    \hline
\thead{<Header 1>} & \thead{<Header 2>} & \thead{<Header 3>} & \thead{<Header 4>} \\ 
                    \hline
a & b & c & d \\    \hline
a & b & c & d \\    \hline
    \end{tabular}
\end{document}

enter image description here


To get the vertical lines in the header of the table properly aligned with the body columns, use the following:

\multicolumn{1}{|c|}{Header 1} & \multicolumn{1}{c|}{Header 2} & \multicolumn{1}{c|}{Header 3}

Tags:

Tables