如何使用Pandoc图像对齐将两个图像对齐在同一行?

Lit*_*eet 10 image alignment pandoc

从pandoc文档中我知道如何插入图像

http://johnmacfarlane.net/pandoc/README.html#images

现在我想在同一行中对齐两个图像,我该怎么做?我想要的输出格式是pdf.

Joh*_*ane 15

你可以尝试这样的事情:

![](tests/lalune.jpg)\ ![](tests/lalune.jpg)
Run Code Online (Sandbox Code Playgroud)

这将为您提供两个并排的图像.但是你不会有标题; pandoc仅将图像视为字幕图形,如果它本身在段落中.

  • 数字大小问题已在更新版本的pandoc中得到解决.您现在可以使用![](tests/lalune.jpg){height = 3cm}这应该可以使您的图像具有相同的高度. (3认同)

wei*_*i14 5

从John的答案扩展,如果您确实希望在两个并排的图形下放置一个标题,那么“ hack”就是这样做的:

![](https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png){width=60%}
![](https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png){width=40%}
\begin{figure}[!h]
\caption{A single caption for the two subfigures}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

这样就为两个并排放置的图像提供了一个标题。您可能需要调整每个单独图像的宽度设置,或调整!h字幕放置说明符,以使内容看起来像这样:

字幕被黑

我发现这很有用,因为您不必像纯LaTeX \subfigure解决方案那样从互联网上下载图片。即只是使用pandoc markdown来获取图像,然后使用LaTeX来生成标题。

如果您想发疯,实际上可以使用与上述相同的方法来制作子图形标题,如下所示:

![](https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png){width=60%}
![](https://upload.wikimedia.org/wikipedia/commons/7/70/Example.png){width=40%}
\begin{figure}[!h]
\begin{subfigure}[t]{0.6\textwidth}
\caption{Caption for the left subfigure}
\end{subfigure}
\hfill
\begin{subfigure}[t]{0.4\textwidth}
\caption{Caption for the right subfigure}
\end{subfigure}
\caption{A single caption for the two subfigures}
\end{figure}
Run Code Online (Sandbox Code Playgroud)

在此处输入图片说明

编辑20180910:

您需要在pandoc YAML frontmatter / header中包含以下软件包:

header-includes: |
    \usepackage{caption}
    \usepackage{subcaption}
Run Code Online (Sandbox Code Playgroud)

  • 糟糕,忘了提到您需要包括这些软件包。在pandoc中,您将有```header-includes:| \ usepackage {caption} \ usepackage {subcaption}````我将编辑答案以使其更清楚。 (2认同)