Forum How do I...?

Space of indentation for lists is too much?

user202411
I am using prince to convert my markdown notes into pdfs. But the indentations of lists, whether in Chinese or English texts(==> see the attachments), take up so much blank space, which is a huge waste. How can I narrow down the space of indentation ahead of all the lists?
  1. 屏幕截图 2024-11-13 222423.png433.7 kB
  2. 屏幕截图 2024-11-13 222438.png177.2 kB
wangp
The indentation is effected by a non-zero margin on ol/ul elements in Prince user agent style sheet (style/html.css). You can override the margin in your own style sheet:
ol, ul {
    margin-left: 40px;
}

Note that browsers (and the current HTML spec) indent lists by setting a non-zero padding, so if you set a non-zero margin, the list will be indented by both the margin and the padding when viewed in a browser. Therefore, you might want to explicitly zero out either the margin or the padding:
ol, ul {
    margin-left: 0;
    padding-left: 40px;
}

We are considering making a change to the Prince user agent style sheet for future versions.
user202411
Thanks. This works well.
mikeday
We have now changed the latest builds to use padding instead of margin for HTML list items by default, which should make the behaviour more consistent with web browsers.

The previous advice still applies: explicitly specifying padding and margin will guarantee the expected result in every version of Prince and browser.