两个图形并排放置,高度不一致,且标题对齐

两个图形并排放置,高度不一致,且标题对齐

对于这个问题我还有一个补充:两个并排的身影

假设我们有两张图片,它们的高度不均匀。我正在寻找一种方法来不是使用subfig并对齐两个图形,同时保持标题垂直对齐。

我创建了以下示例:

\documentclass{article}
\title{Two Figures Side by Side}
\author{Little Bobby Tables}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\exedout}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}

\newcommand{\exedouttwo}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}
\begin{document}
\maketitle
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\centering
\begin{minipage}{0.45\textwidth}
\centering\exedout
\caption{first figure but with more comments than the second picture to see what the different is.}
\end{minipage}
\begin{minipage}{0.45\textwidth}
\centering\exedouttwo
\caption{second figure}
\end{minipage}
\end{figure}

\lipsum

\end{document}

其结果如下:

错误对齐

但我需要这个:

右对齐

答案1

使用[t]可选参数minipage将两者与顶部基线(即图像基线/下线)对齐。我还将%s 添加到您的宏中,以避免源代码换行符插入额外的空格。

\documentclass{article}
\usepackage{lipsum}
\usepackage{tikz}

\newcommand{\exedout}{%
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}%
}

\newcommand{\exedouttwo}{%
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.8\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}%
}
\begin{document}
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\centering
\begin{minipage}[t]{0.45\textwidth}
\centering\exedout
\caption{first figure but with more comments than the second picture to see what the different is.}
\end{minipage}
\begin{minipage}[t]{0.45\textwidth}
\centering\exedouttwo
\caption{second figure}
\end{minipage}
\end{figure}

\lipsum

\end{document}

答案2

正在使用floatrow一个选项?

请注意,在下面的例子中,我通过改变\exedout和使两个图形变窄\exedouttwo,因为ffigbox似乎没有改变\textwidthminipage因此两个图形会太宽。

\documentclass{article}
\title{Two Figures Side by Side}
\author{Little Bobby Tables}
\usepackage{lipsum}
\usepackage{tikz}
\usepackage{floatrow}
\newcommand{\exedout}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.4\textwidth, 0.8\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}

\newcommand{\exedouttwo}{
\begin{tikzpicture}
\path node (LL) {}
    ++ (0.4\textwidth, 0.4\textheight) node (UR) {}
    (LL -| UR) node (LR) {}
    (LL |- UR) node (UL) {};
\draw (LL) rectangle (UR) (LL) -- (UR) (UL) -- (LR);
\end{tikzpicture}
}
\begin{document}
\maketitle
How can I put two figures side-by-side? Not two sub-figures, but two actual figures
with separate "Fig.: bla bla" captions. A figure is supposed to spread over the
entire text width, but I have two figures which are narrow and long, and I need to
save the space in order to withstand the pages limit.

\lipsum

\begin{figure}
\begin{floatrow}
\ffigbox{\caption{first figure but with more comments than the second picture to see what the different is.}}{\exedout}
\ffigbox{\caption{second figure}}{\exedouttwo}
\end{floatrow}
\end{figure}

\lipsum

\end{document}

在此处输入图片描述

相关内容