3

Is it possible to vertically center the cells of one column in a TikZ matrix? Adding nodes = {anchor = center} vertically centers all of the cells, but I would like to retain the bottom alignment of the content of the cells in the second and third column.

That is, how can I vertically center asdf in the first column but retain the bottom alignment of the images in the second and third columns?

MWE

\documentclass{article}
\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{matrix}
\begin{document}
\begin{tikzpicture}
    \matrix[matrix of nodes]{
    asdf & \includegraphics[width=2cm]{example-image-a} & \includegraphics[width=3cm]{example-image-a} \\
    };
\end{tikzpicture}
\end{document}
4

You can use column 1/.style to style just the cells in the first column, or row 2 column 3/.style for a particular cell. Here some styling applied to the first column:

Sample output

\documentclass{article}

\usepackage{mwe}
\usepackage{tikz}
\usetikzlibrary{matrix}

\begin{document}

\begin{tikzpicture}
    \matrix[matrix of nodes,
    column 1/.style={anchor=center,color=red,text depth=2cm}]{
    asdf & \includegraphics[width=2cm]{example-image-a} & \includegraphics[width=3cm]{example-image-a} \\
    bkgi & \includegraphics[width=3cm]{example-image-a} & \includegraphics[width=1cm]{example-image-a} \\
    };
\end{tikzpicture}

\end{document}

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.