Any initiative to implement columns in Marp? #192
-
Columns are a integral and frequent feature in slide creation. Is there a way to make slides in Marp with two or more columns? Thanks in advance! |
Beta Was this translation helpful? Give feedback.
Replies: 11 comments 36 replies
-
https://twitter.com/y_hatt/status/1449951469961023488 CSS grid---
marp: true
style: |
.columns {
display: grid;
grid-template-columns: repeat(2, minmax(0, 1fr));
gap: 1rem;
}
---
# Multi columns in Marp slide
<div class="columns">
<div>
## Column 1
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas eveniet, corporis commodi vitae accusamus obcaecati dolor corrupti eaque id numquam officia velit sapiente incidunt dolores provident laboriosam praesentium nobis culpa.
</div>
<div>
## Column 2
Tempore ad exercitationem necessitatibus nulla, optio distinctio illo non similique? Laborum dolor odio, ipsam incidunt corrupti quia nemo quo exercitationem adipisci quidem nesciunt deserunt repellendus inventore deleniti reprehenderit at earum.
</div>
</div> Use Tailwind CSS v2 utilities (obsoleted)---
marp: true
style: @import url('https://unpkg.com/tailwindcss@^2/dist/utilities.min.css');
---
# Multi columns in Marp slide
<div class="grid grid-cols-2 gap-4">
<div>
## Column 1
Lorem ipsum dolor sit amet consectetur adipisicing elit. Voluptas eveniet, corporis commodi vitae accusamus obcaecati dolor corrupti eaque id numquam officia velit sapiente incidunt dolores provident laboriosam praesentium nobis culpa.
</div>
<div>
## Column 2
Tempore ad exercitationem necessitatibus nulla, optio distinctio illo non similique? Laborum dolor odio, ipsam incidunt corrupti quia nemo quo exercitationem adipisci quidem nesciunt deserunt repellendus inventore deleniti reprehenderit at earum.
</div>
</div>
Past discussion is available in marp-team/marpit#137. |
Beta Was this translation helpful? Give feedback.
-
@yhatt I just had an idea about this topic. I understand that it ist not easy compatible with common markdown to implement multi column natively. Then it came to my mind, what if there is a page derictive |
Beta Was this translation helpful? Give feedback.
-
I cust did a little "hack" with the proposed columns class and the // engine.js
const markdownItContainer = require('markdown-it-container');
module.exports = ({ marp }) => marp
.use(markdownItContainer, 'columns', {
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
return '<div class="columns"><div>\n';
} else {
return '</div></div>\n';
}
}
})
.use(markdownItContainer, 'split', {
render: function (tokens, idx) {
if (tokens[idx].nesting === 1) {
return '</div><div>\n';
} else {
return '</div></div>\n';
}
}
}) With this engine it is possible to write columns like this. # Heading
:::columns
left content
:::split
right content
::: it will be rendered to <h1>Heading</h1>
<div class="columns"><div>
left content
</div><div>
right content
</div></div> |
Beta Was this translation helpful? Give feedback.
-
FYI: I've been build short cut as plugin! |
Beta Was this translation helpful? Give feedback.
-
I would like to see a solution as suggested in marp-team/marpit#137 using just a *** separator in Markdown and no additional HTML directives. One reason for this is the following: I'm using Typora for editing Markdown and apart from creating slides with marp I'm using also Typoras export feature for creating PDFs (in A4 format). I've noticed that when I use HTML |
Beta Was this translation helpful? Give feedback.
-
I've found the following to work really well for me: <style scoped>
section {
columns: 2;
}
h1 {
column-span: all;
}
h2 {
break-before: column;
}
</style> Paste this at the top of a slide you want to have columns in. This assumes that each columns has an |
Beta Was this translation helpful? Give feedback.
-
I ended up just using CSS Grid
|
Beta Was this translation helpful? Give feedback.
-
The problem with the grid on the For me also the flex solution is not working always as expected with images on the right side. For the meantime the original solution with the additional |
Beta Was this translation helpful? Give feedback.
-
I have known how to split two and three columns by |
Beta Was this translation helpful? Give feedback.
-
@yhatt I totaly disagree with your stance on other issue that this feature is pure styling and everyone needs to figure out a style via css.
Most people will use some standart layouts and this breaks totaly the intuitive approch. I am very happy with the framework and html/css is a huge toolbox, but predetermined layouts should be a core thing. This might look like a minor thing but I realy believe this would open up for more people to use the framework. I cant go to a college and explain him "ye you can use markdown and make slides very easy buuuuuut you have to play around with very basic styling and waste your time on that" |
Beta Was this translation helpful? Give feedback.
-
How do I change the number of columns for each slide instead of the beginning of the file? |
Beta Was this translation helpful? Give feedback.
https://twitter.com/y_hatt/status/1449951469961023488
CSS grid