2

I have a table, built using the tabu package.

My code currently looks like below. The \\[5ex] does increase the row height, but the contents of the third cell is aligned top instead of middle (notice the X[c,m] definition). The \arraystretch changes the height of all the rows, but I only want to increase the height of only the first one.

\documentclass[]{article}

\usepackage{tabu}

\begin{document}

\begin{table}[h!]
    \begin{center}
        \begin{tabu} to 0.5\linewidth {| X[c,m] | X[c,m] | X[c,m] |}
            \hline
            \textbf{First column} & \textbf{Second Column} & \textbf{Third Column} \\[5ex] \hline
            \hline

            1 & 0x1 & 01 \\ \hline
            2 & 0x2 & 02 \\ \hline
            3 & 0x3 & 03 \\ \hline
            4 & 0x4 & 04 \\ \hline
            5 & 0x5 & 05 \\ \hline
            6 & 0x6 & 06 \\ \hline
            7 & 0x7 & 07 \\ \hline
            8 & 0x8 & 010 \\ \hline
            9 & 0x9 & 011 \\ \hline
            10 & 0xa & 012 \\ \hline

        \end{tabu}
    \end{center}

    \caption{Example of another short table, but smaller and centered.}
\end{table}

\end{document}
0

I'll admit it is not pretty, but I placed top rules \tr before each 1st-row column and a bottom rule \br after each 1st-row column.

Trying to accomplish it with a single rule caused inter-word vertical space to appear. And trying to do it in one rather than three columns caused a disparity between the column positioning.

\documentclass[]{article}

\usepackage{tabu}
\newcommand\tr{\rule{0pt}{4.5ex}}
\newcommand\br{\rule[-3ex]{0pt}{3ex}}
\begin{document}

\begin{table}[h!]
    \begin{center}
        \begin{tabu} to 0.5\linewidth {| X[c,m] | X[c,m] | X[c,m] |}
            \hline
            \tr\textbf{First column}\br & \tr\textbf{Second Column}\br &
            \tr\textbf{Third Column}\br \\ \hline
            \hline

            1 & 0x1 & 01 \\ \hline
            2 & 0x2 & 02 \\ \hline
            3 & 0x3 & 03 \\ \hline
            4 & 0x4 & 04 \\ \hline
            5 & 0x5 & 05 \\ \hline
            6 & 0x6 & 06 \\ \hline
            7 & 0x7 & 07 \\ \hline
            8 & 0x8 & 010 \\ \hline
            9 & 0x9 & 011 \\ \hline
            10 & 0xa & 012 \\ \hline

        \end{tabu}
    \end{center}

    \caption{Example of another short table, but smaller and centered.}
\end{table}

\end{document}

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.