3

I have a file with content akin to the following (which will be the base of my MWE) with the result shown: Desired

Here's the MWE:

\documentclass{article}
\usepackage{booktabs}
\begin{document}
\begin{tabular}{c c@{\hspace{0.5em}}c}
  Item & \multicolumn{2}{c}{Type} \\
  \midrule
  Thing 1 & babel & bottle \\
  Thing 2 & cable & cattle \\
  Thing 3 & fable & fiddle \\
\end{tabular}
\end{document}

This is exactly what I want. Unexpectedly, when I changed "Type" to something wider than the second and third columns, I obtained this result: enter image description here

I expected the width between the second and third columns to remain the same, and that both would be centered under the header "Representations". I played around with a number of things, but I could not achieve that result.

1

2 Answers 2

2

I propose increasing the last \tabcolsep and using \makebox[0pt]:

\documentclass{article}
\usepackage{booktabs}

\begin{document}

\begin{tabular}{c c@{\hspace{0.5em}}c@{\hspace{0.7em}}}
  Item & \multicolumn{2}{c}{\makebox[0em]{Representation}} \\
  \midrule
  Thing 1 & babel & bottle \\
  Thing 2 & cable & cattle \\
  Thing 3 & fable & fiddle \\
\end{tabular}

\end{document} 

enter image description here

2
  • This seems to work, thanks. Why did you increase the last \tabcolsep? Was is just for esthetics, or does it serve a role in the solution?
    – Derek
    Aug 12, 2018 at 16:20
  • @Derek: Yes, it's for æsthetics – \tabcolsep was minimally increased, and @{\hspace{0.7em}} was added, so that Representation doesn't go beyond the end of \midrule.
    – Bernard
    Aug 12, 2018 at 16:49
2

Here is a proposal using nested tabular

enter image description here

\documentclass{article}
\usepackage{booktabs}
\begin{document}

\begin{tabular}{c c}
  Item & Type \\
  \midrule
          \begin{tabular}{c}
            Thing 1\\
            Thing 2\\
            Thing 3\\
          \end{tabular}
           &
          \begin{tabular}{c c}
             babel & bottle \\
             cable & cattle \\
             fable & fiddle \\
        \end{tabular}
\end{tabular}

\vspace{0.5cm}
\begin{tabular}{c c}
  Item & Representation \\
  \midrule
          \begin{tabular}{c}
            Thing 1\\
            Thing 2\\
            Thing 3\\
          \end{tabular}
           &
          \begin{tabular}{c c}
             babel & bottle \\
             cable & cattle \\
             fable & fiddle \\
        \end{tabular}
\end{tabular}
\end{document}
1
  • This is an interesting solution. Unfortunately in my case, my actual table is more complex, making the horizontal alignment too tricky for this solution.
    – Derek
    Aug 12, 2018 at 16:29

You must log in to answer this question.

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