將多張圖片與其標題和描述對齊

將多張圖片與其標題和描述對齊

我正在使用 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}

相關內容