我正在尝试调整 egreg 在此处给出的答案:
我想要一个表,其中一列是直方图,下一列是相应的描述统计子表。
我已将大部分内容放置到位,但直方图和描述统计表未对齐。直方图出现在其单元格的顶部,而描述统计表出现在其单元格的底部。
如何对齐直方图和子表的图像?
像图片一样,我想在描述统计表下方添加一个标题。(这也应该与图片下方的标题对齐)。
谢谢巴兹
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx}
\newcommand{\subf}[2]{%
{\small\begin{tabular}[t]{@{}c@{}}
#1\\#2
\end{tabular}}%
}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{|c|c|}
\hline
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
{``iteraciones máximas \\ de BT''$=20$}
&
\begin{tabular}{p{2cm}|p{1cm}}
\hline
Statistic & Value \\\hline
Max & 2 \\
min & 3 \\
Mean & 2 \\
Std & 3\\
Skew & 2 \\
Kurtosis & 3 \\
Percent Positive & 100\\\hline
\end{tabular}\\\\
\hline
\subf{\includegraphics[width=60mm]{example-image-4x3.pdf}}
{``iteraciones máximas \\ de BT''$=20$}
&
\begin{tabular}{p{2cm}|p{1cm}}
\hline
Statistic & Value \\\hline
Max & 2 \\
min & 3 \\
Mean & 2 \\
Std & 3\\
Skew & 2 \\
Kurtosis & 3 \\
Percent Positive & 100\\\hline
\end{tabular}\\\\\hline
\end{tabular}
\end{figure}
\end{document}
答案1
人们需要根据基线对图像的垂直位置进行一些调整;这adjustbox
使得它变得相当容易:
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage[export]{adjustbox}
\usepackage{graphicx}
\newcommand{\subf}[2]{%
{\small\begin{tabular}[t]{@{}c@{}}
#1\\#2
\end{tabular}}%
}
\begin{document}
\begin{figure}
\centering
\begin{tabular}{|c|c|}
\hline
\subf{\includegraphics[valign=T,width=60mm]{example-image-4x3.pdf}}
{``iteraciones máximas \\ de BT''$=20$}
&
\begin{tabular}[t]{l|l}
\hline
Statistic & Value \\\hline
Max & 2 \\
min & 3 \\
Mean & 2 \\
Std & 3\\
Skew & 2 \\
Kurtosis & 3 \\
Percent Positive & 100\\\hline
\end{tabular}\\
\hline
\subf{\includegraphics[valign=T,width=60mm]{example-image-4x3.pdf}}
{``iteraciones máximas \\ de BT''$=20$}
&
\begin{tabular}[t]{l|l}
\hline
Statistic & Value \\\hline
Max & 2 \\
min & 3 \\
Mean & 2 \\
Std & 3\\
Skew & 2 \\
Kurtosis & 3 \\
Percent Positive & 100\\\hline
\end{tabular}\\\hline
\end{tabular}
\end{figure}
\end{document}
我不确定你是否想要任何垂直规则。
答案2
您还可以尝试\adjustbox{valign=T}{...}
从adjustbox
库或其环境表单中将\begin{adjustbox}{valign=T}...\end{adjustbox}
图形和表格对齐在顶部。
\documentclass[12pt,a4paper]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[spanish]{babel}
\usepackage{graphicx,adjustbox,array}
\newcommand{\Mtable}{%
\begin{tabular}[t]{p{2cm}|p{1cm}}
\hline
Statistic & Value \\\hline
Max & 2 \\
min & 3 \\
Mean & 2 \\
Std & 3\\
Skew & 2 \\
Kurtosis & 3 \\
Percent Positive & 100\\ \hline
\multicolumn{2}{c}{``Descriptive Statistics}\\
\multicolumn{2}{c}{for Simulated Set 3"} \\[-1ex]
\multicolumn{2}{c}{}
\end{tabular}
}
\begin{document}
\begin{tabular}{|c|c|}\hline
\adjustbox{valign=T}{\centering
\begin{tabular}{c}
\includegraphics[width=60mm]{example-image-4x3.pdf}\\
``Histogram of Steepener Results\\ for Simulated Set 3"
\end{tabular}}
&
\adjustbox{valign=T}{\Mtable}
\\ \hline
\adjustbox{valign=T}{\centering
\begin{tabular}{c}
\includegraphics[width=60mm]{example-image-4x3.pdf}\\
``Histogram of Steepener Results\\ for Simulated Set 3"
\end{tabular}}
&
\adjustbox{valign=T}{\Mtable}\\ \hline
\end{tabular}
\end{document}
或者,无需adjustbox
,您可以使用库\raisebox
中的graphicx
。这个想法是,图像自然地放置在基线上方,而表格自然地放置在基线下方。因此,我们只需将图像提升为其高度的负数;这将使图像和表格从基线开始并向下增长。
以下是\raisebox
版本:
\begin{tabular}{|c|c|}\hline
\begin{tabular}[t]{c}
\raisebox{-\height}{\includegraphics[width=60mm]{example-image-4x3.pdf}}\\
``Histogram of Steepener Results\\ for Simulated Set 3"
\end{tabular}
&
\Mtable
\\ \hline
\begin{tabular}[t]{c}
\raisebox{-\height}{\includegraphics[width=60mm]{example-image-4x3.pdf}}\\
``Histogram of Steepener Results\\ for Simulated Set 3"
\end{tabular}
&
\Mtable
\\ \hline
\end{tabular}