0

If I use the code from this thread It will look like in the image. The user packages I have are \usepackage{subcaption} \usepackage{subfig} \usepackage{subfigure}

But for some reason, it does not work, at all? Where in the code do I enter the image name?enter image description here

3
  • 2
    You can't use all three packages subfigure, subfig and subcaption inside of a single document. Since the first one is considered deprecated, decide which of the latter two you want to use and stick to a single package.
    – leandriis
    Apr 26 '21 at 14:23
  • Does it matter which one I use of the two last ones? Apr 26 '21 at 14:31
  • @JohnGreger: Each package has its own implementation (macros and the like). However, in some cases, since they deal with the same subject matter, there may be some macros that overlap between packages and therefore could be overwritten.
    – Werner
    Apr 26 '21 at 16:48
1

This example uses the package subcaption for two upper figures side by side.

To test it with your images, put them in the same directory as the .tex document. Later you can move them to another directory by adding the path.

a

\documentclass[12pt,a4paper]{article}

\usepackage{subcaption} %  added <<<<<<<<<<<<<<<<

\usepackage{graphicx}

\begin{document}    
    
    \begin{figure}[ht!]  % with two subfigures included
        \begin{subfigure}[t]{.40\textwidth}
            \centering
            % first image
            \includegraphics[width=\textwidth, keepaspectratio]{example-image-a}  %  <<< image name 1
            \caption{Lorem ipsum}
            \label{fig:Lorem}
        \end{subfigure}\hfill
        \begin{subfigure}[t]{.40\textwidth}
            \centering
            % second image
            \includegraphics[width=\textwidth, keepaspectratio]{example-image-b} %  <<< image name 2
            \caption{Lorem ipsum, Lorem ipsum, Lorem ipsum, Lorem ipsum, Lorem ipsum}
            \label{fig:ipsum}
        \end{subfigure}
    \caption{Caption place holder}
    \end{figure}  

    \begin{figure}[ht!] % a single figure
            \centering
            \includegraphics[width=0.5\textwidth, keepaspectratio]{example-grid-100x100pt} % 
            \caption{Single figure named example-grid-100x100pt}
        \label{fig:gris}
    \end{figure}    
    
\end{document}

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.