Open flyaflya opened 6 years ago
Sounds like a bug, but I don't have time to fix it. Sorry. And pull requests are welcome!
Alright, I can embrace the challenge of debugging this, but I need a hint.
Using fig.margin = TRUE
, but WITHOUT the chunk option of fig.align = "center"
in the .rmd
file I get the following working output in the .md
file:
<p><span class="marginnote shownote">
<!--
<div class="figure">-->
<img src="image.png" alt="Alt title." width="30%" />
<!--
<p class="caption marginnote">-->MPG vs horsepower, colored by transmission.<!--</p>-->
<!--</div>--></span></p>
As soon as I add fig.align = "center"
, then the .md
file reads:
Last sentence of text in a normal paragraph.</p>
<div class="figure" style="text-align: center">
<img src="image.png" alt="Screwy: MPG vs horsepower, colored by transmission." width="30%" />
<!--
<p class="caption marginnote">-->Screwy: MPG vs horsepower, colored by transmission.<!--</p>-->
<!--</div>--></span></p>
As you can see, the addition of the align option omits the two first lines which start the HTML paragraph. Specifically, these are missing:
<p><span class="marginnote shownote">
<!--
And also, the align option alters the third line in a way that is not helpful to centering the image:
<div class="figure" style="text-align: center">
I have trouble now finding a function in the knitr
, tufte
, or rmarkdown
packages responsible for generating the .md
file with the marginnote
designation. Any advice? Thanks!!!!
@flyaflya did you manage to get fig.align = "center"
to work?
I never got it to work as above. I chose to center all images by default. To do this, I created a file called center.css
in the directory of my index.rmd file
. The contents are here:
img { display: block;
margin-left: auto;
margin-right: auto;
/*border-style: solid;
border-width: 2px;*/
padding-right: 5em;
}
Then, added center.css to my _output.yml file like this:
bookdown::tufte_html_book:
tufte_variant: "envisioned"
toc: yes
split_by: chapter
css: [toc2.css, googleAPIFont.css, center.css]
highlight: tango
includes:
in_header: doc_prefix.html
Thanks for the great package. I am using it to write a bookdown book with HTML and PDF output.
My problem is that I am trying to center a margin figure instead of accepting the defaul of left-align. PDF output works fine, but HTML output does not handle the below snippet properly:
Output puts figure in center of main text instead of centering in margin: