Having an alternating style for odd or even pages #456
Replies: 2 comments
-
Marp is designed for PowerPoint style presentation slides, and is not supported the book style pagination. If necessary, you can write a Marp (Marpit) plugin to add // engine.mjs
const marpOddEvenSlidePlugin = (md) => {
md.core.ruler.after('marpit_slide', 'marp_odd_even_slide', (state) => {
if (state.inlineMode) return
for (const token of state.tokens) {
if (token.type === 'marpit_slide_open') {
const pageNumber = token.meta.marpitSlide + 1
token.attrJoin('class', pageNumber % 2 === 0 ? 'even' : 'odd')
}
}
})
}
export default ({ marp }) => marp.use(marpOddEvenSlidePlugin)
|
Beta Was this translation helpful? Give feedback.
0 replies
-
Since this is the first Google result and I have come across the problem again (and was surprised to realize I had already asked it a year ago), here's the CSS selector to target odd pages, which can be adapted for even pages: section[data-marpit-pagination$="1"],
section[data-marpit-pagination$="3"],
section[data-marpit-pagination$="5"],
section[data-marpit-pagination$="7"],
section[data-marpit-pagination$="9"]{
/* style goes here */
} |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
In print, it's usual for the page marker to alternate between the right and left side of the page. Is there a way to apply this in Marp?
The expected section:nth-child solution doesn't work since each section is a standalone element.
Thank you for your attention.
Beta Was this translation helpful? Give feedback.
All reactions