3

I am trying to to vertically align cells contents in NiceTabular when they get significantly different heights. However, \adjustbox and makecell do not seem to work (neither does \adjustbox and \Block). Also, \adjustbox seems to provide no good alignment at the baseline of different rows (e.g., 2nd, 4th and 5th rows)

enter image description here

\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 Answer 1

1

You're overcomplicating things with 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}

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.