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

前端 未结 4 2030
无人及你
无人及你 2021-02-19 01:48

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, h

相关标签:
4条回答
  • 2021-02-19 02:14

    One simple way is convert your file first to a .tex file, where you can adjust your image alignment with LaTeX command minipage or so. Then you could obtain your .pdf file running latex or pandoc in command line. See Pandoc Demos for example.

    0 讨论(0)
  • 2021-02-19 02:17

    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.

    0 讨论(0)
  • 2021-02-19 02:29

    You could use a preprocessor like gpp to include options like align image. Or you could do it like how John told you:

    ![](tests/lalune.jpg)\ ![](tests/lalune.jpg)
    
    0 讨论(0)
  • 2021-02-19 02:37

    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:

    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}
    

    Edit 20180910:

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

    header-includes: |
        \usepackage{caption}
        \usepackage{subcaption}
    
    0 讨论(0)
提交回复
热议问题