Skip to content

Jupyter cell directive to set custom styles #8008

Answered by cderv
liquidcarbon asked this question in Q&A
Discussion options

You must be logged in to vote

This is a matter of CSS and HTML element.

About this, #| class-output: { text-align: right; } , this is really a mix of several things. { text-align: right; } is CSS, it needs to be applied to a selector or something. class-output in knitr ecosystem is for setting a class onto the output div, no matter what is inside.

Quarto equivalent of class-output would be #| classes:, which will apply a class to the output div. Example:

```{python}
#| classes: my-table
import pandas as pd
df = pd.DataFrame({'x': [1,2], 'y': [3,4], 'name': ['Alice', 'Bob']})
df
```

This means that your table will be somewhere below a div.my-table and you can then easily target using CSS in your theme file.

This is wha…

Replies: 3 comments 2 replies

Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
1 reply
@cderv
Comment options

Comment options

You must be logged in to vote
1 reply
@cderv
Comment options

Answer selected by liquidcarbon
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants