LaTeX Multiple Columns Text with two or double columns can be created by passing the parameter \twocolumn to the document class statement. If you want to create a document with more than two columns, use the package multicol, which has a set of commands for the same.
You can't, at least not with pure Markdown as it doesn't have any concept of columns. As explained in the rules:
The idea for Markdown is to make it easy to read, write, and edit prose. HTML is a publishing format; Markdown is a writing format. Thus, Markdown’s formatting syntax only addresses issues that can be conveyed in plain text.
For any markup that is not covered by Markdown’s syntax, you simply use HTML itself.
In fact, the best way would be to have each code block wrapped in a <div>
with the appropriate class assigned to each div. However, most Markdown parsers do not parse Markdown inside a raw HTML block. Therefore, you may need to also define the code block in raw HTML as well. Check your parser's list of features to find out. In the event you are not able to define your own CSS to use separately from the Markdown (to style the HTML), you will also need to define the styles inline in the HTML. This question includes a nice sample of what that might look like. Just replace the comments with the appropriate code blocks. If you have to define your code blocks in raw HTML, they would look like this:
<pre><code class="language-c">int foo (void)
{
int i;
}
</code></pre>
So, the final document that is sure to work in all (most?) Markdown parsers would look like this:
# Rule 1
Description for rule 1.
<div style="-webkit-column-count: 2; -moz-column-count: 2; column-count: 2; -webkit-column-rule: 1px dotted #e0e0e0; -moz-column-rule: 1px dotted #e0e0e0; column-rule: 1px dotted #e0e0e0;">
<div style="display: inline-block;">
<h2>Good</h2>
<pre><code class="language-c">int foo (void)
{
int i;
}
</code></pre>
</div>
<div style="display: inline-block;">
<h2>Bad</h2>
<pre><code class="language-c">int foo (void) {
int i;
}
</code></pre>
</div>
</div>
Note that that uses one of many different ways of defining columns in CSS. Different methods may or may not work in different browsers. YMMV.
While this doesn't work for all markdown's, I got this to work with GitLab, Github, and mdBook. I thought I'd share this answer.
Basically, you create the table via HTML. Markdown and HTML don't mix well, but if you surround the markdown with white-space, sometimes the markdown can be recognized.
https://docs.gitlab.com/ee/user/markdown.html#inline-html
<table>
<tr>
<th> Good </th>
<th> Bad </th>
</tr>
<tr>
<td>
```c++
int foo() {
int result = 4;
return result;
}
```
</td>
<td>
```c++
int foo() {
int x = 4;
return x;
}
```
</td>
</tr>
</table>
This is an old question but in case people come here from Google, the above answer is correct for plain true Markdown, but if you're looking to do this with or through something that's implementing kramdown, kramdown does support mixed HTML and Markdown syntaxes by its usage of PHP Markdown Extra as noted in kramdown docs here. kramdown just requires that in your markdown page where you intend to use said HTML, you add an attribute to the wrapping HTML element of markdown="1"
.
As an example (and direct solution to two-column markdown), this results in two columns for content. I did this using Bootstrap to handle both column width and image centering, but you could take any approach for those topics.
<div class="row">
<div class="col-md-8" markdown="1">
Some text.
</div>
<div class="col-md-4" markdown="1">
<!-- ![Alt Text](../img/folder/blah.jpg) -->
<img height="600px" class="center-block" src="../img/folder/blah.jpg">
</div>
</div>
Be wary of indents. I specifically didn't indent more than one level in the above code. I believe kramdown by default will interpret doubly-indented code as a quote block (and if I recall correctly, that's standard for Markdown in general).
Also note that I chose to use the html img
tag instead of the markdown image link. You may choose to do the same since you gain a bit of extra control.
And, if you're new or unfamiliar with/to Bootstrap, you can change the relative column widths by changing the 8
and/or 4
shown in the code above, just make sure the sum of those two numbers is always 12.
As mentioned above, this only works for markdown consumers implementing the kramdown engine (and that's great for Jekyll users).
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With