问题
I am trying to create an analysis report in Rmarkdown and I am stuck here , below is the example of what I am working on
---
output: "pdf_document"
---
one small paragraph here
\newline
another paragraph below the image
here if i use \newline
my image is placed as expected between the paragraphs but the caption is missing else if i remove\newline
my image is randomly placed at the bottom after rendering the document.
Kindly help me , I tried placing extra_dependencies: "float"
in the YAML header still the result is same. I am working in emacs editor and am using basic markdown language and not r chunks. Kindly help me what I am missing here to get my images in place with caption and not floating.
Many thanks in advance.
floating and it is all knitted at the end or in random place
回答1:
EDIT: Found out more about floating images:
Try knitr::opts_chunk$set(fig.pos = "!H", out.extra = "")
in your first chunk. fig.pos
controls floating, and !H
stops floating within the document.
I am not sure why your image is being randomly placed. But it could be because of the image size. But try

test image
to have the caption on the bottom/center of the image. Or
\newline
test image
to have the caption on the bottom left of the image.
Or
test image
\newline
To have the caption on the top left of the image
来源:https://stackoverflow.com/questions/65133804/rmarkdown-image-floating