I am using pandoc and xelatex PDF generator to make my text files (markdown syntax) into PDFs. Command used (just so you get the idea):
pandoc --template=needHelp.tex markdownText.txt --pdf-engine=xelatex -o mwe.pdf
The problem is - in latex figures and tables are floats (and they float around). I don't like that. I like my figures where I place them.
Most people stick with just markdown or latex, so all the valid answers are adding placement specifiers in latex - e.g.
\begin{figure}[hbt!]
... figure contents...
\end{figure}
But all my text, figures, tables etc. is in the text file, so that isn't an option. I need to add something in the preamble of the latex, so that the template knows all my figures will be exactly where I place them.
Minimum working example (consists of template and markdown file):
1) Template:
\documentclass[12pt]{scrartcl}
%Some Imports that are in the original template
\usepackage{color,soul}
\usepackage{tabu}
\usepackage{array}
\usepackage{fancyhdr}
\usepackage{graphicx}
\usepackage{wrapfig}
\usepackage{xcolor}
\IfFileExists{xurl.sty}{\usepackage{xurl}}{}
\IfFileExists{bookmark.sty}{\usepackage{bookmark}}{\usepackage{hyperref}}
\hypersetup{
$if(colorlinks)$
colorlinks=true,
linkcolor=$if(linkcolor)$$linkcolor$$else$Maroon$endif$,
filecolor=$if(filecolor)$$filecolor$$else$Maroon$endif$,
citecolor=$if(citecolor)$$citecolor$$else$Blue$endif$,
urlcolor=$if(urlcolor)$$urlcolor$$else$Blue$endif$,
$else$
pdfborder={0 0 0},
$endif$
breaklinks=true}
\urlstyle{same}
\begin{document}
$body$
\end{document}
2) Markdown:
# First level
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque cursus velit malesuada nisi luctus aliquet. Ut vehicula eros nisi, nec consectetur velit tempor blandit. Ut at nisl at ipsum pretium gravida. Curabitur interdum, diam non venenatis vehicula, neque ipsum congue ante, ut suscipit nisl ipsum eu metus.
## Second level
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque cursus velit malesuada nisi luctus aliquet. Ut vehicula eros nisi, nec consectetur velit tempor blandit. Ut at nisl at ipsum pretium gravida. Curabitur interdum, diam non venenatis vehicula, neque ipsum congue ante, ut suscipit nisl ipsum eu metus.
### Third level
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Pellentesque cursus velit malesuada nisi luctus aliquet. Ut vehicula eros nisi, nec consectetur velit tempor blandit. Ut at nisl at ipsum pretium gravida. Curabitur interdum, diam non venenatis vehicula, neque ipsum congue ante, ut suscipit nisl ipsum eu metus.
# Whatever
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Mauris vitae mi enim. Sed in sapien ut ex pulvinar finibus. In feugiat vel risus quis finibus. Praesent quis imperdiet velit, id tempor nisl. Pellentesque in erat a felis bibendum bibendum. Nam nisl massa, rhoncus non est in, placerat dignissim risus. In viverra viverra leo quis suscipit. Nullam porta, augue eget sodales maximus, ex augue volutpat purus, non tempor nunc neque quis magna. Praesent tincidunt massa id vehicula tincidunt. Praesent nisl odio, elementum eget orci quis, facilisis ullamcorper nulla. Phasellus egestas placerat diam nec ultricies. Phasellus finibus molestie massa sed ornare. Donec magna tellus, viverra a gravida sit amet, iaculis eu nulla. Nullam non augue neque.
## Figure

You won't be able to see it here...
# Intereseting stuff
Lorem ipsum dolor sit amet, consectetur adipiscing elit.
So this is BAD, I DON'T WANT THIS:
This is GOOD (the idea is that if I insert a line break before the image, it will place the image at the right spot. But that is a bad solution and it loses it's caption (cannot be applied):
Also - if someone has a quick fix for the caption to be at the top, I would also appreciate that, but it isn't my main concern. I hope this is enough of a description - I don't know if there is anything more I can provide...
Thank you!
You can use the H
placement specifier provided by the float
package. You can make this the default using
\usepackage{float}
\floatplacement{figure}{H}
\floatplacement{table}{H}