答案1
第一个图形可以用 Ti 绘制钾\multirow
Z.第二张图是同时使用(来自multirow
包)和 的表格\multicolumn
。
如果您希望将图形标题放在页面左侧,请使用\usepackage[singlelinecheck=off]{caption}
:
\documentclass{article}
\usepackage{tikz}
\usepackage{multirow}
\usepackage[singlelinecheck=off]{caption}
\renewcommand{\arraystretch}{1.2}
\begin{document}
\begin{figure}
\centering
\caption{My diagram}
\begin{tikzpicture}[every node/.style={draw,minimum width=1cm,anchor=south west}]
\node at (2,4) (goal) {Goal};
\foreach \x in {1,...,3}
\node at (\x,0) (a\x) {$A_{\x}$};
\foreach \x [evaluate=\x as \c using int(\x+1)] in {0,...,4}{
\node at (\x,2) (c\c) {$C_{\c}$};
\draw (goal.south) -- (c\c.north);
\foreach \xx in {1,...,3}
\draw (c\c.south) -- (a\xx.north);
}
\end{tikzpicture}
\end{figure}
\begin{figure}
\centering
\caption{My table}
\begin{tabular}{|*{5}{c|}}
\hline
\multicolumn{1}{|c}{Criteria} & \multicolumn{1}{c}{Candidates} & \multicolumn{3}{c|}{Decision-makers} \\\hline
\multicolumn{1}{|c}{$C$} & \multicolumn{1}{c}{$A$} & \multicolumn{1}{c}{$D_1$} & \multicolumn{1}{c}{$D_2$} & \multicolumn{1}{c|}{$D_3$} \\\hline
\multirow{3}{*}{$C_1$} & $A_1$ & $MG$ & $G$ & $MG$ \\
& $A_2$ & $G$ & $G$ & $MG$ \\
& $A_3$ & $VG$ & $G$ & $F$ \\\hline
\multirow{3}{*}{$C_2$} & $A_1$ & $G$ & $MG$ & $F$ \\
& $A_2$ & $VG$ & $VG$ & $VG$ \\
& $A_3$ & $MG$ & $G$ & $VG$ \\\hline
\multirow{3}{*}{$C_3$} & $A_1$ & $F$ & $G$ & $G$ \\
& $A_2$ & $VG$ & $VG$ & $G$ \\
& $A_3$ & $G$ & $MG$ & $VG$ \\\hline
\multirow{3}{*}{$C_4$} & $A_1$ & $VG$ & $G$ & $VG$ \\
& $A_2$ & $VG$ & $VG$ & $VG$ \\
& $A_3$ & $G$ & $VG$ & $MG$ \\\hline
\multirow{3}{*}{$C_5$} & $A_1$ & $F$ & $F$ & $F$ \\
& $A_2$ & $VG$ & $MG$ & $G$ \\
& $A_3$ & $G$ & $G$ & $MG$ \\\hline
\end{tabular}
\end{figure}
\end{document}
答案2
第一个图tikz
代码
\documentclass[margin=5mm]{standalone}
\usepackage{tikz}
\begin{document}
\tikzset{every node/.style={draw,minimum width=1cm}}
\begin{tikzpicture}
\node (c-1) {$C_1$};
\node[anchor=south west] (c-2) at (c-1.south east) {$C_2$};
\node[anchor=south west] (c-3) at (c-2.south east) {$C_3$};
\node[anchor=south west] (c-4) at (c-3.south east) {$C_4$};
\node[anchor=south west] (c-5) at (c-4.south east) {$C_5$};
\node [above=1cm,minimum width=1.5cm,minimum height=7mm] (g) at (c-3.north){Goal};
\node [below=1cm,minimum width=1.5cm] (a-2) at (c-3.south){$A_2$};
\node [anchor=south east,minimum width=1.5cm] (a-1) at (a-2.south west){$A_1$};
\node [anchor=south west,minimum width=1.5cm] (a-3) at (a-2.south east){$A_1$};
\foreach \i in{1,2,3,4,5}
{\draw (g.south)--(c-\i.north);}
\foreach \i in {1,2,3,4,5}
{\foreach \j in {1,2,3}
{\draw (c-\i.south)--(a-\j.north);}}
\end{tikzpicture}
\end{document}
您还可以使用positioning
库来放置节点。
输出