Pandoc md to pdf: keep order when inserting image before pagebreak

倾然丶 夕夏残阳落幕 提交于 2020-05-31 06:11:54

问题


as the title states, my question is about pandocs md to pdf.

When I convert a markdown like

# Title

...... text that is about a 3/4 page

![image that is too large to fit page](image.png)

Some more text

then the text after the image "some more text" is displayed on the first page and the image gets pushed to the second page, which changes the order of my content.

What i can do is something like

# Title

...... text that is about a 3/4 page

\newpage
![image that is too large to fit page](image.png)

Some more text

But that is very annoying to maintain, because when i want to add content to the start afterwards i have to check if the \newpage is still neccessary there of if i have to add another one somewhere else.

Is there any real solution for this? Maybe a setting in the YAML header?

I have googled alot about this but didnt come across a solution.

Thanks :)


回答1:


Try rendering with pandoc from the command line and deactivating the implicit_figures option, as in:

pandoc my_markdown.md -f markdown-implicit_figures -o rendered_md.pdf

This comes with the downside that it removes captions from figures. Including the following tex in the header works perfectly for me (copied from here as well):

\usepackage{float}
\let\origfigure\figure
\let\endorigfigure\endfigure
\renewenvironment{figure}[1][2] {
    \expandafter\origfigure\expandafter[H]
} {
    \endorigfigure
}


来源:https://stackoverflow.com/questions/60000244/pandoc-md-to-pdf-keep-order-when-inserting-image-before-pagebreak

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!