子浮点字幕问题

子浮点字幕问题

我有两个并排的数字,如图所示1

这是使用以下代码的当前情况:

 \begin{figure}[H]
    \subfloat[Overall architecture]{\includegraphics[scale=0.45]{images/Graphiti/graphiti_architecture}
    } \hfill{} \subfloat[Detail of the diagram type  agent\label{fig:Diagram-type-agent}]{\includegraphics[scale=0.45]{images/Graphiti/diagram-type-agent-new}  
 }

 \protect\caption{Graphiti architecture\label{fig:Graphiti-architecture}}
\end{figure}

在此处输入图片描述

如您所见,它们没有垂直对齐。在 Google 上搜索解决方案时,我找到了以下代码:

 \newsavebox{\tempbox}
 \begin{figure}[H]
    \sbox{\tempbox}{\includegraphics[width=0.45\textwidth]{images/Graphiti/graphiti_architecture}}
    \subfloat[Graphiti Architecture]{\usebox{\tempbox}\label{sparse}}%
    \qquad
    \subfloat[Detail diagarm type agent]{\vbox to \ht\tempbox{%
            \vfil
            \includegraphics[width=0.45\textwidth]{images/Graphiti/diagram-type-agent-new}
            \vfil}\label{full}}%
    \caption{Graphiti Architecture [ref]}\label{schematic}
 \end{figure}

结果如下:

在此处输入图片描述

这正是我想要的,但第二个标题是错误的。有办法修复吗?

答案1

再加一个\hbox

\vfil
\hbox to 0.45\textwidth{%
            \includegraphics[width=0.45\textwidth]{images/Graphiti/diagram-type-agent-new}}
            \vfil}

做成to 0.45\textwidth\includegraphics[width=0.45\textwidth]

\documentclass[demo]{article}
\usepackage{subfig,graphicx}
\begin{document}

 \newsavebox{\tempbox}
 \begin{figure}[H]
    \sbox{\tempbox}{\includegraphics[width=0.45\textwidth,height=8cm]{images/Graphiti/graphiti_architecture}}
    \subfloat[Graphiti Architecture]{\usebox{\tempbox}\label{sparse}}%
    \hfill
    \subfloat[Detail diagarm type agent]{\vbox to \ht\tempbox{%
            \vfil
            \hbox to 0.45\textwidth{%
            \includegraphics[width=0.45\textwidth]{images/Graphiti/diagram-type-agent-new}
            }
            \vfil}\label{full}}%
    \caption{Graphiti Architecture [ref]}\label{schematic}
 \end{figure}
\end{document}

在此处输入图片描述

相关内容