Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to justify the text to both sides when knitting html in rmarkdown

---
title: '1'
author: "A"
date: "April 4, 2017"
output: html_document
---

      Figure 3 includes the residual plot and QQ-plot. The residual plot have no obvious pattern: the expect value of residuals is close to 0 and the variances are approximately equal. The QQ-plot shows the standardized residuals are close to the theoretical quantiles. Thus, **the residuals are normally distributed and homoscedastic, and the assumption of the liner model is satisfied**. The VIF values for each variable in the best model is small, indicating **there are no obvious multicolinearity**.

Use the above code for example, as it shows in the picture, the second line and third line are aligned to the left by default.

enter image description here

What should I do if I want to align to both sides? (Notice: not align to the center!)

Text Justification in Rmarkdown word document gives the solution for word output case, but I haven't found a good reference for html case.

like image 769
Bin Avatar asked Apr 05 '17 05:04

Bin


People also ask

Can you justify text in Markdown?

Aligning text in native markdown is not possible. However, you can align the text using inline HTML tags. To justify, replace right with justify in the above.

How do you justify text in LaTeX?

Full Justify Text By default, LaTeX fully justifies text in LaTeX documents. However, you can explicitly specify this if you are using a different alignment method. To do this, use the \justify command.

How do you knit Rmarkdown to HTML?

To transform your markdown file into an HTML, PDF, or Word document, click the “Knit” icon that appears above your file in the scripts editor. A drop down menu will let you select the type of output that you want. When you click the button, rmarkdown will duplicate your text in the new file format.


1 Answers

Just overwrite the alignment right after the YAML:

---
title: '1'
author: "A"
date: "April 4, 2017"
output: html_document
---

<style>
body {
text-align: justify}
</style>

&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;Figure 3 includes the residual plot and QQ-plot. The residual plot have no obvious pattern: the expect value of residuals is close to 0 and the variances are approximately equal. The QQ-plot shows the standardized residuals are close to the theoretical quantiles. Thus, **the residuals are normally distributed and homoscedastic, and the assumption of the liner model is satisfied**. The VIF values for each variable in the best model is small, indicating **there are no obvious multicolinearity**.

Credits to Guilherme Parreira, here

like image 63
miguelsj Avatar answered Sep 22 '22 13:09

miguelsj