我在 latex 文档中添加了 12 张不同大小的图片。但它们的位置有些随机,标题也不在正确的位置。我想将 4 行图片分成 3 列,并在下方添加标题。我该怎么做?以下是我尝试过的方法:
\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage[lofdepth,lotdepth]{subfig}
\begin{document}
\begin{figure}[h]
\centering
\subfloat[][22q11]{
\includegraphics[width=0.1\textwidth]{22q11.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Angelman]{
\includegraphics[width=0.1\textwidth]{angelman.jpg}
\label{fig:subfig2}}
\subfloat[]Apert]{
\includegraphics[width=0.1\textwidth]{apert.jpg}
\label{fig:subfig3}}
\qquad
\subfloat[][CDL]{
\includegraphics[width=0.1\textwidth]{CDL.jpg}
\label{fig:subfig4}}
\label{fig:globfig}
\subfloat[]Down]{
\includegraphics[width=0.1\textwidth]{down.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Marfan]{
\includegraphics[width=0.1\textwidth]{marfan.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Progeria]{
\includegraphics[width=0.1\textwidth]{progeria.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Sotos]{
\includegraphics[width=0.1\textwidth]{sotos.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Turner]{
\includegraphics[width=0.1\textwidth]{turner.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Williams]{
\includegraphics[width=0.1\textwidth]{williams.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][FragileX]{
\includegraphics[width=0.1\textwidth]{fragileX.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Treacher Collins]{
\includegraphics[width=0.1\textwidth]{Treacher_collins.jpg}
\label{fig:subfig1}}
\qquad
\end{figure}
\end{document}
答案1
您的代码中缺少一些左括号[
。此外,缺少\qquad
且没有手动\\
添加换行符。如果您这样做,您可能会得出:
\documentclass[a4paper, 10pt, conference]{ieeeconf}
\usepackage{booktabs}
\usepackage{dcolumn}
\usepackage{rotating}
\usepackage{tabularx}
\usepackage{graphicx}
\usepackage[lofdepth,lotdepth]{subfig}
\begin{document}
\begin{figure}[h]
\centering
\subfloat[][22q11]{
\includegraphics[width=0.1\textwidth]{22q11.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Angelman]{
\includegraphics[width=0.1\textwidth]{angelman.jpg}
\label{fig:subfig2}}
\qquad
\subfloat[][Apert]{
\includegraphics[width=0.1\textwidth]{apert.jpg}
\label{fig:subfig3}}
\\
\subfloat[][CDL]{
\includegraphics[width=0.1\textwidth]{CDL.jpg}
\label{fig:subfig4}}
\qquad
\subfloat[][Down]{
\includegraphics[width=0.1\textwidth]{down.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Marfan]{
\includegraphics[width=0.1\textwidth]{marfan.jpg}
\label{fig:subfig1}}
\\
\subfloat[][Progeria]{
\includegraphics[width=0.1\textwidth]{progeria.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Sotos]{
\includegraphics[width=0.1\textwidth]{sotos.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Turner]{
\includegraphics[width=0.1\textwidth]{turner.jpg}
\label{fig:subfig1}}
\\
\subfloat[][Williams]{
\includegraphics[width=0.1\textwidth]{williams.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][FragileX]{
\includegraphics[width=0.1\textwidth]{fragileX.jpg}
\label{fig:subfig1}}
\qquad
\subfloat[][Treacher Collins]{
\includegraphics[width=0.1\textwidth]{Treacher_collins.jpg}
\label{fig:subfig1}}
\end{figure}
\end{document}
编辑:假设您想要对齐且高度相同的图片,图片的宽度会有所不同。您可以使用表格来获得(可能)所需的结果(这次我使用了 MWE 配置,如果您发布问题,请习惯将您的代码更改为 MWE):
\documentclass[a4paper, 10pt]{article}
\usepackage{graphicx}
\usepackage[lofdepth,lotdepth]{subfig}
\begin{document}
\begin{figure}[h]
\centering
\begin{tabular}{ccc}
\subfloat[][22q11]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
&\subfloat[][Angelman]{
\includegraphics[height=2cm]{example-image-1x1}
\label{fig:subfig2}}%
&\subfloat[][Apert]{
\includegraphics[height=2cm]{example-image-10x16}
\label{fig:subfig3}}%
\\
\subfloat[][CDL]{
\includegraphics[height=2cm]{example-image-9x16}
\label{fig:subfig4}}%
&\subfloat[][Down]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
&\subfloat[][Marfan]{
\includegraphics[height=2cm]{example-image-1x1}
\label{fig:subfig1}}%
\\
\subfloat[][Progeria]{
\includegraphics[height=2cm]{example-image-golden}
\label{fig:subfig1}}%
&\subfloat[][Sotos]{
\includegraphics[height=2cm]{example-image-golden-upright}
\label{fig:subfig1}}%
&\subfloat[][Turner]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
\\
\subfloat[][Williams]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
&\subfloat[][FragileX]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
&\subfloat[][Treacher Collins]{
\includegraphics[height=2cm]{example-image-a}
\label{fig:subfig1}}%
\end{tabular}
\end{figure}
\end{document}