Search code examples
rformulabookdown

Layout of a formula in a bookdown file


In my *.Rmd file I'm writing something like this

$\text{Dia}_i = \max_{x, y \in C_i} d(x,y)$

And I was expecting this

namelimits

but when doing bookdown::render_book(...) and controlling the results in my browser firefox I got

nonamelimits

I found that this has something to do with the namelimits (first picture) and nonamelimits (second picture) but unfortunately I have no clue how to change the outcome.

Question: What kind of code chunk I have to add that I can switch between the two notations?

Thanks a lot in advance!

Edit_1

enter image description here

Can I mix these two types?! The goal is to have an inline formula with the desired apperance.

Edit_2

This is my Code - the three dots (...) are the magic/unknown code

enter image description here

And this is my desired output

enter image description here

But sadly I get this

enter image description here

My wish summerized

enter image description here


Solution

  • This should work, following https://stackoverflow.com/a/61979164/13249862:

    Add this to your YAML header:

    header-includes:
        - \newcommand{\argmax}{\mathop{\mathrm{max}}\limits}
    

    Then, you can write both equations:

    This $\text{Dia}_i = \argmax_{x, y \in C_i} d(x,y)$, or this $\text{Dia}_i = \max_{x, y \in C_i} d(x,y)$.
    

    Result: enter image description here