mkdocs-with-pdf
mkdocs-with-pdf copied to clipboard
Admonitions do not render in PDF output - mkdocs-material v8.0.2
When building a PDF with version 8.0.2 from mk-material the output of the admonitions markdown extension is broken.
Sample from v7.3.6

Sample with v8.0.2

No existing changes were made to any configs beyond updating material version.
We're facing the same issue, so currently we have to downgrade mkdocs-material every time we build the .pdf.
Any progress on this? I am holding off on upgrading until we have some sort of fix for this
@jacobswe I think it's just best to run on an older build for the pdf export and setup a special case *.yml. I was planning on doing this for the repo I maintain just haven't gotten around to it due to lists being a bit wonky.
This appears to be a css issue. I was able to get decent looking admonitions by overriding the css with extra_sass.
Pipefile
libsass = "*"
mkdocs.yml
plugins:
- extra-sass
extra_sass/style.css.scss
@media print {
// admonition overrides
// admonition icon
.md-typeset :is(.admonition-title,summary):before {
top: 0.6rem;
left: 0.6rem;
}
// left border
.md-typeset :is(.admonition,details) {
border-left-width: 0.1rem;
padding: 0rem 0rem 0rem 0rem;
margin-left: 1rem;
}
[dir=ltr] .md-typeset :is(.admonition,details) {
margin-left: 1rem;
}
html .md-typeset :is(.admonition,details)>:last-child {
margin-left: 0.6rem;
}
}
@cmaurer I made the same changes you did but none of the styling show for my admonitions in the PDF. What am I missing?
@mudgen I followed @cmaurer's comment, with a few modifications. I got the following result:

Python packages:
- mkdocs-material 8.5.7
- mkdocs-with-pdf 0.9.3
mkdocs.yml
extra_css:
- stylesheets/extra.css
docs/stylesheets/extra.css
@media print {
/* Adjusts positioning of admonition icon */
.md-typeset :is(.admonition-title,summary):before {
top: 0.6rem;
left: 0.6rem;
}
}
I've tried to combine the work of @cmaurer and @santaimpersonator but I still got the alignment issue as #135. Any ideas?
My environment: MacOS M1 Ventura 13.1 (Beta) with Python 3.10.6 (use Conda as package management system).
My package's version:
- mkdocs-material 8.5.7
- mkdocs-with-pdf 0.9.3
- mkdocs 1.4.2 / 1.4.1
Can confirm that @santaimpersonator worked for:
- mkdocs-material==8.5.10
- mkdocs-with-pdf==0.9.3
- mkdocs==1.4.2
Using a docker image adapted from python:3.9.8
It is worth double checking the mkdocs.yml file and the references to the files "extra.css" and "style.css.scss"