Text alignment in quarto
I am using Koma script document class scrbook. The following way to align right in both pdf and html outputs in quarto uses quarto/pandoc fenced block attributes.
In _quarto.yaml:
format:
html:
css: styles.css
pdf:
include-in-header:
- text: |
\usepackage{ragged2e}in styles.css:
.flushright {
text-align: right;
}and in the document:
:::{.flushright data-latex=""}
This text is right-aligned in HTML and PDF.
:::Example – right-aligned text. Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat. Duis aute irure dolor in reprehenderit in voluptate velit esse cillum dolore eu fugiat nulla pariatur. Excepteur sint occaecat cupidatat non proident, sunt in culpa qui officia deserunt mollit anim id est laborum.
data-latex="" causes pandoc to pass the flushright through to \(\LaTeX\) – without it, quarto regards the fenced block as html only and discards the flushright information.
This was posted as an answer in GitHub/quarto-dev/quarto-cli. Apparently, you don’t need the data- bit, but I haven’t tried that.