[英]Vertical alignment of subfigures LATEX
I am working on my thesis and I am struggling with placing 2 images next to each other, so that the second image would be centered vertically along the first one.我正在写我的论文,我正在努力将 2 张图像并排放置,以便第二张图像沿第一张图像垂直居中。 I was also trying to use
subfigure
instead of subfloat
but neither of them works.我也试图利用
subfigure
,而不是subfloat
,但他们都没有工作。
This is how it looks alt text http://img51.imageshack.us/img51/1174/screenshot20100224at712.png这是它的外观替代文本 http://img51.imageshack.us/img51/1174/screenshot20100224at712.png
and my code is:我的代码是:
\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}
Any suggestions to make it look better than now?有什么建议可以让它看起来比现在更好吗? Thx
谢谢
您还可以使用\\raisebox{x}{\\includegraphics[...]{...}}
,其中x
为负数向下移动,正数向上移动。
Edit : it seems like subfig
package has problems, particularly when working with hyperref.编辑:似乎
subfig
包有问题,尤其是在使用subfig
时。 In that case, try subcaption
package as mentioned in this answer .在这种情况下,请尝试本答案中提到的
subcaption
包。
If you use subfig
package, you can do this easily.如果你使用
subfig
包,你可以很容易地做到这一点。 The solution is in section 5.4 of 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}
I haven't tested it, and there may be typos, but it should work.我还没有测试过,可能有错别字,但它应该可以工作。
Another solution (which works with the subcaption
package is另一个解决方案(与
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}
The \\vfill
alone does not work, that's why it is put into the minipage
单独的
\\vfill
不起作用,这就是它被放入minipage
My method is using square minipage which centers its contents:我的方法是使用以内容为中心的方形 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}
This code was generated by LyX, however, so it's a bit ugly.然而,这段代码是由 LyX 生成的,所以有点难看。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.