将多张图片与其标题和描述对齐

将多张图片与其标题和描述对齐

我正在使用 rmarkdown 制作这种报告。我使用 framebox 来显示图片的大小不相同。我尝试对齐 11 张图片(每行 6 张图片,2 行),大小不同,在顶部添加标题,在每张图片下方添加段落。标题介于 1 行和 2 行之间。图片

在此处输入图片描述

\setmainfont{Roboto}
\newfontfamily\Ofont{Oswald}
\newfontfamily\ORfont{Oswald Regular}
\newfontfamily\RMfont{Roboto Medium}
\newfontfamily\RLfont{Roboto Light}
\renewcommand{\baselinestretch}{1}
\setlength{\columnsep}{0.2cm}
 \begin{multicols}{6}
\begin{center}
\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Agriculture}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Agriculture}}\\ 
\vspace{10mm}\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Transport}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Transport}}\\ 
\vspace{10mm}\columnbreak
\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Education}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Education}}\\ 
\vspace{10mm}\textbf{\ORfont{\fontsize{11}{48} \selectfont Water, Sanitation \&\\Urban Services}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Water, Sanitation & Urban Services}}\\ 
\vspace{10mm}\columnbreak
\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Energy}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Energy}}\\ 
\vspace{10mm}\textbf{\ORfont{\fontsize{11}{48} \selectfont Industry \&\\Mining}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Industry & Mining}}\\ 
\vspace{10mm}\columnbreak
\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Finance}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Finance}}\\ 
\vspace{10mm}\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Real Estate}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Real Estate}}\\ 
\vspace{10mm}\columnbreak
\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Health}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Health}}\\ 
\vspace{10mm}\textbf{\ORfont{\fontsize{11}{48} \selectfont  \\Others}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Others}}\\ 
\vspace{10mm}\columnbreak
\textbf{\ORfont{\fontsize{11}{48} \selectfont Information \&\\Communications}}\\ 
\vspace{1cm}\framebox{\includegraphics[height=0.25\textheight]{Information & Communications}}\\ 
\vspace{10mm}\columnbreak
\end{center}
\end{multicols}

答案1

对齐所有图片的最简单方法可能是将它们放在表格中,例如使用环境tabular。我在这里做了一个小例子,里面有空白图片。为了使文本在每个单元格中垂直和水平居中,我C根据包m中的列类型定义了一种新的列类型array。另请注意,即使图片的大小不同,您可能也不需要使用任何类型framebox,因为您可以在可选参数中直接指定大小includegraphics

\documentclass[11pt]{article}
\usepackage{array}
\usepackage[demo]{graphicx}
\usepackage[margin=2cm]{geometry}
\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}
\newlength{\colwidth}
\setlength{\colwidth}{2.8cm}

\begin{document}

\begin{table}
\centering
\begin{tabular}{C{\colwidth}C{\colwidth}C{\colwidth}C{\colwidth}C{\colwidth}C{\colwidth}}
    Agriculture & Finance & Information \& communications & Title 4 & Title 5 & Title 6 \\
        \includegraphics[width=0.8\linewidth]{a} &
        \includegraphics[width=0.8\linewidth]{b} &
        \includegraphics[width=0.8\linewidth]{c} &
        \includegraphics[width=0.8\linewidth]{d} &
        \includegraphics[width=0.8\linewidth]{e} &
        \includegraphics[width=0.8\linewidth]{f} \\
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects \\
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m \\[4mm]
    Ttile 7 & Title 8 & Title 9 & Title 10 & Title 11 & Title 12 \\
        \includegraphics[width=0.8\linewidth]{g} &
        \includegraphics[width=0.8\linewidth]{h} &
        \includegraphics[width=0.8\linewidth]{i} &
        \includegraphics[width=0.8\linewidth]{j} &
        \includegraphics[width=0.8\linewidth]{k} &
        \includegraphics[width=0.8\linewidth]{l} \\
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects & 
        11 projects \\
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m & 
        \$US 11.0m \\
\end{tabular}
\end{table}

\end{document}

相关内容