我需要并排获取两个数字,并使用以下代码:
\begin{figure} [H]
\centering
\begin{subfigure}{0.49\textwidth}
\centering
\includegraphics[width = \textwidth]{1e4}
\caption{Combined figure}
\label{fig:left}
\end{subfigure}
\begin{subfigure}{0.49\textwidth}
\centering
\includegraphics[width = \textwidth]{1e3}
\caption{Right figure}
\label{fig:right}
\end{subfigure}
\end{figure}
但是,我需要为每个图形单独添加标题。该怎么做?
答案1
您可以minipages
在环境中对每个图形使用figure
一个命令:caption
\documentclass{article}
\usepackage{lmodern}
\usepackage{graphicx}
\begin{document}
As you can see in figs.~\ref{fig:left} and \ref{fig:right} \dots
\begin{figure}
\centering
\begin{minipage}{0.49\textwidth}
\centering
\includegraphics[width = \textwidth]{example-image-a}
\caption{Left figure}
\label{fig:left}
\end{minipage}
\begin{minipage}{0.49\textwidth}
\centering
\includegraphics[width = \textwidth]{example-image-b}
\caption{Right figure}
\label{fig:right}
\end{minipage}
\end{figure}
\end{document}
答案2
floatrow
使用专用于该操作的包可以轻松完成此操作,并与以下caption
包配合使用:
\documentclass[a4paper, 11pt]{article}
\usepackage[utf8]{inputenc}
\usepackage{lipsum}
\usepackage{graphicx}
\usepackage{floatrow}
\DeclareFloatVCode{rowsep}{\vskip 5ex}
\begin{document}
\begin{figure} [H]
\centering\floatsetup{floatrowsep = qquad, rowpostcode = rowsep}
\begin{floatrow}
\ffigbox[\FBwidth]{\caption{For the Snarks were Boojums, you see…}\label{fig:left}}
{\includegraphics[width = 0.48\textwidth]{snark.png}}
%%%%
\ffigbox[\FBwidth]{\caption{A Portrait of a distinguished author}\label{fig:right}}
{\includegraphics[width = 0.48\textwidth]{Charles-Dodgson}}
\end{floatrow}
\begin{floatrow}
\ffigbox[\FBwidth]
{\includegraphics[scale = 0.8]{sendak}}
{\caption{Where Wild Things are} \label{fig:Maurice}}
\ffigbox[\FBwidth]
{\includegraphics[scale = 0.5]{AliceSteadman}}
{\caption{Ralph} \label{fig:Wabbit}}
\end{floatrow}
\end{figure}
\end{document}