我正在尝试使用subfigure
环境来生成带有字幕的并排图像,但是由于图像的高度不同,字幕的高度也不同。而且,它们之间完全没有空间,在我看来,这使得它们难以阅读。有没有直接的方法来解决这个问题?
我用来生成这些子图/标题的代码是
\documentclass[a4paper,12pt,oneside]{report}
\usepackage[inline]{asymptote}
\usepackage{caption}
\usepackage{subcaption}
\makeatletter
\g@addto@macro\@floatboxreset\centering
\makeatother
\begin{document}
\begin{figure}[h!tb]
\begin{subfigure}{.5\textwidth}
\raggedright
\begin{asy}
picture pic;
path p1 = (-1, 0)--(-1, 1)--(-0.5, 1.5)--(0, 2)--(.5, .7)--(0, .7)--(.5, .5)--(.5, 0)--(-1, 0);
draw(pic, p1);
draw(pic, (-1, 0)--(-1, 2)--(0.5, 2)--(0.5, 0)--(-1, 0), red+dashed);
path p2 = shift(1, -0.5)*((-1, 0.5)--(-0.5, 1)--(0.5, 1)--(1, 0.5)--(1, -0.5)--(0.5, -1)--(-0.5, -1)--(-1, -0.5)--(-1, 0.5));
draw(pic, p2);
draw(pic, shift(1, -0.5)*((-1, -1)--(-1, 1)--(1, 1)--(1, -1)--(-1, -1)), purple+dashed);
add(scale(50)*pic);
\end{asy}
\caption{Two polygons that intersect, along with intersecting bounding
rectangles}
\end{subfigure}%
\begin{subfigure}{.5\textwidth}
\raggedleft
\begin{asy}
picture pic;
path p1 = (-1, 0)--(-1, 1)--(-0.5, 1.5)--(0, 2)--(.5, .7)--(0, .7)--(.5, .5)--(.5, 0)--(-1, 0);
draw(pic, shift(1)*p1);
draw(pic, shift(1)*((-1, 0)--(-1, 2)--(0.5, 2)--(0.5, 0)--(-1, 0)), blue+dashed);
path p2 = shift(-0.8, 1.8)*((-1, 0.5)--(-0.5, 1)--(0.5, 1)--(1, 0.5)--(1, -0.5)--(0.5, -1)--(-0.5, -1)--(-1, -0.5)--(-1, 0.5));
draw(pic, p2);
draw(pic, shift(-0.8, 1.8)*((-1, -1)--(-1, 1)--(1, 1)--(1, -1)--(-1, -1)), green+dashed);
add(scale(50)*pic);
\end{asy}
\caption{Two polygons that do not intersect but with intersecting
bounding rectangles}
\end{subfigure}
\caption{The representation of some polygons and their minimum bounding
rectangles.}
\end{figure}
\end{document}
答案1
改变路线
\begin{subfigure}{.5\textwidth}
到
\begin{subfigure}[b]{.5\textwidth}
并添加
\usepackage[margin=1cm]{subcaption}
到文件的开头应该可以解决这两个问题。