我在尝试将子标题图例放在图形顶部时遇到了麻烦。无论我做什么,它们都会出现在中间。此代码重现了该问题:
\documentclass[draft, oneside, a4paper, onecolumn, 11pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage[export]{adjustbox}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % use color
\begin{document}
\begin{figure}[!ht]
\adjustbox{minipage=1em,valign=t}{\subcaption{} \label{fig:fig1}}%
\begin{subfigure}[c]{0.24\textwidth}
\centering
\includegraphics[scale=1.]{fig1.pdf}
\end{subfigure}
\adjustbox{minipage=1em,valign=t}{\subcaption{} \label{fig:fig2}}%
\begin{subfigure}[c]{0.24\textwidth}
\centering
\includegraphics[scale=1.]{fig2.pdf}
\end{subfigure}
\adjustbox{minipage=0em,valign=t}{\subcaption{} \label{fig:fig3}}%
\begin{subfigure}[c]{0.4\textwidth}
\centering
\includegraphics[scale=1.]{fig3.pdf} \\
\end{subfigure}
\end{figure}
\end{document}
导致
我究竟做错了什么?
答案1
假设您想要将子图的中心对齐在一起,但将标题的顶部与子图的顶部对齐,则需要首先使用保存框确定子图的高度。
顺便说一句,没有标题的子图是一个小页面。
\documentclass[draft, oneside, a4paper, onecolumn, 11pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{adjustbox}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % use color
\begin{document}
\begin{figure}[!ht]
\sbox0{\begin{subfigure}[c]{0.24\textwidth}
\centering
\includegraphics[scale=1.]{fig1.pdf}
\end{subfigure}}%
\adjustbox{minipage=1em,raise=\dimexpr\ht0-\height}{\subcaption{} \label{fig:fig1}}%
\usebox0
%
\sbox0{\begin{subfigure}[c]{0.24\textwidth}
\centering
\includegraphics[scale=1.]{fig2.pdf}
\end{subfigure}}%
\adjustbox{minipage=1em,raise=\dimexpr\ht0-\height}{\subcaption{} \label{fig:fig2}}%
\usebox0
%
\sbox0{\begin{subfigure}[c]{0.4\textwidth}
\centering
\includegraphics[scale=1.]{fig3.pdf} \\
\end{subfigure}}%
\adjustbox{minipage=1em,raise=\dimexpr\ht0-\height}{\subcaption{} \label{fig:fig3}}%
\usebox0
\end{figure}
\end{document}
如果想要对齐图像的顶部,可以使用一种更简单的方法。
\documentclass[draft, oneside, a4paper, onecolumn, 11pt]{article}
\usepackage{graphicx}
\usepackage{subcaption}
\usepackage{adjustbox}
\usepackage[usenames,dvipsnames,svgnames,table]{xcolor} % use color
\begin{document}
\begin{figure}[!ht]
\adjustbox{minipage=2em,raise=-\height}{\subcaption{} \label{fig:fig1}}%
\raisebox{-\height}{\includegraphics[scale=1.]{fig1.pdf}}
%
\adjustbox{minipage=2em,raise=-\height}{\subcaption{} \label{fig:fig2}}%
\raisebox{-\height}{\includegraphics[scale=1.2]{fig2.pdf}}
%
\adjustbox{minipage=2em,raise=-\height}{\subcaption{} \label{fig:fig3}}%
\raisebox{-\height}{\includegraphics[scale=1.]{fig3.pdf}}
\end{figure}
\end{document}