Can I justify my text when I create a docx file with Quarto?

Hi, guys!

I have been using quarto in RStudio for few days.

I need to generate an .docx with justified text and Times New Roman font (or similar in Linux).

To justify in .rmd files I used to put <div style="text-align: justify"> at the begin of the file and close with </div>.

But this is not working with quarto. How can I fix it?

Also, how can I change my main font in quarto?

My code:

---
title: "My simple title"
description: | 
  Text proof
author: "My name and ID"
format: 
  docx:
    geometry: 
      - top=30mm
      - left=30mm
editor: visual
---

<div style="text-align: justify"> 

**UNIVERSIDADE DE SÃO PAULO - USP**

-   Program

-   Date: 10/05/2022

-   Subject: Calc

-   Professor: Marcelo 

# Question
**1)** Text textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textText textxt textText textText textText textText textText textText textText textText textText textText textText textText textxt textText textText textText textText textText textText textText textText textText textText textText textText text

</div>

What this working with rmarkdown::word_document() format ? I can't reproduce, and I am not sure it was ever possible to style docx this way. Can you share a working example in Rmd so I can have a look ?

Usually for docx document, you need to provide a reference docx to change the default style used, or provided use custom style you could use with fenced divs syntax to apply on a paragraph.

See about custom styles syntax https://pandoc.org/MANUAL.html#output and how to create docx template in https://quarto.org/docs/output-formats/ms-word-templates.html

1 Like

Thanks a lot!

I tried to use a template yesterday and did not work, but tried again now and worked fine!

I dont know what I did wrong lol

Thanks a lot!

1 Like

About my .rmd, I used it in a simple HTML output with prettydoc package.

Ok. So that is why the syntax you used worked - because it is HTML output. The syntax with div will have not effect for Word output. Templates need to be used.

Glad it works now

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.