2

In the following table, I want to place the Name in the center of the cell while the next row aaaaa-bbbbbb and ddddd in the left of the cell. How can I fix the following figure?

 \begin{table}
    \centering
    \caption{X}
    \label{d}
    \begin{tabular}{|l|c|c|}
        \hline
        name    & X    & Y \\
        \hline
        aaaaa-bbbbbb & * & ** \\
        ddddd & ** & * \\
        \hline
    \end{tabular}
\end{table}   

enter image description here

2 Answers 2

3

Like this:

enter image description here

With tabularray package is simple:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
    \begin{table}
    \centering
    \caption{X}
    \label{d}
\begin{tblr}{hline{1,2,Z}=solid, vlines,
            colspec = {l  cc},
            row{1}  = {c}
            }
name            & X     & Y     \\
aaaaa-bbbbbb    & *     & **    \\
ddddd           & **    & *     \\
 \end{tblr}
    \end{table} 
\end{document}

However, with use of multicolumn instruction can be dona with tabular table too:

\documentclass{article}
\usepackage{tabularray}

\begin{document}
    \begin{table}
    \centering
    \caption{X}
    \label{d}
    \begin{tabular}{|l|c|c|}
        \hline
\multicolumn{1}{|c|}{name}    & X     & Y     \\
        \hline
aaaaa-bbbbbb                & *     & **    \\
ddddd                       & **    & *     \\
        \hline
    \end{tabular}
    \end{table} 
\end{document}

enter image description here

4

Although you should remember that you one argument of \multicolumn is the alignment, and that there are a nice tabulararray package (btw, +1), in this case the simplest is just add \hfil to "name" cell.

\documentclass{article}
\usepackage{xcolor}
\begin{document}
    \begin{tabular}{|l|c|c|}
        \hline
        \hfil name    & X    & Y \\
        \hline
        aaaaa-bbbbbb & * & ** \\
        ddddd & ** & * \\
        \hline
    \end{tabular}
\end{document}

You must log in to answer this question.

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