我想在包含 TikZ 绘图的表格中写入一行booktabs
高于行高的文本。默认情况下,文本与 TikZ 绘图的基线垂直对齐。我希望它与 TikZ 绘图的中间垂直对齐。
这是我的代码:
\documentclass[a4paper,11pt]{scrartcl}
\usepackage{xcolor}
\definecolor{HighlightColor}{RGB}{255,173,97}
\usepackage{booktabs}
\usepackage[radius=.09cm,edgeLength=1.5cm]{dynkin-diagrams}
\usepackage[left=3cm, right=3cm, top=4cm]{geometry}
\usepackage{mathtools}
\usepackage[utf8]{inputenc}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{tikz-cd}
\newcommand{\R}{\mathbb{R}}
\newcommand{\SL}{\operatorname{SL}}
\newcommand{\SO}{\operatorname{SO}}
\usepackage{graphbox}
\begin{document}
\begin{center}
\begin{tabular}[c]{p{1cm}cp{3cm}}
\toprule
$\Phi$ &
Dynkin diagram &
Symmetric space
\\
\midrule
$\Phi_3$ & \vspace{1cm}
\begin{tikzpicture}
\draw[HighlightColor,densely dotted,thick] (0,0.5) arc (90:270:0.5);
\draw[HighlightColor,densely dotted,thick] (1.5,-0.5) arc (270:450:0.5);
\draw[HighlightColor,densely dotted,thick] (0,0.5) -- (1.5,0.5);
\draw[HighlightColor,densely dotted,thick] (0,-0.5) -- (1.5,-0.5);
\dynkin[mark=o,text/.style={scale=1.2}]{B}{3};
\end{tikzpicture}
$\rightarrow$
\begin{tikzpicture}
\dynkin[mark=o,text/.style={scale=1.2}]{A}{2};
\end{tikzpicture}
&
$\SL(3,\R)/\SO(3)$
\\
\bottomrule
\end{tabular}
\end{center}
\end{document}
我拥有的:
我想要的是:
dynkin-diagrams.sty
成立这里。
答案1
您可以使用一个简单的宏垂直居中任何图片而无需猜测值:\newcommand{\ctikz}[1]{$\vcenter{\hbox{#1}}$}
。只需使用\ctikz{<your picture>}
。此外,无需手动\vspace{1cm}
。
\newcommand{\ctikz}[1]{$\vcenter{\hbox{#1}}$}
\begin{center}
\begin{tabular}{p{1cm} c p{3cm}}
\toprule
$\Phi$ & Dynkin diagram & Symmetric space \\
\midrule
$\Phi_3$ & %\vspace{1cm}
\ctikz{%
\begin{tikzpicture}
\draw[HighlightColor,densely dotted,thick] (0,0.5) arc (90:270:0.5);
\draw[HighlightColor,densely dotted,thick] (1.5,-0.5) arc (270:450:0.5);
\draw[HighlightColor,densely dotted,thick] (0,0.5) -- (1.5,0.5);
\draw[HighlightColor,densely dotted,thick] (0,-0.5) -- (1.5,-0.5);
\dynkin[mark=o,text/.style={scale=1.2}]{B}{3};
\end{tikzpicture}
}
$\rightarrow$
\ctikz{%
\begin{tikzpicture}
\dynkin[mark=o,text/.style={scale=1.2}]{A}{2};
\end{tikzpicture}
}
&
$\SL(3,\R)/\SO(3)$
\\
\bottomrule
\end{tabular}
\end{center}
答案2
使用baseline
第一张图片的选项,如所述这里:
\begin{tikzpicture}[baseline=-0.7ex] %<--- adjust as desired
\draw[HighlightColor,densely dotted,thick] (0,0.5) arc (90:270:0.5);
\draw[HighlightColor,densely dotted,thick] (1.5,-0.5) arc (270:450:0.5);
\draw[HighlightColor,densely dotted,thick] (0,0.5) -- (1.5,0.5);
\draw[HighlightColor,densely dotted,thick] (0,-0.5) -- (1.5,-0.5);
\dynkin[mark=o,text/.style={scale=1.2}]{B}{3};
\end{tikzpicture}
\vspace{1cm}
如果您想除去图片下方的多余空间,请删除(或调整)您添加的。
答案3
另一种方法是使用 dynkin 包进行练习:
\documentclass[a4paper,11pt]{scrartcl}
\usepackage[hmargin=3cm, top=4cm]{geometry}
\usepackage{xcolor}
\definecolor{HighlightColor}{RGB}{255,173,97}
\usepackage{booktabs}
\usepackage[radius=.09cm,edgeLength=1.5cm]{dynkin-diagrams}
\usepackage{mathtools} % it also loads amsmath
\usepackage[utf8]{inputenc}
\usepackage{amsfonts}
\newcommand{\R}{\mathbb{R}}
\newcommand{\SL}{\operatorname{SL}}
\newcommand{\SO}{\operatorname{SO}}
\usepackage{graphbox}
\begin{document}
\begin{center}
\begin{tabular}{p{1cm}cp{3cm}}
\toprule
$\Phi$ & Dynkin diagram & Symmetric space \\
\midrule
$\Phi_3$ & \begin{tikzpicture}[baseline=-0.75ex]
\draw[HighlightColor,densely dotted,thick] (0.0,-0.5) arc (270:90:0.5) --
(1.5, 0.5) arc (90:-90:0.5) -- cycle;
\dynkin[mark=o,text/.style={scale=1.2}] {B}{3};
\draw[->] (3.3,0) -- + (0.5,0);
\scoped[xshift=41mm]\dynkin[mark=o,text/.style={scale=1.2}]{A}{2};
\end{tikzpicture}
& $\SL(3,\R)/\SO(3)$ \\
\bottomrule
\end{tabular}
\end{center}
\end{document}
答案4
考虑到 Benjamin McKay 对上述软件包的回答,他告诉我们(至少是我),这个软件包的新版本有一些变化,不具有向后兼容性...以及这个软件包的一些使用可能性,新的解决方案可以是:
\documentclass[a4paper,11pt]{scrartcl}
\usepackage[hmargin=3cm, top=4cm]{geometry}
\usepackage{xcolor}
\definecolor{HighlightColor}{RGB}{255,173,97}
\usepackage{booktabs}
\usepackage[radius=.09cm,
edge-length=1.5cm, % <--- new syntax for edge lengths
mark=o]{dynkin-diagrams}
\usetikzlibrary{fit, shapes.misc}
\newcommand{\R}{\mathbb{R}}
\newcommand{\SL}{\operatorname{SL}}
\newcommand{\SO}{\operatorname{SO}}
\begin{document}
\begin{center}
\begin{tabular}{p{1cm}cp{3cm}}
\toprule
$\Phi$ & Dynkin diagram & Symmetric space \\
\midrule
$\Phi_3$ & \begin{tikzpicture}[baseline]
\dynkin{B}{3}
\node[rounded rectangle, draw=HighlightColor,
densely dotted, thick, fit=(root 1) (root 2)] {};
\draw[->] (root 3) ++ (4mm,0) -- ++ (0.5,0) node[-,right]{\dynkin{A}{2}};
\end{tikzpicture}
& $\SL(3,\R)/\SO(3)$ \\
\bottomrule
\end{tabular}
\end{center}
\end{document}
其结果与其他答案几乎相同: