![如何在表格环境中垂直居中小页面](https://linux22.com/image/293629/%E5%A6%82%E4%BD%95%E5%9C%A8%E8%A1%A8%E6%A0%BC%E7%8E%AF%E5%A2%83%E4%B8%AD%E5%9E%82%E7%9B%B4%E5%B1%85%E4%B8%AD%E5%B0%8F%E9%A1%B5%E9%9D%A2.png)
我的目标是让第二列的 minipage 垂直居中,但我做不到。我尝试使用带有“m”选项的数组包:
\tabular{c|m}
但没有成功,我还尝试将选项设置[t]
为和,minipage
但tabular
没有成功。
你知道怎样让它发挥作用吗?
这是一个最小的例子:
\documentclass[10pt,mathserif,smaller,fleqn]{beamer}
\usepackage{tikz}
\usepackage{multicol}
\usepackage[utf8]{inputenc}
\usetheme{Antibes}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\frame{
\begin{center}
\begin{tabular}[t]{c|c}
\multicolumn{2}{c}{Une architecture hybride}\\[0.4em]
\hline~\\[0.4em]
\begin{tikzpicture}[scale=.5]
\input{hybride.tikz}
\end{tikzpicture}
&
\begin{minipage}[t]{0.4\textwidth}
\begin{itemize}
\item bla
\item bla
\item bla
\end{itemize}
\end{minipage}
\end{tabular}
\end{center}
}
\end{document}
这是文件 hybride.tikz
\tikzset{client/.style={draw,rectangle,rounded corners=3pt,color=blue},
server/.style={draw,rectangle,color=red}};
\node[client] (A) at (0,0) {Pair};
\node[client] (B) at (8,0) {Pair};
\node[client] (C) at (4,6.92) {Pair};
\node[server] (D) at (4,2.31) {Oracle};
\draw[->, >=latex, color=blue] (A) to[bend left=10] (B);
\draw[->, >=latex, color=blue] (A) to[bend left=10] (C);
\draw[->, >=latex, color=blue] (B) to[bend left=10] (A);
\draw[->, >=latex, color=blue] (B) to[bend left=10] (C);
\draw[->, >=latex, color=blue] (C) to[bend left=10] (A);
\draw[->, >=latex, color=blue] (C) to[bend left=10] (B);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (A);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (B);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (C);
答案1
如果第二列应垂直居中于图片,则可以使用两m
列
\begin{tabular}{>{\centering}m{0.5\textwidth}|m{0.4\textwidth}}
代码:
\documentclass[10pt,mathserif,smaller,fleqn]{beamer}
\usepackage{tikz}
\usepackage{multicol}
\usepackage[utf8]{inputenc}
\usetheme{Antibes}
\setbeamertemplate{navigation symbols}{}
\usepackage{array}
\begin{document}
\begin{frame}
\begin{center}
\begin{tabular}{>{\centering}m{0.5\textwidth}|m{0.4\textwidth}}
\multicolumn{2}{c}{Une architecture hybride}\\[0.4em]
\hline~\\[0.4em]
\begin{tikzpicture}[scale=.5]
\tikzset{
client/.style={draw,rounded corners=3pt,color=blue},
server/.style={draw,color=red},
}
\foreach \n/\p in {A/{0,0},B/{8,0},C/{4,6.92}}
\node[client](\n) at (\p) {Pair};
\node[server] (D) at (4,2.31) {Oracle};
\foreach \x/\y/\z in {A/B/C,B/A/C,C/A/B}
\path[-latex,blue,bend left=10](\x) edge (\y)edge (\z);
\foreach \x in {A,B,C}
\draw[-latex,thick,red,dashed] (D) -- (\x);
\end{tikzpicture}
&
\begin{minipage}{\linewidth}
\begin{itemize}
\item bla
\item bla
\item bla
\end{itemize}
\end{minipage}\\[0.8em]
~
\end{tabular}
\end{center}
\end{frame}
\end{document}
答案2
另一种方法是使用adjustbox
带export
选项的包。这里valign=t,c,b
可以使用minipage
位置说明符 t、c、b
代码
\documentclass[10pt,mathserif,smaller,fleqn]{beamer}
\usepackage{tikz}
\usepackage[export]{adjustbox}
\usepackage{multicol}
\usepackage[utf8]{inputenc}
\usetheme{Antibes}
\setbeamertemplate{navigation symbols}{}
\begin{document}
\frame{
\begin{center}
\begin{tabular}[t]{c|c}
\multicolumn{2}{c}{Une architecture hybride}\\[0.4em]
\hline~\\[0.4em]
\begin{adjustbox}{valign=c}
\begin{tikzpicture}[scale=.5]
\tikzset{client/.style={draw,rectangle,rounded corners=3pt,color=blue},
server/.style={draw,rectangle,color=red}};
\node[client] (A) at (0,0) {Pair};
\node[client] (B) at (8,0) {Pair};
\node[client] (C) at (4,6.92) {Pair};
\node[server] (D) at (4,2.31) {Oracle};
\draw[->, >=latex, color=blue] (A) to[bend left=10] (B);
\draw[->, >=latex, color=blue] (A) to[bend left=10] (C);
\draw[->, >=latex, color=blue] (B) to[bend left=10] (A);
\draw[->, >=latex, color=blue] (B) to[bend left=10] (C);
\draw[->, >=latex, color=blue] (C) to[bend left=10] (A);
\draw[->, >=latex, color=blue] (C) to[bend left=10] (B);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (A);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (B);
\draw[->, >=latex, thick, color=red, dashed] (D) -- (C);
\end{tikzpicture}
\end{adjustbox}
&
\begin{minipage}[c]{0.4\textwidth}
\begin{itemize}
\item bla
\item bla
\item bla
\end{itemize}
\end{minipage}
\end{tabular}
\end{center}
}
\end{document}