表格列有不需要的间距

表格列有不需要的间距

我有一张有两列的表格。

\begin{table}[ht]
\begin{tabular}{|p{12cm}|p{4cm}|}
\hline
\textbf{Company} & \textbf{Contact} \\
\hline
Company produces advanced product systems compatible with a range of blah, blah, and blah used on this and that & Company\\
& 1234\\
& First Street\\
& Troy, New York 12180\\ 
& USA\\ 
\hline
\end{tabular}
\end{table} 

我设置的方式是第二列有一个空白行,该行由第一列的大小设置,如下图所示。我该如何避免这种情况?

在此处输入图片描述

答案1

你的意思是(\usepackage{multirow}在序言中添加)之类的东西?

\begin{table}[ht]
\begin{tabular}{|p{12cm}|p{4cm}|}
\hline
\textbf{Company} & \textbf{Contact} \\
\hline
\multirow{5}{12cm}{Company produces advanced product systems compatible with a range of blah, blah, and blah used on this and that} & Company\\
& 1234\\
& First Street\\
& Troy, New York 12180\\
& USA\\
\hline
\end{tabular}
\end{table}

或(multirow不需要)

\begin{table}[ht]
\begin{tabular}{|p{12cm}|p{4cm}|}
\hline
\textbf{Company} & \textbf{Contact} \\
\hline
Company produces advanced product systems compatible with a range of blah, blah, and blah used on this and that & Company%
\newline 1234%
\newline First Street%
\newline Troy, New York 12180%
\newline USA\\
\hline
\end{tabular}
\end{table}

答案2

根据您的tabular设计,您可以嵌套右侧列条目:

在此处输入图片描述

\documentclass{article}
\begin{document}
\begin{tabular}{|p{8cm}|l|}
  \hline
  \textbf{Company} & \textbf{Contact} \\
  \hline
  Company produces advanced product systems compatible with a range of blah, blah, and blah used on this and that &
  \begin{tabular}[t]{@{}p{4cm}@{}}
    Company \\ 1234 \\ First Street \\ Troy, New York 12180 \\ USA
  \end{tabular} \\
  \hline
\end{tabular}
\end{document}

确保右侧嵌套tabular有一个[t]操作对齐的锚点。

相关内容