如何垂直对齐 NiceTabular 中的单元格内容?

如何垂直对齐 NiceTabular 中的单元格内容?

NiceTabular当单元格高度相差很大时,我尝试垂直对齐单元格内容。但是,\adjustboxmakecell似乎不起作用(和也不起作用\adjustbox\Block。此外,\adjustbox似乎无法在不同行(例如,第 2、第 4 和第 5 行)的基线处提供良好的对齐效果

在此处输入图片描述

\documentclass{scrreprt}

\usepackage[x11names]{xcolor}
\usepackage{adjustbox}

\usepackage{nicematrix}

\usepackage{makecell}

\begin{document}

{\centering
    
    \begin{NiceTabular}[b]{|c|c|c|}[code-before=\cellcolor{DodgerBlue3}{3-1,2-2,1-3}, hvlines]
        \hline
        \adjustbox{valign=m}{a} & \adjustbox{valign=m}{b} & \adjustbox{valign=m}{\includegraphics[width=0.47\linewidth]{example-image-C}}
        \\
        \hline
        \adjustbox{valign=m}{e} & \adjustbox{valign=m}{f} & g
        \\
        \hline
        h & i & \makecell[c]{j \\ basmah \\ shafaamri}
        \\
        \adjustbox{valign=b}{h} & \adjustbox{valign=b}{i} & \adjustbox{valign=b}{\makecell[c]{j \\ basmah \\ shafaamri}}
        \\
        \adjustbox{valign=b}{h} & \adjustbox{valign=b}{i} & \adjustbox{valign=b}{\Block{1-1}{j \\ basmah \\ shafaamri}}
        \\
        \hline
    \end{NiceTabular}

}
    
\end{document}

答案1

您把事情弄得太复杂了adjustbox

\documentclass{scrreprt}

\usepackage[x11names]{xcolor}
\usepackage[export]{adjustbox}

\usepackage{nicematrix}

\usepackage{makecell}

\begin{document}

    
\begin{NiceTabular}{|c|c|c|}[code-before=\cellcolor{DodgerBlue3}{3-1,2-2,1-3}, hvlines]
\hline
a & b & \includegraphics[width=0.47\linewidth,valign=m]{example-image-c} \\
\hline
a & b & \includegraphics[width=0.47\linewidth,valign=b]{example-image-c} \\
\hline
e & f & g \\
\hline
h & i & \makecell[c]{j \\ basmah \\ shafaamri} \\
h & i & \makecell[b]{j \\ basmah \\ shafaamri} \\
\hline
\end{NiceTabular}
    
\end{document}

在此处输入图片描述

相关内容