仅填充一列单元格,而不是表格的所有单元格

仅填充一列单元格,而不是表格的所有单元格

我希望只有一列单元格具有顶部填充。我试过:

\def\arraystretch{factor}%

但结果并不理想。因为我不希望所有列都有顶部填充。

有没有办法为仅一列的单元格指定顶部填充?

编辑

我有一张有 10 行 4 列的长表,第 4 列有图像。这是我的代码(总结为 3 列):

\begin{longtable}{|p{2cm}|p{3cm}|p{8cm}|p{2cm}|}
\caption{my caption}
\label{table:10.1}
\\
\hline

\centering titile 1     &  \centering title 2 & \centering title 3 &  {\centering  title 4}  \\
\hline \hline
first r first c &  first r second c &  first r third c & 
      \begin{minipage}{.12\textwidth}
      \includegraphics[width=\linewidth]{table10-1-1.png}
    \end{minipage}
 \\
\hline
second r first c & second r second c  &  second r third c & 
\begin{minipage}{.12\textwidth}
      \includegraphics[width=\linewidth]{table10-1-2.png}
    \end{minipage}
     \\
\hline
third r first c &  third r second d &  third r third c & 
\begin{minipage}{.12\textwidth}
      \includegraphics[width=\linewidth]{table10-1-3.png}
    \end{minipage} 

    \\
\hline
\end{longtable}

结果是这样的:

在此处输入图片描述

我尝试使用 {\renewcommand{\arraystretch}{4}% 来获得填充,但结果并不好: 在此处输入图片描述

如果只有第四列的单元格有填充,那就没问题了。

无论如何,我在这张表中遇到了另一个问题:

1- 单元格中的文本是对齐的,有时单词之间的间距太大。

我将感谢任何帮助。

答案1

由于您使用minipage图像,因此您可以在其中添加一些填充:

\documentclass{article}
\usepackage[margin=1cm]{geometry}% just for not having overfull lines
\usepackage{graphicx}
\usepackage{longtable,array}

\begin{document}
\begin{longtable}{|p{2cm}|p{3cm}|p{8cm}|p{2cm}|}
\caption{my caption}
\label{table:10.1}
\\
\hline

\centering title 1 &
  \centering title 2 &
  \centering title 3 &
  \centering\arraybackslash title 4 \\
\hline \hline
first r first c &  first r second c &  first r third c & 
  \begin{minipage}{\linewidth}
  \vspace{12pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
 \\
\hline
second r first c & second r second c  &  second r third c & 
  \begin{minipage}{\linewidth}
  \vspace{12pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
\\
\hline
third r first c &  third r second d &  third r third c & 
  \begin{minipage}{\linewidth}
  \vspace{12pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{3pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
\\
\hline
\end{longtable}
\end{document}

请注意,我指出的宽度minipage与它所在的列一样宽p,图片的宽度也是一样。

考虑到方案是固定的,输入可能会被简化。

在此处输入图片描述

只需进行一些小改动,您就可以将前三列中的文本从顶部开始。在这里,我\vspace{0pt}在小页面的顶部使用了

\documentclass{article}
\usepackage[margin=1cm]{geometry}% just for not having overfull lines
\usepackage{graphicx}
\usepackage{longtable,array}

\begin{document}
\begin{longtable}{|p{2cm}|p{3cm}|p{8cm}|p{2cm}|}
\caption{my caption}
\label{table:10.1}
\\
\hline

\centering title 1 &
  \centering title 2 &
  \centering title 3 &
  \centering\arraybackslash title 4 \\
\hline \hline
first r first c &  first r second c &  first r third c & 
  \begin{minipage}[t]{\linewidth}
  \vspace{0pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
 \\
\hline
second r first c & second r second c  &  second r third c & 
  \begin{minipage}[t]{\linewidth}
  \vspace{0pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
\\
\hline
third r first c &  third r second d &  third r third c & 
  \begin{minipage}[t]{\linewidth}
  \vspace{0pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{3pt}
  \includegraphics[width=\linewidth]{example-grid-100x100pt}\par
  \vspace{12pt}
  \end{minipage}
\\
\hline
\end{longtable}
\end{document}

在此处输入图片描述

相关内容