Cellspace 包问题

Cellspace 包问题

我有一张包含图片的表格,想让它们在单元格中垂直和水平居中。为此,我使用了\cellspacetoplimit和,并使用自定义命令插入它们,但它们仍然接触到以下线条:\cellsapcebottomlimit\newcommand\cincludegraphics[2][]{\raisebox{-0.5\height}{\includegraphics[#1]{#2}}}在此处输入图片描述

我该如何修复它?

例子:

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

答案1

以下内容可能会让您了解如何组合valign=ccellspace和嵌套表格:

在此处输入图片描述

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

相关内容