
我有下表。
我知道如何製作表格,表格的每個方格內只有一個數字/字元。我也知道如何在表格外寫字符,感謝來自的答案如何在表格外寫入字元?但我不知道如何在一個正方形中添加這樣的箭頭和 3 個不同的數字。
有人可以告訴我該怎麼做嗎?
提前致謝。
【圖片中還有粉紅色的小方塊,不過這沒什麼大不了的。我可以用不同的顏色來表示它們(粉紅色方塊並不那麼重要)]
答案1
這是使用 tikz 完成的部分答案:
\documentclass{article}
\usepackage{tikz}
\usepackage{xcolor}
\begin{document}
\begin{center}
\begin{tikzpicture}
\foreach \x in {0,2,...,10} \draw[thick] (\x,0)--(\x,6);
\foreach \x in {0,2,...,6} \draw[thick] (0,\x)--(10,\x);
\node at (1.5,1.5) {$3$};
\draw[thick,red] (4,5)--(3,5)--(3,4);
\draw[thick,->] (8.25,2.5)--(7.75,2.5);
\node[above] at (1,6) {$V_1=3$};
\node at (3.5,4.5) {\color{red}{$-2$}};
\node at (8.5,2.5) {$\theta$};
\node[left] at (0,5) {$x_1=0$};
\end{tikzpicture}
\end{center}
\end{document}
如果我編譯它,我會得到這個:
答案2
您的表格的簡短摘錄:
\documentclass{article}
\usepackage[table]{xcolor}
%%%%% modified tikzmark command from here: https://tex.stackexchange.com/a/182693/134144
\usepackage{tikz}
\usetikzlibrary{matrix}
\newcommand{\tikzmark}[2]{\tikz[overlay, remember picture] \node[inner sep=0pt, outer sep=0pt, anchor=center] (#1) {#2};}
%%%%%%%%%%
\begin{document}
\begin{tabular}{l|ccc|ccc|}
\multicolumn{1}{c}{} & \multicolumn{3}{c}{$V_1=3$} & \multicolumn{3}{c}{$V_2 = 0$}\\
\cline{2-7}
& & & a & & & b \\
$U_1 = 0$ & & \tikzmark{b}{y} & & & \tikzmark{a}{x} & \\
\arrayrulecolor{red}\cline{7-7}\arrayrulecolor{black}
& c & & & & \multicolumn{1}{c!{\color{red}\vrule}}{} & d\\
\cline{2-7}
\end{tabular}
\tikz[overlay,remember picture] {
\draw[shorten >=5pt,shorten <=5pt,->] (a) -- (b);
}
\end{document}