答案1
使用
tabular
环境以网格方式排列图像和文本并添加分隔线。使用该
booktabs
包可以获得更好的表格布局和更漂亮的线条。使用该
rotating
包来获取sideways
将其内容逆时针旋转 90 度的环境。使用
array
包来节省输入:它允许您使用符号>{...}
并<{...}
在列的每个单元格中添加材料。在表格条目中,您可以使用进一步的表格。
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{array}
\newcommand\pic[2][1cm]{\includegraphics[height=#1]{example-image-#2}}
\begin{document}
\begin{tabular}{>{\begin{sideways}}l<{\end{sideways}}l}
\toprule
image A
& \pic[2cm]{a}
\\\midrule
5 images B
& \pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}\pic[2cm]{b}
\\\midrule
\begin{minipage}{3cm}
Many more images C arranged as a grid,
and a longer text.
\end{minipage}
& \begin{tabular}[b]{@{}ccccc@{}}
\pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c} \\
\pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c} \\
\pic{c} & \pic{c} & \pic{c} & \pic{c} & \pic{c}
\end{tabular}
\\\bottomrule
\end{tabular}
\end{document}
编辑:这是另一个示例,它考虑了原始帖子编辑中指定的进一步要求。
为了让表格占据整个空间
\textwidth
而不必自己计算可用空间,我们使用tabularx
带有X
列的环境。此外,为了使单元格的内容垂直居中,我们重新定义了X
列类型。\usepackage{tabularx} \renewcommand\tabularxcolumn[1]{m{#1}} ... \begin{tabularx}{\textwidth}{m{2ex}}X}
我们希望第一列旋转并显示为红色,因此我们将其替换
m{2ex}
为>{\begin{sideways}\color{red}}m{2ex}<{\end{sideways}}
在每个单元格的开始和结束处插入必要的命令。
第二列的元素本身应该是结构化项目,由一个带有两个值的标题和一个图像组成。所以我们定义一个命令
\captpic{A-value}{B-value}{name of image}
如下(根据需要修改)。
\newcommand\pic[1]{\includegraphics[width=1cm]{#1}} \newcommand\captpic[3]% {\begin{tabular}[t]{@{}c@{}} \footnotesize\color{blue} A: #1\\[-1ex] \footnotesize\color{blue} B: #2\\ \pic{#3} \end{tabular}% }
\documentclass{article}
\usepackage{graphicx}
\usepackage{booktabs}
\usepackage{rotating}
\usepackage{tabularx}
\renewcommand\tabularxcolumn[1]{m{#1}}
\usepackage{xcolor}
\newcommand\pic[1]{\includegraphics[width=1cm]{#1}}
\newcommand\captpic[3]%
{\begin{tabular}[t]{@{}c@{}}
\footnotesize\color{blue} A: #1\\[-1ex]
\footnotesize\color{blue} B: #2\\
\pic{#3}
\end{tabular}%
}
\begin{document}
\noindent
\begin{tabularx}{\textwidth}%
{>{\begin{sideways}\color{red}}m{2ex}<{\end{sideways}}%
X%
}
\toprule
sample
& \pic{example-image-a}
\\\midrule
selection 1
& \captpic{1}{0.00}{example-image-b}
\captpic{2}{0.01}{example-image-b}
\captpic{3}{0.02}{example-image-b}
\captpic{4}{0.03}{example-image-b}
\captpic{5}{0.04}{example-image-b}
\captpic{6}{0.05}{example-image-b}
\captpic{7}{0.06}{example-image-b}
\captpic{8}{0.07}{example-image-b}
\captpic{9}{0.08}{example-image-b}
\captpic{10}{0.09}{example-image-b}
\\\midrule
selection 2
& \captpic{1}{0.00}{example-image-b}
\captpic{2}{0.01}{example-image-b}
\captpic{3}{0.02}{example-image-b}
\captpic{4}{0.03}{example-image-b}
\captpic{5}{0.04}{example-image-b}
\captpic{6}{0.05}{example-image-b}
\captpic{7}{0.06}{example-image-b}
\captpic{8}{0.07}{example-image-b}
\captpic{9}{0.08}{example-image-b}
\captpic{10}{0.09}{example-image-b}
\captpic{11}{0.10}{example-image-b}
\captpic{12}{0.11}{example-image-b}
\captpic{13}{0.12}{example-image-b}
\captpic{14}{0.13}{example-image-b}
\\\bottomrule
\end{tabularx}
\end{document}