Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

lists are not aligned properly when exported to PDF with mkdocs-material as theme #145

Open
ThibaudBrrd opened this issue Jun 7, 2023 · 2 comments

Comments

@ThibaudBrrd
Copy link

Problem

It seem that mkdocs-with-pdf don't indent lists when mkdocs-material theme is used.

Configuration

mkdocs.yml (without mkdocs-material) :

site_name: PDF List Indentation Test

plugins:
  - with-pdf

mkdocs.yml (with mkdocs-material) :

site_name: PDF List Indentation Test

theme:
    name: material

plugins:
  - with-pdf

Source

docs/index.md :

# PDF List Indentation Test

Test for indentation of list in PDF generated by mkdocs-with-pdf plugin

## Unordered List

- First level
    * Second level
        + Third level

## Ordered List

1. First level
    1. Second level
        1. Third level

## Mixed List

1. First level
    * Second level
        1. Third level

Result

document.pdf (without mkdocs-material)

image

document.pdf (with mkdocs-material)

image

Comment

As you can see the unordered list is not indented on each level and the next list are indented in the wrong direction and still not visually indented on each level even when the marker is indented.

@ThibaudBrrd
Copy link
Author

After searching and testing solutions, I found that the problem may originate from WeasyPrint. Apparently, during my test with WeasyPrint version 56, I didn't encounter the issue of unindented lists with mkdocs-material. However, the problem occurs with other versions such as WeasyPrint 58 or WeasyPrint 52.

After testing solutions, I have found a fix for the problem. Here is my modification:

.md-typeset > ul {
  margin-left: 0rem !important;
}
.md-typeset ul li,
.md-typeset ol li {
  margin-left: 1.5rem !important;
}

I placed it on top of themes/material.scss file just before @media print. Not sure if it's the right file to place it, but it works.

During my search, I also added the solution from issue #94.

@averaart
Copy link

averaart commented Dec 7, 2023

After searching and testing solutions, I found that the problem may originate from WeasyPrint. Apparently, during my test with WeasyPrint version 56, I didn't encounter the issue of unindented lists with mkdocs-material. However, the problem occurs with other versions such as WeasyPrint 58 or WeasyPrint 52.

After testing solutions, I have found a fix for the problem. Here is my modification:

.md-typeset > ul {
  margin-left: 0rem !important;
}
.md-typeset ul li,
.md-typeset ol li {
  margin-left: 1.5rem !important;
}

I placed it on top of themes/material.scss file just before @media print. Not sure if it's the right file to place it, but it works.

During my search, I also added the solution from issue #94.

Thanks!

I ended up placing this in ./templates/style.scss, which according to the documentation should be picked up to be applied over whatever theme styling you've selected.

This allowed me to keep the fix in my own codebase and not rely on changes to files from this repo.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants