Could anyone help fixing the error and shift the table's legend up a bit?
Can you make the table legend with TikZ instead of \legend
?
\documentclass[]{standalone}
\usepackage{tikz}
\usetikzlibrary{automata,shapes.geometric}
\usepackage{array}
\begin{document}
\begin{figure}[h]
\begin{tabular}{*{2}{>{\centering\arraybackslash}b{\dimexpr0.5\textwidth-2\tabcolsep\relax}}}
\legend{Weighted, complete graph $K_H$}
\begin{tikzpicture}[
state/.append style={minimum size=5mm}]
%\begin{pgfonlayer}{nodelayer}
\node [state] (0) at (-2, 3) [label=left:E] {};
\node [state] (1) at ( 2, 3) [label=right:B]{};
\node [state] (2) at (-1.25, 0.75)[label=left:D] {};
\node [state] (3) at ( 1.25, 0.75) [label=right:C]{};
\node [state] (4) at ( 0, 4.5) [label=above: A]{};
%\end{pgfonlayer}
%\begin{pgfonlayer}{edgelayer}
\draw (0) to (4);
\draw (4) to (1);
\draw (1) to (3);
\draw (0) to (2);
\draw (3) to (2);
\draw (2) to (4);
\draw (4) to (3);
\draw (0) to (1);
\draw (0) to (3);
\draw (2) to (1);
%\end{pgfonlayer}
\end{tikzpicture}
&
\renewcommand{\arraystretch}{1.3}
\legend{\textbf{THIS IS TABLE LEGEND}}
\begin{tabular}{c|ccccc}
& A & B & C & D & E \\
\hline
A & -- & 4 & 7 & 6 & 12 \\
B & 4 & -- & 3 & 5 & 8 \\
C & 7 & 3 & -- & 2 & 5 \\
D & 6 & 5 & 2 & -- & 9 \\
E & 12 & 8 & 5 & 9 & --
\end{tabular}
\end{tabular}
\end{figure}
\end{document}
standalone
is not intended to contain floats. If you persist to contain it, than you need to add optionvarwidth
:\documentclass[varwidth]{standalone}
. Where you define `\legend˛command? Does it should be caption?