4

I want that just one of my columns cells have top padding. I tried :

\def\arraystretch{factor}%

but the result is not ideal. because I don't want all columns have the top padding.

is there anyway to specify top padding for cells of just one column?

Edit

I have a long table with 10 rows and 4 columns that the 4th column has image. this is my code (summarized with 3 columns ):

\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}

The result is like this:

enter image description here

I tried to get padding with {\renewcommand{\arraystretch}{4}% but the result in not good: enter image description here

It would be fine if just cells of 4th column had padding.

anyway I have another problem in this table:

1- Text in the cells are justified and sometimes the space between the words are too much.

I will be thankful for any help.

AshKan
  • 951

1 Answers1

3

Since you use minipage for the images, you can add some padding there:

\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}

Note that I stated the width of the minipage as wide as the p column it's in, and the same for the pictures.

The input might be simplified, taking into account that the scheme is fixed.

enter image description here

With small changes you can have the text in the first three columns beginning at the top. Here I used \vspace{0pt} at the top of the minipages

\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}

enter image description here

egreg
  • 1,121,712
  • thanks. Is there any way that texts of cells begin from top of the cell? – AshKan Dec 24 '14 at 12:41
  • @AshKan Yes, use \begin{minipage}[t]{\linewidth}; you'll probably want to reduce the amount in the first \space. – egreg Dec 24 '14 at 13:28