TransWikia.com

How to fix the LaTeX code of the inserted figures? (By using begin{minipage})

TeX - LaTeX Asked on December 29, 2020

I have some difficulties to fix the errors of the codes produced by the inserted figures.

Here is my original LaTeX code:

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.4linewidth}
    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.4linewidth}
    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.4linewidth}
    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.4linewidth}
    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}

The error of the output is as follows:

enter image description here

One Answer

The subfigure package is old and deprecated. Don't use it. Instead, use either the subfig or the subcaption package.

The following solution employs the subcaption package and its subfigure environment. (The "?" symbols shown in the screenshot occur because the cross-references cannot be resolved.)

enter image description here

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}

Answered by Mico on December 29, 2020

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP