1

I want to place three tcolorboxes among themselves with arrows between them. To the left of each colorbox is a text that should be center aligned with respect to the box.

The following code produces the boxes, arrows and texts, but I miss the vertical center alignment.

\begin{tabularx}{0.5\textwidth}{p{0.6cm}c}
        1979 & 
        \begin{tcolorbox}[colframe=tubsred,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,width=0.7\textwidth, halign = center]
            Text A
        \end{tcolorbox} \\
        %
        & \begin{tikzpicture}[line cap = round]
        \draw[tubsred, line width = 3pt, ->] (0,0) -- (0,-0.5);
        \end{tikzpicture} \\
        %
        1992 & 
        \begin{tcolorbox}[colframe=tubsred,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,width=0.7\textwidth, halign = center]
            Text B
        \end{tcolorbox} \\
        %
        & \begin{tikzpicture}[line cap = round]
        \draw[tubsred, line width = 3pt, ->] (0,0) -- (0,-0.5);
        \end{tikzpicture} \\
        %
        This \newline Work & 
        \begin{tcolorbox}[colframe=tubsred,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,width=0.7\textwidth, halign = center]
            Text C
        \end{tcolorbox} \\
        %
    \end{tabularx}

Current: Current

Wanted: Wanted

What's the best way to achieve this behavior?

1

1 Answer 1

1

Here I use the baseline= key to tcolorbox. For the single line entries, its value should be that of bottom plus the line thickness, estimated here as 7.5pt. For the 2-line entry, I had to add 1/2 of a \normalbaselineskip.

\documentclass{article}
\usepackage{tcolorbox,tabularx,tikz}
\begin{document}
\begin{tabularx}{0.5\textwidth}{p{0.6cm}c}
        1979 & 
        \begin{tcolorbox}[baseline=7.5pt,
        colframe=red,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,
            width=0.7\textwidth, halign = center]
            Text A
        \end{tcolorbox} \\
        %
        & \begin{tikzpicture}[line cap = round]
        \draw[red, line width = 3pt, ->] (0,0) -- (0,-0.5);
        \end{tikzpicture} \\
        %
        1992 & 
        \begin{tcolorbox}[baseline=7.5pt,
        colframe=red,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,
            width=0.7\textwidth, halign = center]
            Text B
        \end{tcolorbox} \\
        %
        & \begin{tikzpicture}[line cap = round]
        \draw[red, line width = 3pt, ->] (0,0) -- (0,-0.5);
        \end{tikzpicture} \\
        %
        This \newline Work & 
        \begin{tcolorbox}[baseline=\dimexpr7.5pt+.5\normalbaselineskip\relax,
        colframe=red,colback=white,arc=4pt,
            left=6pt,right=6pt,top=6pt,bottom=6pt,boxsep=0pt,
            width=0.7\textwidth, halign = center]
            Text C
        \end{tcolorbox} \\
        %
    \end{tabularx}
\end{document}

enter image description here

0

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .