【问题标题】:Vertical alignment of subfigures LATEX子图的垂直对齐 LATEX
【发布时间】:2011-01-20 16:01:03
【问题描述】:

我正在写我的论文,我正在努力将 2 个图像彼此相邻放置,以便第二个图像将沿着第一个图像垂直居中。我也尝试使用subfigure 而不是subfloat,但它们都不起作用。

这就是它的样子alt text http://img51.imageshack.us/img51/1174/screenshot20100224at712.png

我的代码是:

\begin{figure}[H]
\centering  \subfloat[H][sparse($\mathbf{A}$)]{\includegraphics[width=0.28\textwidth]{sparsesmall} \label{sparse}}
    \subfloat[H][full($\mathbf{A}$)]{\includegraphics[width=0.55\textwidth]{fullsmall}\label{full}}
  \caption{Representation of $\mathbf{A}$ in MATLAB}
  \label{schematic}
\end{figure}

有什么建议可以让它看起来比现在更好吗?谢谢

【问题讨论】:

    标签: image latex formatting vertical-alignment


    【解决方案1】:

    您也可以使用\raisebox{x}{\includegraphics[...]{...}},其中x 为负数表示向下移动,正数表示向上移动。

    【讨论】:

      【解决方案2】:

      编辑subfig 包似乎有问题,尤其是在使用 hyperref 时。在这种情况下,请尝试 this answer 中提到的 subcaption 包。

      如果你使用subfig 包,你可以轻松做到这一点。解决方法在the manual的5.4节:

      \newsavebox{\tempbox}
      \begin{figure}[H]
      \sbox{\tempbox}{\includegraphics[width=0.28\textwidth]{sparsesmall}}
      \subfloat[sparse($\mathbf{A}$)]{\usebox{\tempbox}\label{sparse}}%
      \qquad
      \subfloat[full($\mathbf{A}$)]{\vbox to \ht\tempbox{%
        \vfil
        \includegraphics[width=0.55\textwidth]{fullsmall}
        \vfil}\label{full}}%
        \caption{Representation of $\mathbf{A}$ in MATLAB}\label{schematic}
      \end{figure}
      

      我没有测试过,可能有错别字,但应该可以。

      【讨论】:

      • 由于某种原因,第二个图的标题右对齐。否则它会完美运行,谢谢。
      • 仅供参考,subfig 包现在已经过时了。因此,应使用subcaption (stackoverflow.com/a/18795247/8653606) 的答案。
      【解决方案3】:

      另一个解决方案(与subcaption 包一起使用是

      \begin{figure}[p]
              \centering
              \begin{subfigure}{.49\linewidth}
                  \centering
                  \caption{Large Picture}
                  \includegraphics{LARGEPIC}
              \end{subfigure}
              \hfill
              \begin{subfigure}{.49\linewidth}
                  \centering
                  \caption{SMALL PIC}
                  \includegraphics{small picture}
                  \begin{minipage}{.1cm}
                  \vfill
                  \end{minipage}
              \end{subfigure} 
              \caption{Two pictures}
      \end{figure}
      

      单独\vfill是不行的,所以才放到minipage

      【讨论】:

      • 谢谢,我不能使用 subfig 包,所以这是要走的路(至少对我来说)。
      【解决方案4】:

      我的方法是使用以内容为中心的方形 minipage:

      \begin{figure}
      \subfloat[Figure a]{%
      \begin{minipage}[c][1\width]{0.5\textwidth}%
      \includegraphics[clip,width=1\textwidth]{figurea}%
      \end{minipage}}\subfloat[Figure b]{\centering{}%
      \begin{minipage}[c][1\width]{0.5\textwidth}%
      \begin{center}
      \includegraphics[clip,width=0.6\textwidth]{figureb}
      \par\end{center}%
      \end{minipage}}
      \caption{main caption}
      \end{figure}
      

      不过,这段代码是 LyX 生成的,所以有点难看。

      【讨论】:

        猜你喜欢
        • 2021-08-22
        • 2021-02-26
        • 1970-01-01
        • 1970-01-01
        • 2010-10-29
        • 1970-01-01
        • 2010-12-03
        相关资源
        最近更新 更多