Reputation: 4102
When I create a simple table in Jupyter Notebooks, the table appears in the center of the cell. What do I have to do to align that table to the left instead of center?
Sample Latex Table for Jupyter:
| This | is |
|------|------|
| a | table|
Thank you
Upvotes: 5
Views: 13517
Reputation: 1
Align tables only for markdown output:
Jupyter & Jupyter Lab:
%%html
<style>
/* Jupyter */
.rendered_html table,
/* Jupyter Lab*/
div[data-mime-type="text-markdown"] table {
margin-left: 0
}
</style>
Put this code once on the top of notebook in Code cell
Upvotes: 0
Reputation: 365
When creating a table and assigning it the float: left attribute you end up having to add more CSS to resolve the text that surrounds the table. Place this in a code cell before your markdown cell
%%html
<style>
table {
display: inline-block
}
</style>
However, if you have a lot of CSS, might be best to put it in another file for the overall beauty of the document.
Upvotes: 8
Reputation: 25976
Here are the steps:
Create a Code cell just above your markdown cell where you want to show your table.
Write the following in your Code cell.
%%html <style> table {float:left} </style>
Run your Code cell.
Write Table markdown code in your Markdown cell. Your table should now align to the left.
Upvotes: 7