使用这个帖子我尝试向我的 latex 文档中添加多对子图
\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}
但什么也没出现!
但是当我将width
最后两个子图的更改为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}
我想要的是process_select3
和以与和process_select4
相同的大小显示。我还有另外 2 个子图和想要添加,我尝试使用它们:process_select1
process_select2
process_select5
proceess_select6
\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}
\begin{figure}...\end{figure}
但遗憾的是,当我在环境中添加该代码时,什么也没有出现
如果有人能给我提供乳胶代码,使我的所有 6 个子图( )以与前 2 个子图(和)process_select1-6
相同的宽度显示,并且为每对子图提供标题,那就太好了!process_select3
process_select4
答案1
我只是猜测您想获得什么……但我不确定以下结果是否是您想要的:
在我的 MWE 中,我使用由包 (选项)demo
提供的图像,而不是您的图像。在 compa\hsil 中:graphicx
demo
\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}