¿Cómo puedo alinear correctamente dos minipáginas debajo de una mesa?

¿Cómo puedo alinear correctamente dos minipáginas debajo de una mesa?

Tengo una mesa y quiero poner dos leyendas debajo. Estas son minipáginas (no encontré otra forma de hacerlo), pero me cuesta alinearlas en el centro de la página y a la misma altura. vspace y hspace no mueven la minipágina en cuestión hacia arriba o hacia abajo (o hacia la izquierda o hacia la derecha), pero hacen que las cosas salten por la página de manera impredecible. ¿Cómo puedo alinearlos correctamente?

\documentclass{article}
\usepackage[table]{xcolor}
\def\hbar#1#2{%%
   {\color{#2}\rule{4mm}{#1mm}}}
\def\legbox#1#2{%%
   {\color{#1}\rule{4mm}{4mm}} \hspace{0.4mm}#2 \hspace{3mm}\\}

\begin{document}

\begin{figure}[h!]
  \vspace*{-4.0cm}
  \hspace*{-4.2cm}
  \centering
  {\setlength{\extrarowheight}{50pt}%
  \begin{tabular}{lllccl}
  \arrayrulecolor{gray}\hline
  \hline
    Item Description Name & Most Recent Update & State District & Governmental Body & Bars & More bars \\
    \hline
      Item 1 & Jan 1, 2010 & District 1 & GB 3 &
      \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
      \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
      \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}    \\   
      Item 2 & Jan 1, 2010 & District 1 & GB 3 &
      \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
      \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
      \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}      \\ 
      Item 3 & Jan 1, 2010 & District 1 & GB 3 &
      \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
      \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
      \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
      Item 4 & Jan 1, 2010 & District 1 & GB 3 &
      \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
      \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
      \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
      Item 5 & Jan 1, 2010 & District 1 & GB 3 &
      \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
      \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
      \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
  \end{tabular}
  }
  \caption{Here goes a table caption to describe the table}
\hspace{-10cm}
\begin{minipage}[t]{5cm}
\vspace{1cm}
 \textbf{Legend 1} \\
\legbox{black}{Long Label 1}
\legbox{blue}{Label 2}
\legbox{black}{Long Label 3}
\legbox{blue}{Label 4}
\legbox{black}{Long Label 5}
\legbox{blue}{Label 6}
\legbox{black}{Long Label 7}
\end{minipage}

\begin{minipage}{6cm}
\hspace{8cm}
\vspace{-4.7cm}
\\\textbf{Legend 2} \\

\legbox{blue}{Another label}
\legbox{black}{Mini}
\legbox{green}{A pretty long label}
\legbox{green}{A label}
\end{minipage}

\end{figure}
\end{document}

Así es como se ve:

Diseño actual

Y así es como me gustaría que se viera (línea solo con fines ilustrativos):

Diseño preferido

Respuesta1

Quizás esto es lo que estás esperando:

\documentclass{article}
\usepackage[table]{xcolor}
\def\hbar#1#2{%%
   {\color{#2}\rule{4mm}{#1mm}}}
\def\legbox#1#2{%%
   {\color{#1}\rule{4mm}{4mm}} \hspace{0.4mm}#2 \hspace{3mm}\\}

\begin{document}

\begin{figure}[h!]
  \centering
  \makebox[0pt]
  {%%
    \setlength{\extrarowheight}{50pt}%
    \begin{tabular}{lllccl}
    \arrayrulecolor{gray}\hline
    \hline
      Item Description Name & Most Recent Update & State District & Governmental Body & Bars & More bars \\
      \hline
        Item 1 & Jan 1, 2010 & District 1 & GB 3 &
        \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
        \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
        \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}    \\   
        Item 2 & Jan 1, 2010 & District 1 & GB 3 &
        \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
        \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
        \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}      \\ 
        Item 3 & Jan 1, 2010 & District 1 & GB 3 &
        \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
        \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
        \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
        Item 4 & Jan 1, 2010 & District 1 & GB 3 &
        \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
        \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
        \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
        Item 5 & Jan 1, 2010 & District 1 & GB 3 &
        \hbar{14}{green} \hbar{20}{green} \hbar{10}{green} \hbar{15}{red}
        \hbar{19}{red} \hbar{6}{red} \hbar{10}{red}  &
        \hbar{15}{red} \hbar{19}{red} \hbar{6}{red}       \\
    \end{tabular}
  }
  \caption{Here goes a table caption to describe the table}
  \vspace{2ex}\par
  \begin{minipage}[t]{5cm}
    {\centering\textbf{Legend 1}}%%

    \legbox{black}{Long Label 1}
    \legbox{blue}{Label 2}
    \legbox{black}{Long Label 3}
    \legbox{blue}{Label 4}
    \legbox{black}{Long Label 5}
    \legbox{blue}{Label 6}
    \legbox{black}{Long Label 7}
  \end{minipage}%%
  \hspace{\fill}
  \begin{minipage}[t]{6cm}
    {\centering\textbf{Legend 2}}%%

    \legbox{blue}{Another label}
    \legbox{black}{Mini}
    \legbox{green}{A pretty long label}
    \legbox{green}{A label}
  \end{minipage}%%
\end{figure}
\end{document}

ingrese la descripción de la imagen aquí

Puedo eliminar la mayoría de tus comandos \hspacey \vspace.

Su tabla es más grande de lo que permite la geometría de la página. Puedes centrarlo en la página poniendo su cuerpo en un \makeboxancho 0pt. Básicamente, reemplazo tu código:

\begin{figure}[h!]
  \vspace*{-4.0cm}
  \hspace*{-4.2cm}
  \centering
  {\setlength{\extrarowheight}{50pt}%

con el siguiente código:

\begin{figure}[h!]
  \centering
  \makebox[0pt]
  {%%
    \setlength{\extrarowheight}{50pt}%

También estás usando \hspacey \vspacemucho con tus leyendas de una manera que parece innecesaria. Aquí hay algunos ajustes que hice:

  • Después \captionagregué un espacio vertical para controlar mejor el espacio entre el título y las leyendas en lugar de agregar el espacio vertical dentro de los minipages.
  • Dentro de la minipages de la leyenda, no estoy seguro de qué estás tratando de lograr con tus comandos \hspacey . \vspaceParece que puedes evitarlos por completo haciendo un salto de párrafo entre el título de la leyenda y el cuerpo y centrando el título.

Respuesta2

La tabla, tal como está, no puede caber en ningún ancho de página razonable, así que la he reducido.

Para la leyenda, solo usa un par de tabular.

También cambié tu \defa \newcommandy \hbara \HBarno entrar en conflicto con un comando ya existente. SermuyCuidado con \def.

\documentclass{article}
\usepackage{booktabs,makecell}
\usepackage[table]{xcolor}

\newcommand\HBar[2]{%%
   {\color{#2}\rule{3mm}{#1mm}}%
}
\newcommand\legbox[2]{%%
   {\color{#1}\rule{4mm}{4mm}}\hspace{0.4mm}#2\hspace{3mm}%
}

\begin{document}

\begin{figure}[htp]
\centering
\begingroup\small
\addtolength{\tabcolsep}{-2.8pt}
\begin{tabular}{@{}lllccc@{}}
\toprule
\makecell{Item \\ Description \\ Name} &
  \makecell{Most Recent \\ Update} &
  \makecell{State \\ District} &
  \makecell{Governmental \\ Body} &
  Bars &
  More bars \\
\midrule
\addlinespace
Item 1 & Jan 1, 2010 & District 1 & GB 3 &
\HBar{14}{green} \HBar{20}{green} \HBar{10}{green} \HBar{15}{red}
\HBar{19}{red} \HBar{6}{red} \HBar{10}{red}  &
\HBar{15}{red} \HBar{19}{red} \HBar{6}{red}    \\
\addlinespace
Item 2 & Jan 1, 2010 & District 1 & GB 3 &
\HBar{14}{green} \HBar{20}{green} \HBar{10}{green} \HBar{15}{red}
\HBar{19}{red} \HBar{6}{red} \HBar{10}{red}  &
\HBar{15}{red} \HBar{19}{red} \HBar{6}{red}      \\ 
\addlinespace
Item 3 & Jan 1, 2010 & District 1 & GB 3 &
\HBar{14}{green} \HBar{20}{green} \HBar{10}{green} \HBar{15}{red}
\HBar{19}{red} \HBar{6}{red} \HBar{10}{red}  &
\HBar{15}{red} \HBar{19}{red} \HBar{6}{red}       \\
\addlinespace
Item 4 & Jan 1, 2010 & District 1 & GB 3 &
\HBar{14}{green} \HBar{20}{green} \HBar{10}{green} \HBar{15}{red}
\HBar{19}{red} \HBar{6}{red} \HBar{10}{red}  &
\HBar{15}{red} \HBar{19}{red} \HBar{6}{red}       \\
\addlinespace
Item 5 & Jan 1, 2010 & District 1 & GB 3 &
\HBar{14}{green} \HBar{20}{green} \HBar{10}{green} \HBar{15}{red}
\HBar{19}{red} \HBar{6}{red} \HBar{10}{red}  &
\HBar{15}{red} \HBar{19}{red} \HBar{6}{red}       \\
\bottomrule
\end{tabular}
\endgroup

\caption{Here goes a table caption to describe the table}

\bigskip

\begin{tabular}[t]{@{}l@{}}
\multicolumn{1}{c}{\textbf{Legend 1}} \\
\legbox{black}{Long Label 1} \\
\legbox{blue}{Label 2} \\
\legbox{black}{Long Label 3} \\
\legbox{blue}{Label 4} \\
\legbox{black}{Long Label 5} \\
\legbox{blue}{Label 6} \\
\legbox{black}{Long Label 7} \\
\end{tabular}%
\hspace{1cm}
\begin{tabular}[t]{@{}l@{}}
\multicolumn{1}{c}{\textbf{Legend 2}} \\
\legbox{blue}{Another label} \\
\legbox{black}{Mini} \\
\legbox{green}{A pretty long label} \\
\legbox{green}{A label} \\
\end{tabular}

\end{figure}
\end{document}

ingrese la descripción de la imagen aquí

información relacionada