Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to use Pandoc image alignment to align two images in the same row?

From the pandoc documentation I know how to insert an image

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

Now I want to align two images in the same row, how can I do that? My desired output format is pdf.

like image 637
LittleSweet Avatar asked Mar 12 '13 16:03

LittleSweet


People also ask

What is pandoc used for?

Pandoc is a command-line tool for converting files from one markup language to another. Markup languages use tags to annotate sections of a document. Commonly used markup languages include Markdown, ReStructuredText, HTML, LaTex, ePub, and Microsoft Word DOCX.

Can pandoc convert HTML to markdown?

Pandoc can convert between numerous markup and word processing formats, including, but not limited to, various flavors of Markdown, HTML, LaTeX and Word docx.

Can pandoc convert PDF to markdown?

You can use the program pandoc on the SCF Linux and Mac machines (via the terminal window) to convert from formats such as HTML, LaTeX and Markdown to formats such as HTML, LaTeX, Word, OpenOffice, and PDF, among others.


2 Answers

You can try something like this:

![](tests/lalune.jpg)\ ![](tests/lalune.jpg)

This will give you two side-by-side images. You won't have a caption, though; pandoc only treats an image as a captioned figure if it is by itself in a paragraph.

like image 52
John MacFarlane Avatar answered Oct 11 '22 19:10

John MacFarlane


Expanding on from John's answer, if you do want a single caption under two side by side figures, a 'hack' would be to do this:

![](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}

This results in one caption for two images placed side by side. You might need to tweak each individual image's width setting, or the !h caption placement specifier to get things looking like this:

hacked caption

I found this helpful because you don't have to download the picture off the internet as in a pure LaTeX \subfigure solution. I.e. just use pandoc markdown to get the image, and LaTeX to generate the caption.

If you want to go crazy, you can actually use the same idea above to make subfigure captions like so:

![](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}

enter image description here

Edit 20180910:

You'll need to include the following packages in the pandoc YAML frontmatter/header:

header-includes: |
    \usepackage{caption}
    \usepackage{subcaption}
like image 36
weiji14 Avatar answered Oct 11 '22 19:10

weiji14