0

Using this post I tried to add multiple pairs of subfigures to my latex document

\usepackage{minted}
\usemintedstyle{borland}
\newcommand{\code}[1]{\mintinline{c}{#1}}
\usepackage{subcaption}
\usepackage{graphicx}

\begin{document}
\subsection{\code{process_select()}}

The following diagrams show how  \code{process_select()} would modify the \code{queue} and \code{current_process} for test \code{lab3_t0.c}.

\begin{figure}[h]
\centering
\begin{subfigure}[b]{0.5\textwidth}
   \includegraphics[width=1\linewidth]{process_select1}
   \caption{\code{queue}}
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth}
   \includegraphics[width=1\linewidth]{process_select2}
   \caption{\code{current_process}}
\end{subfigure}

\caption{Initially \code{queue} would hold both processes, but \code{current_process} would not be set since \code{process_select()} has not been called so no \code{current_process} has been set}

\begin{subfigure}[b]{0.5\textwidth}
   \includegraphics[width=1\linewidth]{process_select3}
   \caption{\code{queue}}
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth}
   \includegraphics[width=1\linewidth]{process_select4}
   \caption{\code{current_process}}
\end{subfigure}
\end{figure}
\end{document}

But nothing shows up!

But when I change the width of the last 2 subfigures to width=0.5\linewidth:

\begin{subfigure}[b]{0.5\textwidth}
   \includegraphics[width=0.5\linewidth]{process_select3}
   \caption{\code{queue}}
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth}
   \includegraphics[width=0.5\linewidth]{process_select4}
   \caption{\code{current_process}}
\end{subfigure}

It shows up but not the way I want it to: enter image description here

What I want is for the process_select3 and process_select4 to show up in the same size as process_select1 and process_select2. I also have an additional 2 subfigures process_select5 and proceess_select6 that I want to add, which I tried using:

    \begin{subfigure}[b]{0.5\textwidth}
   \includegraphics[width=0.5\linewidth]{process_select5}
   \caption{\code{queue}}
\end{subfigure}

\begin{subfigure}[b]{0.25\textwidth}
   \includegraphics[width=0.5\linewidth]{process_select6}
   \caption{\code{current_process}}
\end{subfigure}

\caption{After second call to \code{process_select()} \code{current_process} would be set to the next process in the \code{queue} (\code{p2}) and since the \code{p1} is still running, it would be appended to the end of the queue}

But sadly nothing showed up when I added that code in the \begin{figure}...\end{figure} environment

If anyone could provide me the latex code to make all 6 of my subfigures (process_select1-6) show up with the same width as the first 2 subfigures (process_select3 and process_select4) and also have a caption for each pair of subfigures, that would be great!

14wml
  • 255
  • 3
  • 7
  • I cant reproduce your problem. With the first code in your question I obtain expected result. Off topic: why you have caption on middle of the figure and not bottom, where usually is? By the way, in your MWE is missed \documentclass{...}˙ – Zarko Mar 24 '17 at 21:13
  • @Zarko I've added my whole code. I didn't want to add my whole code b/c I didn't think they affected my results, but based on your comment there might be smtg I'm overlooking. Please let me know. And I added captions "in the middle of the figure" because I want to have caption for every 2 picture (i.e. a caption for process_select 1 & process_select2, a caption for process_select3 & process_select4, and a caption for process_select5 & process_select6). But perhaps I am doing this wrong? – 14wml Mar 24 '17 at 21:24
  • please, make your question shorter. one MWE is sufficient :) – Zarko Mar 24 '17 at 21:25
  • okay I'll delete the code. jw, what do you mean by MWE? – 14wml Mar 24 '17 at 21:49
  • MWE: Minimal Working Example. A small complete (self contained) document with \documentclass{...} on its beginning and end{document} on its end :), which show the your problem. – Zarko Mar 24 '17 at 22:29

1 Answers1

1

I only guessing what you like to obtain ... but I'm not sure, if the following result is what you looking for:

enter image description here

In my MWE instead of your image I use demo images, which are provided by graphicx package (optiondemo). IN compa\hsil:

\documentclass[12pt,a4paper,openright,oneside]{article}
\usepackage{minted}
\usemintedstyle{borland}
\newcommand{\code}[1]{\mintinline{c}{#1}}
\usepackage{subcaption}
\usepackage[demo]{graphicx}

\begin{document}
\subsection{\code{process_select()}}

The following diagrams show how  \code{process_select()} would modify the \code{queue} and \code{current_process} for test \code{lab3_t0.c}.

\begin{figure}[h]
\centering
\begin{subfigure}[t]{0.6\textwidth}
   \includegraphics[width=\linewidth]{process_select1}
   \caption{\code{queue}}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.3\textwidth}
   \includegraphics[width=\linewidth]{process_select2}
   \caption{\code{current_process}}
\end{subfigure}

\caption{Initially \code{queue} would hold both processes, but \code{current_process} would not be set since \code{process_select()} has not been called so no \code{current_process} has been set}
\begin{subfigure}[t]{0.6\textwidth}
   \includegraphics[width=\linewidth]{process_select3}
   \caption{\code{queue}}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.3\textwidth}
   \includegraphics[width=\linewidth]{process_select4}
   \caption{\code{current_process}}
\end{subfigure}

\caption{Initially \code{queue} would hold both processes, but \code{current_process} would not be set since \code{process_select()} has not been called so no \code{current_process} has been set}

\begin{subfigure}[t]{0.6\textwidth}
   \includegraphics[width=\linewidth]{process_select5}
   \caption{\code{queue}}
\end{subfigure}
\hfil
\begin{subfigure}[t]{0.3\textwidth}
   \includegraphics[width=\linewidth]{process_select6}
   \caption{\code{current_process}}
\end{subfigure}

\caption{Initially \code{queue} would hold both processes, but \code{current_process} would not be set since \code{process_select()} has not been called so no \code{current_process} has been set}
\end{figure}

\end{document}
Zarko
  • 296,517