最近我问了一个问题caption
关于的不兼容性revtex4-2
。我采纳了建议,但现在我面临新的问题,例如:
- 文本中和文本下方的图形数字样式之间的差异
- 我想将图片并排放置。我附加了文件(我不知道如何附加图片)
\documentclass[aps,pra,twocolumn,floatfix,footinbib,notitlepage,superscriptaddress,groupaddress,subcaption,caption,showpacs]{revtex4-2}
\usepackage{graphicx,graphics,times,bm,bbm,bbold,amssymb,amsmath,amsfonts,dsfont,hyperref,mathrsfs,color,cancel}
\usepackage{adjustbox}
\usepackage{tabularx}
\usepackage{tabulary}
\usepackage{tabularray}
\UseTblrLibrary{booktabs}
\usepackage{dcolumn}% Align table columns on decimal point
\usepackage{booktabs}
\usepackage{nicefrac}
\usepackage[caption=false]{subfig}
%\usepackage[mathlines]{lineno}% Enable numbering of text and display math
%\linenumbers\relax % Commence numbering lines
\usepackage{kantlipsum} % dummy text <<<<<<<<<<<<<<<
\begin{document}
\preprint{AIP/123-QED}
1. \kant[1-2]
%\title[Sample title]{Sample Title:\\with Forced Linebreak\footnote{Error!}}% Force line breaks with \\
\begin{abstract}
\end{abstract}
\keywords{}
\maketitle
\begin{quotation}
% The ``lead paragraph'' is encapsulated with the \LaTeX\
% \verb+quotation+ environment and is formatted as a single paragraph before the first section heading.
% (The \verb+quotation+ environment reverts to its usual meaning after the first sectioning command.)
% Note that numbered references are allowed in the lead paragraph.
%
% The lead paragraph will only be found in an article being prepared for the journal \textit{Chaos}.
\end{quotation}
\section{Introduction}\label{sec:introduction}
\textcolor{blue}{As Fig.~(\ref{fig1}) and Fig.(\ref{fig2}) show there is a difference between the number of the picure in text and caption }
\begin{figure}[ht!]\label{fig1}
\subfloat[\label{subfig2a}]{%}
\includegraphics[width=0.45\textwidth]{fig1}%
}\hfill
\subfloat[\label{subfig2b}]{%
\includegraphics[width=0.45\textwidth]{fig2}%
}\hfill
\caption{caption for \ref{subfig2a} subfloat 1 \ref{subfig2b} subflot2}
\end{figure}
\begin{figure}[ht!]\label{fig2}
\subfloat[\label{subfig3a}]{%}
\includegraphics[width=0.45\textwidth]{fig1}%
}\hfill
\subfloat[\label{subfig3b}]{%
\includegraphics[width=0.45\textwidth]{fig2}%
}\hfill
\caption{caption for \ref{subfig2a} subfloat 1 \ref{subfig2b} subflot2}
\end{figure}
2. \kant[2-4]
\end{document}
%
% ****** End of file aipsamp.tex ******
答案1
尝试
\documentclass[aps,pra,twocolumn,floatfix,footinbib,notitlepage,superscriptaddress,groupaddress,subcaption,caption,showpacs]{revtex4-2}
\usepackage{graphicx}
\usepackage{xcolor}
%\usepackage[caption=false]{subfig}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\section{Introduction}
\label{sec:introduction}
\textcolor{blue}{As Fig.~(\ref{fig1}) and Fig.(\ref{fig2}) show there is a difference between the number of the picture in text and caption}
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig1a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig1b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig1a} subfloat-1 \ref{subfig1b} subflot-2}
\label{fig1}
\end{figure}
Referencing subfigures \ref{subfig1a} and \ref{subfig1b}.
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig2a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig2a} subfloat-1 \ref{subfig2b} subfloat-2}
\label{fig2}
\end{figure}
\begin{figure}[ht!]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig3a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig3b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig3a} subfloat-1 \ref{subfig3b} subfloat-2}
\label{fig3}
\end{figure}
Referencing subfigures \ref{subfig2a}, \ref{subfig2a},\ref{subfig3a} and \ref{subfig3b}, and figures \ref{fig2} and \ref{fig3}.
\lipsum[1-3]
\end{document}
通过以上代码与您的代码的比较您应该观察到:
- 图表标签应位于标题之后
- 您的问题的 MWE 可以显著缩短
- 它也适用于最近的
subcaption
软件包(版本 1.3 或最新版本) - 您不需要加载
graphics
包(它由加载graphicx
)。 - 请为图像加载示例图像,该图像可供所有人使用
附录:
例如,如果您希望图中的图像跨越文档的列,则需要使用figure*
浮动。例如:
\documentclass[aps,pra,twocolumn,floatfix,footinbib,notitlepage,superscriptaddress,groupaddress,subcaption,caption,showpacs]{revtex4-2}
\usepackage{graphicx}
\usepackage{xcolor}
\usepackage{subcaption}
\usepackage{lipsum}
\begin{document}
\section{Introduction}
\label{sec:introduction}
\textcolor{blue}{As Fig.~(\ref{fig1}) and Fig.(\ref{fig2}) show there is a difference between the number of the picture in text and caption}
\begin{figure}[!ht]
\setkeys{Gin}{width=0.45\linewidth}
\subfloat[\label{subfig1a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig1b}]{\includegraphics{example-image-b}}
\caption{caption for \ref{subfig1a} subfloat-1 \ref{subfig1b} subflot-2}
\label{fig1}
\end{figure}
\lipsum[1]
\begin{figure*}
\setkeys{Gin}{width=0.22\linewidth}
\subfloat[\label{subfig2a}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2b}]{\includegraphics{example-image-b}}
\hfill
\subfloat[\label{subfig2c}]{\includegraphics{example-image-a}}
\hfill
\subfloat[\label{subfig2d}]{\includegraphics{example-image-b}}
\caption{caption for subfloats \ref{subfig2a}, \ref{subfig2b},
\ref{subfig2c} and \ref{subfig2d}.}
\label{fig2}
\end{figure*}
\textcolor{blue}{Referencing subfigures \ref{subfig2a}, \ref{subfig2a},\ref{subfig2c} and \ref{subfig2d} in figure \ref{fig2}.}
\lipsum[2-11]
\end{document}
图形将出现在插入点的下一页的顶部。