0

Please consider this MWE:

enter image description here

\documentclass[11pt, a4paper]{article}

\begin{document}

\begin{table}[h]
\begin{tabular}{|p{40mm}|p{100mm}|}
    Company & Head Quarters\\
    \hline
    Foo Bar Company  & New York, New York, United States of America\\
    Bar Brothers     & London, United Kingdom\\
\end{tabular}
\caption{Some companies}
\end{table}

\begin{table}[h]
\begin{tabular}{|p{40mm}|p{50mm}|p{50mm}|}
    Fruit            & Likeability & Street names\\
    \hline
    Pears            & meh         & Baker Street\\
    Apples           & meh         & Harbour Street\\
\end{tabular}
\caption{Some random stuff}
\end{table}

\end{document}

Something strange is going on: in Table 2, the middle and right column is set to have a size of 50 mm each. Yet, they are not as wide as the upper table, which is 100 mm. Why is this? What can I do to make sure Table 2 is as wide as Table 1?

2

Turning my comment into an answer:

By default each column is surrounded by one \tabcolsep on each side (resulting in two such spaces when two columns are side by side). You have to consider those in your code and subtract them from your width.

Just as a side note: You can control those spaces using @{<stuff-between-columns} in between two column specifiers. So @{\hspace*{0.5\tabcolsep} would result in half a \tabcolsep there (note that the @{} syntax overwrites both spaces, so if the above is used in between two columns there'll be a total of only 0.5\tabcolsep).

Also note that if you use vertical rules and the package array the vertical rules do take some space (without array they result in the same horizontal space as without). Therefore if you use array you'd have to subtract an additional \arrayrulewidth in the first column, resulting in: {|p{40m}|p{dimexpr50mm-\tabcolsep-\arrayrulewidth\relax}|p{\dimexpr50mm-\tabcolsep\relax}|} as the column specification. (or 0.5\arrayrulewidth in both to get even results)

\documentclass[11pt, a4paper]{article}

\begin{document}

\begin{tabular}{|p{40mm}|p{100mm}|}
    Company & Head Quarters\\
    \hline
    Foo Bar Company  & New York, New York, United States of America\\
    Bar Brothers     & London, United Kingdom\\
\end{tabular}

\begin{tabular}{|p{40mm}|*2{p{\dimexpr50mm-\tabcolsep\relax}|}}
    Fruit            & Likeability & Street names\\
    \hline
    Pears            & meh         & Baker Street\\
    Apples           & meh         & Harbour Street\\
\end{tabular}

\end{document}

enter image description here

1

A solution with tabularx so you won't have to make calculations with \tabcolsep and \arrayrulewidth, and the tables won't overflow into the margin:

\documentclass[11pt, a4paper]{article}
\usepackage[showframe]{geometry}
\usepackage{tabularx}

\begin{document}

\setlength{\extrarowheight}{2pt}
\begin{table}[h]
\begin{tabularx}{\linewidth}{|>{\hsize=0.57\hsize}X|>{\hsize=1.43\hsize\arraybackslash}X|}
    Company & Head Quarters\\
    \hline
    Foo Bar Company & New York, New York, United States of America\\
    Bar Brothers & London, United Kingdom\\
\end{tabularx}
\caption{Some companies}
\end{table}

\begin{table}[h]
\begin{tabularx}{\linewidth}{|>{\hsize=0.85\hsize}X|*{2}{>{\hsize=1.075\hsize\arraybackslash}X|}}
    Fruit & Likeability & Street names\\
    \hline
    Pears & meh & Baker Street\\
    Apples & meh & Harbour Street\\
\end{tabularx}
\caption{Some random stuff}
\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.