Latex Beamer - 垂直居中对齐 tcolorbox 左侧的文本

Latex Beamer - 垂直居中对齐 tcolorbox 左侧的文本

我想在三个颜色框之间放置箭头。每个颜色框左侧是一段文本,文本应相对于颜色框居中对齐。

以下代码产生了框、箭头和文本,但我错过了垂直居中对齐。

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

当前的: 当前的

通缉: 通缉

实现这一行为的最佳方法是什么?

答案1

这里我使用了baseline=tcolorbox。对于单行条目,其值应为bottom加上线条粗细,这里估计为7.5pt。对于 2 行条目,我必须添加 的 1/2 \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}

在此处输入图片描述

相关内容