我正在使用利用 subfig 包的预制 latex 代码撰写论文,我想一次并排放置一系列图像。但这会导致图像的标题编号为 a、b、c.... 或 1、2、3....,但我希望编号与遵循章节和节编号的单个图像的编号相同:
\documentclass{article}
\usepackage{graphicx}
\usepackage{transparent} % Enables transparent images
\usepackage{eso-pic} % For the background picture on the title page
\usepackage{subfig} % Numbered and caption subfigures using \subfloat.
\usepackage{tikz} % A package for high-quality hand-made figures.
\usetikzlibrary{}
\graphicspath{{./Images/}} % Directory of the images
\usepackage{caption} % Coloured captions
\usepackage{xcolor} % Coloured captions
\usepackage{amsthm,thmtools,xcolor} % Coloured "Theorem"
\usepackage{float}
\usepackage{wrapfig}
\usepackage{alphalph}
\renewcommand*{\thesubfigure}{%
\alphalph{\value{subfigure}}%
}%
\begin{figure}[H]
\centering
\subfloat[Figure 1]
{
\includegraphics[width=.4\textwidth]{Figure 1.png}
\label{fig:fig1}
}
\subfloat[Figure 2]
{
\includegraphics[width=.4\textwidth]{Figure 2.png}
\label{fig:fig2}
}
\end{figure}
\begin{figure}[H]
\centering
\subfloat[Figure 3]
{
\includegraphics[width=.4\textwidth]{Figure 3.png}
\label{fig:fig3}
}
\subfloat[Figure 4]
{
\includegraphics[width=.4\textwidth]{Figure 4.png}
\label{fig:fig4}
}
\end{figure}
\end{document}
我已将使用过的所有软件包都包括在内,因为我不确定哪些可能重要。
答案1
错误源于您对 的重新定义\thesubfigure
,该定义已不存在。从技术上讲,您应该用\subfloat
其他名称替换该名称,因为它与子图无关。
\documentclass{article}
\usepackage[draft]{graphicx}% REMOVE DRAFT OPTION
\usepackage{transparent} % Enables transparent images
\usepackage{eso-pic} % For the background picture on the title page
%\usepackage{subfig} % Numbered and caption subfigures using \subfloat.
\usepackage{tikz} % A package for high-quality hand-made figures.
\usetikzlibrary{}
\graphicspath{{./Images/}} % Directory of the images
\usepackage{caption} % Coloured captions
\usepackage{xcolor} % Coloured captions
\usepackage{amsthm,thmtools,xcolor} % Coloured "Theorem"
\usepackage{float}
\usepackage{wrapfig}
\usepackage{alphalph}
\newcommand{\subfloatlabal}{\empty}% reserve global name
\newcommand{\subfloat}[2][\empty]% #1=caption (optional), #2=body
{\bgroup
\let\subfloatlabel=\empty
\sbox0{% measure image
\def\label##1{\gdef\subfloatlabel{##1}}% save \label name
#2}%
\begin{minipage}[b]{\wd0}
\usebox0
\ifx\empty#1\relax
\else\caption{#1}%
\fi
\ifx\empty\subfloatlabel\relax
\else\label{\subfloatlabel}%
\fi
\end{minipage}
\egroup}
\begin{document}
\begin{figure}[ht]% freinds don't let friends use [H]
\centering
\subfloat[Figure 1]
{
\includegraphics[width=.4\textwidth]{Figure 1.png}
\label{fig:fig1}
}
\subfloat[Figure 2]
{
\includegraphics[width=.4\textwidth]{Figure 2.png}
\label{fig:fig2}
}
\end{figure}
\begin{figure}[ht]
\centering
\subfloat[Figure 3]
{
\includegraphics[width=.4\textwidth]{Figure 3.png}
\label{fig:fig3}
}
\subfloat[Figure 4]
{
\includegraphics[width=.4\textwidth]{Figure 4.png}
\label{fig:fig4}
}
\end{figure}
\ref{fig:fig1}, \ref{fig:fig2}, \ref{fig:fig3} and \ref{fig:fig4}.
\end{document}