我一直在尝试创建一个包含几个不同图形以及一些矩阵的表格,但在尝试将矩阵置于表格的中心以及尝试修复我为立方体创建的标签时遇到了麻烦。我的代码如下:
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{graphicx}% Include figure files
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{bm}% bold math
\usepackage{comment}
\usepackage{setspace}
\usepackage{braket}
\usepackage{amsmath}
\usepackage{amsfonts}
\usepackage{amsthm}
\usepackage{calrsfs}
\usepackage{array}
\usepackage{float}
\usepackage{tikz}
\usetikzlibrary{backgrounds,calc,decorations.markings,hobby}
\usepackage{pstricks}
\usepackage{pst-optexp}
\usepackage{pst-node}
\usepackage{amssymb}
\usepackage[margin=1in]{geometry}
\addparagraphcolumntypes{X}
\usepackage{amsmath,mleftright}
\date{March 2021}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.2pt}
\doublespacing
\newtheorem{theorem}{Theorem}
\let\vec\mathbf
\begin{document}
\begin{table}
\begin{tabular}{|c|c|c|}
\hline
\multirow{Algebraic branching program} &
\multirow{Adjacency matrix} &
\multirow{Determinant of adjacency matrix}\\ \hline
\begin{tikzpicture}
\draw[fill,red] (6.05, 2.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (6.05, 1.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (6,2) -- (6,1)
node [midway,right] {$x_{11}$};
\end{tikzpicture} & \abovebaseline[-3pt]{\begin{pmatrix}
x_{11}\\
\end{pmatrix}} & $\text{det}(A)=x_{11}$ \\
\hline
\centering
\begin{tikzpicture}[decoration={
markings,
mark=at position 0.35 with {\arrow{>}}}]
\draw[fill,red] (1.55, 1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (1.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (1.5,1) -- (0.5,0)
node [midway,left] {$x_{11}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (2.5,0)
node [midway,right] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (1.5,-1)
node [midway,left] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (1.5,-1)
node [midway,right] {$x_{12}$};
\draw (0.5, 0.0) arc(0:360:0.2) -- cycle;
\draw (2.9, 0.0) arc(0:360:0.2) -- cycle;
\end{tikzpicture} &
\begin{pmatrix}
x_{11} & x_{12}\\
x_{21} & x_{22}\\
\end{pmatrix} & $\text{det}(A)=x_{11}x_{22}+x_{12}x_{21}$\\
\hline
\centering
\begin{tikzpicture}[decoration={
markings,
mark=at position 0.35 with {\arrow{>}}}
]
\draw[fill,red] (1.55, 1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (1.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (1.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (1.55, -2.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (1.5,1) -- (0.5,0)
node [midway,left] {$x_{11}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (1.5,0)
node [pos=0.65,right] {$x_{12}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (2.5,0)
node [pos=0.5,right] {$x_{13}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (0.5,-1)
node [midway,left] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (1.5,-1)
node [midway, right] {$x_{23}$};
\draw[thick,black,postaction={decorate}] (1.5,0) -- (0.5,-1)
node [pos=0.3,above] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (1.5,0) -- (2.5,-1)
node [] {$x_{23}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (2.5,-1)
node [midway,right] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (1.5,-1)
node [pos=0.85,right] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (0.5,-1) -- (1.5,-2)
node [midway,left] {$x_{33}$};
\draw[thick,black,postaction={decorate}] (1.5,-1) -- (1.5,-2)
node [pos=0.2,left] {$x_{32}$};
\draw[thick,black,postaction={decorate}] (2.5,-1) -- (1.5,-2)
node [midway,right] {$x_{31}$};
\end{tikzpicture} & \begin{pmatrix}
1 & 2 & 3\\
1 & 2 & 3\\
1 & 2 & 3
\end{pmatrix} & $\text{det}(A)= x_{33}x_{22}x_{11}+...$ \\
\hline
\end{tabular}
\caption{Comparison of ABP for the case of n=1,2,3}
\end{table}
\end{document}
这将产生以下输出
但是,我想尝试使边缘标签在立方体上清晰可见,并且不跨越任何线,并且第 2 列和第 3 列位于中间。
答案1
您可以适当地设置 s 的基线tikzpicture
。为了方便起见,我添加了一个样式,vcenter tikz
,它引入了一个适当的节点并相应地设置基线。(现在代码稍微精简了一些,但可以进一步减少。此外,使用\det
而不是\text{det}
。)
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage{setspace}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{bm}% bold math
\usepackage{array}
\usepackage{tikz}
\usetikzlibrary{decorations.markings}
\usepackage[margin=1in]{geometry}
\usepackage{mleftright}
\title{598 Final report}
\author{owen.doty }
\date{March 2021}
\setlength{\columnsep}{1.5cm}
\setlength{\columnseprule}{0.2pt}
\doublespacing
\tikzset{vcenter tikz/.style={execute at end picture={%
\path (current bounding box.center) node (TMP) {\vphantom{T}};
},baseline={(TMP.base)}}}
\begin{document}
\begin{table}
\begin{tabular}{|c|c|c|}
\hline
Algebraic branching program &
Adjacency matrix &
Determinant of adjacency matrix\\ \hline
\begin{tikzpicture}[vcenter tikz]
\draw[fill,red] (6.05, 2.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (6.05, 1.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (6,2) -- (6,1)
node [midway,right] (x11) {$x_{11}$};
\end{tikzpicture} & $\begin{pmatrix}
x_{11}\\
\end{pmatrix}$ & $\det(A)=x_{11}$ \\
\hline
\centering
\begin{tikzpicture}[vcenter tikz,decoration={
markings,
mark=at position 0.35 with {\arrow{>}}}]
\draw[fill,red] (1.55, 1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (1.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (1.5,1) -- (0.5,0)
node [midway,left] {$x_{11}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (2.5,0)
node [midway,right] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (1.5,-1)
node [midway,left] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (1.5,-1)
node [midway,right] {$x_{12}$};
\draw (0.5, 0.0) arc(0:360:0.2) -- cycle;
\draw (2.9, 0.0) arc(0:360:0.2) -- cycle;
\end{tikzpicture} &
$\begin{pmatrix}
x_{11} & x_{12}\\
x_{21} & x_{22}\\
\end{pmatrix}$ & $\det(A)=x_{11}x_{22}+x_{12}x_{21}$\\
\hline
\begin{tikzpicture}[vcenter tikz,decoration={
markings,
mark=at position 0.35 with {\arrow{>}}}
]
\draw[fill,red] (1.55, 1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (1.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, 0.0) arc(0:360:0.05) -- cycle;
\draw[fill] (0.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (1.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill] (2.55, -1.0) arc(0:360:0.05) -- cycle;
\draw[fill,red] (1.55, -2.0) arc(0:360:0.05) -- cycle;
\draw[thick,black,postaction={decorate}] (1.5,1) -- (0.5,0)
node [midway,left] {$x_{11}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (1.5,0)
node [pos=0.65,right] {$x_{12}$};
\draw[thick,black,postaction={decorate}] (1.5,1) -- (2.5,0)
node [pos=0.5,right] {$x_{13}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (0.5,-1)
node [midway,left] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (0.5,0) -- (1.5,-1)
node [midway, right] {$x_{23}$};
\draw[thick,black,postaction={decorate}] (1.5,0) -- (0.5,-1)
node [pos=0.3,above] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (1.5,0) -- (2.5,-1)
node [] {$x_{23}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (2.5,-1)
node [midway,right] {$x_{22}$};
\draw[thick,black,postaction={decorate}] (2.5,0) -- (1.5,-1)
node [pos=0.85,right] {$x_{21}$};
\draw[thick,black,postaction={decorate}] (0.5,-1) -- (1.5,-2)
node [midway,left] {$x_{33}$};
\draw[thick,black,postaction={decorate}] (1.5,-1) -- (1.5,-2)
node [pos=0.2,left] {$x_{32}$};
\draw[thick,black,postaction={decorate}] (2.5,-1) -- (1.5,-2)
node [midway,right] {$x_{31}$};
\end{tikzpicture} & $\begin{pmatrix}
1 & 2 & 3\\
1 & 2 & 3\\
1 & 2 & 3
\end{pmatrix}$ & $\det(A)= x_{33}x_{22}x_{11}+\dots$ \\
\hline
\end{tabular}
\caption{Comparison of ABP for the case of $n=1,2,3$.}
\end{table}
\end{document}