0

I have a table with pictures and want to center them vertically and horizontally in cell. I used \cellspacetoplimit and \cellsapcebottomlimit for that and I'm inserting them with custom command \newcommand\cincludegraphics[2][]{\raisebox{-0.5\height}{\includegraphics[#1]{#2}}} and they're still touching the lines: enter image description here

How can I fix that?

Example:

\begin{table}[H]
    \centering
    \caption{Interpretowane pokrycia terenu}
    \label{tab:ndvi}
    \begin{tabular}{|c|c|c|c|c|}
        \hline
        \textbf{Zabudowa} & \textbf{Woda} & \textbf{Las} & \textbf{Gunt orny} & 
        \textbf{Uprawa trwała} \\ \hline
        \cincludegraphics[width=4.5cm]{../screeny/NDVI/NDVI_reklas_bud} & 
        \cincludegraphics[width=4.5cm]{../screeny/NDVI/NDVI_reklas_woda} & 
        \cincludegraphics[width=4.5cm]{../screeny/NDVI/NDVI_reklas_las} & 
        \cincludegraphics[width=4.5cm]{../screeny/NDVI/NDVI_reklas_rola} & 
        \cincludegraphics[width=4.5cm]{../screeny/NDVI/NDVI_reklas_laki} \\ 
        \hline
    \end{tabular}
\end{table}
muzimuzhi Z
  • 26,474

1 Answers1

0

The following might give you an idea on how to combine valign=c, cellspace and nested tabulars:

enter image description here

\documentclass{article}
\usepackage{graphicx}
\usepackage{cellspace}
\usepackage[export]{adjustbox}

\setlength{\cellspacetoplimit}{\tabcolsep}
\setlength{\cellspacebottomlimit}{\tabcolsep}

\begin{document}

\begin{tabular}{ScScSc}
\hline
\begin{tabular}{@{}Sc@{}}
\includegraphics[height=2cm, valign=c]{example-image} \\
\includegraphics[height=2cm, valign=c]{example-image}
\end{tabular} 
& \includegraphics[height=4.4cm, valign=c]{example-image} &
\begin{tabular}{@{}Sc@{}}
\includegraphics[height=2cm, valign=c]{example-image} \\
\includegraphics[height=2cm, valign=c]{example-image}
\end{tabular} \\
\hline
\end{tabular}

\end{document}
leandriis
  • 62,593