为什么下面的表格没有水平对齐?
我的 MWE:
\documentclass[ignorenonframetext,xcolor={table,svgnames}]{beamer}
\usepackage{tikz}
\usepackage{amssymb,amsmath}
\usetikzlibrary{shapes,backgrounds,fit,positioning}
\usetikzlibrary{decorations.pathreplacing,angles,quotes}
\usetikzlibrary{calc}
\tikzset{every picture/.style={remember picture}}
\begin{document}
\begin{frame}[b]
\tikzset{na/.style={baseline=-.5ex}}
\begin{table}
$\kern-\nulldelimiterspace\left.
\begin{tabular}{|c|c|c|c|c|}
\hline
$C$ & $C_{1}$ & $C_{2}$ & \ldots & $C_{q^k}$
\tikz[na] \node[coordinate] (t1) {gi};\\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{3}+C$ & $v_{3}+0$ & $ \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (bug)
{$v_{3}+C_{2}$};
} $ & \ldots & $v_{3}+C_{q^k}$ \\
\hline
$\ldots$ & $\ldots$ & $\ldots$ & \ldots & $\ldots$ \\
\hline
\end{tabular}\right\}$ $\omega(v_{i})\leq t$
$\kern-\nulldelimiterspace\left.
\begin{tabular}{|c|c|c|c|c|}
\hline
$v_{2}+C$ & $v_{2}+0 $ & $ \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (dug){$v_{2}+C_{2}$};} $ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
\end{tabular}\right\}$ $\omega(v_{i}) > t$
\end{table}
1 \tikz[na] \node[coordinate] (booh) {};
\begin{tikzpicture}[overlay]
\path[very thick,->] (t1) edge [bend right] (bug);
\path[very thick,->] (booh) edge [bend left] (bug);
\end{tikzpicture}
\end{frame}
\end{document}
答案1
您的问题的原因已经在 JMP 答案中确定(他的反应太快了...),所以我只对您的代码进行了一些优化(这会消耗这三分钟:-) ):
\documentclass{beamer}
\usepackage{tikz}
\usepackage{amssymb,amsmath}
\usetikzlibrary{angles,
backgrounds,
calc,
decorations.pathreplacing,
fit,
positioning,
quotes,
shapes}
\tikzset{
every picture/.style = {remember picture},
na/.style = {baseline=-.5ex}
}
\begin{document}
\begin{frame}[b]
\qquad$\left.\begin{array}{|*{5}{c|}}
\hline
C & C_{1} & C_{2} & \ldots
& C_{q^k}\tikz[na]\node[coordinate] (t1) {gi}; \\
\hline
v_{2}+C & v_{2}+0 & \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (bug)
{$v_{2}+C_{2}$};}
& \ldots
& v_{2}+C_{q^k} \\
\hline
v_2+C & v_2+0 & v_2+C_2 & \ldots
& v_{2}+C_{q^k} \\
\hline
v_{2}+C & v_{2}+0 & v_2+C_2 & \ldots
& v_{2}+C_{q^k} \\
\hline
\end{array}\right\} \omega(v_{i}) > t$
\qquad$\left.
\begin{array}{|*{5}{c|}}
\hline
v_{2}+C & v_{2}+0 & \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (dug)
{$v_{2}+C_{2}$};}
& \ldots
& v_{2}+C_{q^k} \\
\hline
v_{2}+C & v_{2}+0 & v_2+C_2 & \ldots
& v_{2}+C_{q^k} \\
\hline
v_{2}+C & v_{2}+0 & v_2+C_2 & \ldots
& v_{2}+C_{q^k} \\
\hline
\end{array}\right\} \omega(v_{i}) > t$
\vspace{2ex}
1 \tikz[na] \node[coordinate] (booh) {};
\begin{tikzpicture}[overlay]
\path[very thick,->] (t1) edge [bend right] (bug);
\path[very thick,->] (booh) edge [bend left] (bug);
\end{tikzpicture}
\end{frame}
\end{document}
结果几乎相同(我只选择了从左边框到表格的不同距离:
与您的代码的主要区别在于tabular
我使用array
。因此$
仅在数组的开头和结尾以及节点的内容中才需要 。
答案2
您需要告诉 Latex 在表格之间开始一个新段落,否则它会尝试通过添加空格来以某种方式排版您的代码。
\documentclass[ignorenonframetext,xcolor={table,svgnames}]{beamer}
\usepackage{tikz}
\usepackage{amssymb,amsmath}
\usetikzlibrary{shapes,backgrounds,fit,positioning}
\usetikzlibrary{decorations.pathreplacing,angles,quotes}
\usetikzlibrary{calc}
\tikzset{every picture/.style={remember picture}}
\begin{document}
\begin{frame}[b]
\tikzset{na/.style={baseline=-.5ex}}
\begin{table}
$\kern-\nulldelimiterspace\left.
\begin{tabular}{|c|c|c|c|c|}
\hline
$C$ & $C_{1}$ & $C_{2}$ & \ldots & $C_{q^k}$
\tikz[na] \node[coordinate] (t1) {gi};\\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{3}+C$ & $v_{3}+0$ & $ \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (bug)
{$v_{3}+C_{2}$};
} $ & \ldots & $v_{3}+C_{q^k}$ \\
\hline
$\ldots$ & $\ldots$ & $\ldots$ & \ldots & $\ldots$ \\
\hline
\end{tabular}\right\}$ $\omega(v_{i})\leq t$
$\kern-\nulldelimiterspace\left.
\begin{tabular}{|c|c|c|c|c|}
\hline
$v_{2}+C$ & $v_{2}+0 $ & $ \tikz[baseline]{
\node[rounded corners,fill=red!15,anchor=base] (dug){$v_{2}+C_{2}$};} $ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
$v_{2}+C$ & $v_{2}+0$ & $v_{2}+C_{2}$ & \ldots & $v_{2}+C_{q^k}$ \\
\hline
\end{tabular}\right\}$ $\omega(v_{i}) > t$
\end{table}
1 \tikz[na] \node[coordinate] (booh) {};
\begin{tikzpicture}[overlay]
\path[very thick,->] (t1) edge [bend right] (bug);
\path[very thick,->] (booh) edge [bend left] (bug);
\end{tikzpicture}
\end{frame}
\end{document}