如何修复插入图片的 LaTeX 代码?(使用 \begin{minipage})

如何修复插入图片的 LaTeX 代码?(使用 \begin{minipage})

我在修复插入数字产生的代码错误时遇到了一些困难。

以下是我的原始 LaTeX 代码:

\documentclass[12pt]{article}
\usepackage{graphicx}
\usepackage{subfigure}

\begin{document}
\begin{figure}[H]
    \centering
    \subfigure[\centering Graph of $\phi$ from Example \ref{example1_1}(a), \\ $\phi(a,b)=|a|+|b|-\max(a,b)$]{\begin{minipage}[t]{0.4\linewidth}
    \centering
        \includegraphics[width=5cm]{LHC2020-4-1-a.pdf}
    \end{minipage}%
        }%
    \subfigure[\centering Graph of $\phi$ from Example \ref{example1_1}(b), \\ $\phi(a,b)=\ln(e^{|a|}+e^{|b|}-1)-\max(a,b)$]{\begin{minipage}[t]{0.4\linewidth}
    \centering
        \includegraphics[width=5cm]{LHC2020-4-1-b.pdf}
    \end{minipage}%
        }%

    \subfigure[\centering Graph of $\phi$ from Example \ref{example1_1}(c), \\ $\phi(a,b)=\|(a,b)\|_2-\max(a,b)$]{\begin{minipage}[t]{0.4\linewidth}
    \centering
        \includegraphics[width=5cm]{LHC2020-4-1-c.pdf}
    \end{minipage}%
        }%
    \subfigure[\centering Graph of $\phi$ from Example \ref{example1_1}(d), \\ $\phi(a,b)=\|(a,b)\|_5-\max(a,b)$]{\begin{minipage}[t]{0.4\linewidth}
    \centering
        \includegraphics[width=5cm]{LHC2020-4-1-d.pdf}
    \end{minipage}%
        }%
    \caption{Graphs of some NCP functions from Proposition \ref{prop1_1}(a)}
\end{figure}
\end{document}

输出的错误如下:

在此处输入图片描述

答案1

subfigure软件包已过时且已弃用。请勿使用它。请改用subfigsubcaption软件包。

以下解决方案使用了该subcaption包及其subfigure环境。(屏幕截图中显示的“?”符号是因为无法解析交叉引用而出现的。)

在此处输入图片描述

\documentclass[12pt]{article}
\usepackage[demo]{graphicx} % remove 'demo' option in real doc.
\usepackage{subcaption} % for 'subfigure' environment
\usepackage{geometry}   % set page parameters suitably

\begin{document}
\begin{figure}[h]
\captionsetup[subfigure]{justification=centering}
\begin{subfigure}{7cm}
\includegraphics[width=\textwidth]{LHC2020-4-1-a}
\caption{Graph of $\phi$ from Example \ref{example1_1}(a)\\
$\phi(a,b)=|a|+|b|-\max(a,b)$}
\end{subfigure}%
\hfill % maximize the horizontal separation
\begin{subfigure}{7cm}
\includegraphics[width=\textwidth]{LHC2020-4-1-b}
\caption{Graph of $\phi$ from Example \ref{example1_1}(b)\\
$\phi(a,b)=\ln(e^{|a|}+e^{|b|}-1)-\max(a,b)$}
\end{subfigure}

\bigskip % increase the vertical separation
\begin{subfigure}{7cm}
\includegraphics[width=\textwidth]{LHC2020-4-1-c}
\caption{Graph of $\phi$ from Example \ref{example1_1}(c)\\
$\phi(a,b)=\|(a,b)\|_2-\max(a,b)$}
\end{subfigure}%
\hfill % maximize the horizontal separation
\begin{subfigure}{7cm}
\includegraphics[width=\textwidth]{LHC2020-4-1-d}
\caption{Graph of $\phi$ from Example \ref{example1_1}(d)\\
$\phi(a,b)=\|(a,b)\|_5-\max(a,b)$}
\end{subfigure}

\caption{Graphs of some NCP functions from Proposition \ref{prop1_1}(a)}
\end{figure}
\end{document}

相关内容