Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
831 views
in Technique[技术] by (71.8m points)

latex - Displaystyle in all equations in R Markdown document entire document

is there a way to have equations (inside $$) always displaystyle without having to type displaystyle inside each $$? I looked online but couldn't find an answer, only for TeX documents, but not for R Markdown. Thanks !

Nonexample: (test.Rmd)

---
title: "Displaystyle"
author: "Stacker"
date: "1/25/2021"
output: pdf_document
fontsize: 12pt
---

$displaystyle frac {1}{2}$

$displaystyle sum_{i=0}^n$

$displaystyle int_0^infty$
 

Beware this task may or may not be possible.

question from:https://stackoverflow.com/questions/65894576/displaystyle-in-all-equations-in-r-markdown-document-entire-document

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

This page https://tex.stackexchange.com/questions/32824/show-inline-math-as-if-it-were-display-math-and-vice-versa suggests putting everymath{displaystyle} in the preamble to achieve what you want. If I just put that into the body of the R Markdown file, it seems to work for me. For example,

---
title: "Displaystyle"
author: "Stacker"
date: "1/25/2021"
output: pdf_document
fontsize: 12pt
---

everymath{displaystyle}

$frac {1}{2}$

$displaystyle frac {1}{2}$

$sum_{i=0}^n$

$displaystyle sum_{i=0}^n$

$int_0^infty$

$displaystyle int_0^infty$

produces duplicates of each equation. To restore the default, just include everymath{}.

Edited to add: One limitation of this approach: MathJax doesn't support everymath, so this only works in formats like pdf_document that use LaTeX as an intermediate. If you want the same behaviour in html_document, you'll need to do something else.


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...