
테이블이 있고 그 아래에 두 개의 범례를 넣고 싶습니다. 이것은 미니페이지이지만(이 작업을 수행하는 다른 방법은 찾지 못했습니다) 페이지 중앙과 같은 높이에 정렬하는 데 어려움을 겪고 있습니다. vspace 및 hspace는 문제의 미니페이지를 위나 아래(또는 왼쪽이나 오른쪽)로 이동하지 않지만 예측할 수 없게 페이지 주위를 맴돌게 만듭니다. 어떻게 하면 올바르게 정렬할 수 있나요?
\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}
그 모습은 다음과 같습니다.
그리고 여기에 내가 원하는 모습이 나와 있습니다(설명 목적으로만 줄 표시).
답변1
아마도 이것이 당신이 바라는 것입니다:
\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}
나는 대부분의 \hspace
및 \vspace
명령을 제거할 수 있습니다.
테이블이 페이지의 기하학적 구조가 허용하는 것보다 큽니다. 본문을 \makebox
너비 에 맞춰 페이지 중앙에 배치할 수 있습니다 0pt
. 기본적으로 코드를 교체합니다.
\begin{figure}[h!]
\vspace*{-4.0cm}
\hspace*{-4.2cm}
\centering
{\setlength{\extrarowheight}{50pt}%
다음 코드를 사용하세요.
\begin{figure}[h!]
\centering
\makebox[0pt]
{%%
\setlength{\extrarowheight}{50pt}%
당신은 또한 불필요해 보이는 방식으로 당신의 전설을 많이 \hspace
사용 하고 있습니다. \vspace
제가 조정한 사항은 다음과 같습니다.
\caption
캡션과 범례 사이의 공간을 더 잘 제어하기 위해 s 내에 수직 공간을 추가하는 대신 수직 공간을 추가한 후입니다minipage
.- 범례에 대한 s 내에서 및 명령을
minipage
사용하여 무엇을 달성하려는지 약간 불확실합니다 . 범례 제목과 본문 사이에 단락 구분을 만들고 제목을 중앙에 배치하면 이러한 문제를 완전히 피할 수 있는 것 같습니다.\hspace
\vspace
답변2
테이블은 있는 그대로의 페이지 너비에 맞지 않아 축소했습니다.
범례의 경우 몇 개의 tabular
.
또한 이미 존재하는 명령과 충돌하지 않도록 를 으로 변경 \def
했습니다 . BE\newcommand
\hbar
\HBar
매우에 조심하세요 \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}