5

I have the following LaTeX code which very nearly does what I want:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}

\begin{document}
\begin{table}
  \begin{tabular}{ | p{1.5cm} | p{1cm} | c | c | }
    \hline
     & Fully Translated & Linearized & Stabilized \\
    \hline
    MulDA Partial &  &  &  \\
    \hline
    MulDA Full & \multirow{2}{*}{X} &  &  \\
    \hline
    Stabilized Partial &  &  & \multirow{2}{*}{X} \\
    \hline
    Stabilized Full & \multirow{2}{*}{X} &  & \multirow{2}{*}{X} \\
    \hline
    Linearized Partial &  & \multirow{2}{*}{X} &  \\
    \hline
    Linearized Full & \multirow{2}{*}{X} & \multirow{2}{*}{X} &  \\
    \hline
  \end{tabular}
\end{table}

\end{document}

However, the Xs in the second column are slightly off to the left.

Xs slightly off to the left

How do I fix this? I've tried using m or c instead of p, and using c comes close, but then it makes the column too big so it overflows.

EDIT: ChatGPT recommended using parbox which almost works, but makes the text in the box too cramped:

text too cramped

Here's the code for that one:

\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{multirow}

\begin{document}
\begin{tabular}{ | p{1.5cm} | c | c | c | }
    \hline
     & \parbox{1.5cm}{Fully\newline Trans-\newline lated} & Linearized & Stabilized \\
    \hline
    MulDA Partial &  &  &  \\
    \hline
    MulDA Full & \multirow{2}{*}{X} &  &  \\
    \hline
    Stabilized Partial &  &  & \multirow{2}{*}{X} \\
    \hline
    Stabilized Full & \multirow{2}{*}{X} &  & \multirow{2}{*}{X} \\
    \hline
    Linearized Partial &  & \multirow{2}{*}{X} &  \\
    \hline
    Linearized Full & \multirow{2}{*}{X} & \multirow{2}{*}{X} &  \\
    \hline
  \end{tabular}
\end{document}

3 Answers 3

5

With tblr of tabularray package the table code is simple and result is (at least to my opinion) nicer:

enter image description here

\documentclass{article}
\usepackage{tabularray}

\begin{document}
    \begin{table}
\begin{tblr}{hlines, vlines,
            colspec = {Q[l,m,wd=1.6cm] Q[c,m,wd=1cm] Q[c,m] Q[c,m]},
            %rowsep=1pt
            }
                    & Fully Translated
                        & Linearized
                            & Stabilized    \\
MulDA Partial       &   &   &               \\
MulDA Full          & X &   &               \\
Stabilized Partial  &   &   & X             \\
Stabilized Full     & X &   & X             \\
Linearized Partial  &   & X &               \\
Linearized Full     & X & X &               \\
\end{tblr}
    \end{table}
\end{document}
6

No \multirow. Use \Centering from ragged2e and the m column type from array.

\documentclass{article}
\usepackage{ragged2e,array}

\begin{document}
\begin{table}

\begin{tabular}{
  |
  >{\Centering}m{1.6cm}
  |
  >{\Centering}m{1cm} | c | c | }
\hline
& Fully Translated & Linearized & Stabilized \\
\hline
MulDA Partial &  &  &  \\
\hline
MulDA Full & X &  &  \\
\hline
Stabilized Partial &  &  & X \\
\hline
Stabilized Full & X &  & X \\
\hline
Linearized Partial &  & X &  \\
\hline
Linearized Full & X & X &  \\
\hline
\end{tabular}

\end{table}

\end{document}

enter image description here

A different style

\documentclass{article}
\usepackage{booktabs}

\newcommand{\splitcell}[1]{\begin{tabular}{@{}c@{}}#1\end{tabular}}

\begin{document}
\begin{table}

\begin{tabular}{@{}lccc@{}}
\toprule
& \splitcell{Fully \\ Translated} & Linearized & Stabilized \\
\midrule
\textit{MulDA} \\
\quad Partial &  &  &  \\
\quad Full & X &  &  \\
\midrule
\textit{Stabilized} \\
\quad Partial &  &  & X \\
\quad Full & X &  & X \\
\midrule
\textit{Linearized} \\
\quad Partial &  & X &  \\
\quad Full & X & X &  \\
\bottomrule
\end{tabular}

\end{table}

\end{document}

enter image description here

3

It took a few iterations with ChatGPT (I ended up writing this final version myself based on advice from ChatGPT), but I finally got what I wanted:

Correctly centered image

\begin{tabular}{ | p{1.5cm} | c | c | c | c | }
    \hline
     & \parbox{1cm}{\vspace{0.1cm}\centering Fully\newline Trans-\newline lated\vspace{0.1cm}} & Linearized & Stabilized \\
    \hline
    MulDA Partial &  &  &  \\
    \hline
    MulDA Full & \multirow{2}{*}{X} &  &  \\
    \hline
    Stabilized Partial &  &  & \multirow{2}{*}{X} \\
    \hline
    Stabilized Full & \multirow{2}{*}{X} &  & \multirow{2}{*}{X} \\
    \hline
    Linearized Partial &  & \multirow{2}{*}{X} &  \\
    \hline
    Linearized Full & \multirow{2}{*}{X} & \multirow{2}{*}{X} &  \\
    \hline
\end{tabular}

You must log in to answer this question.

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