Can you be more precise with your example with what you want to write in the Rmd file and what you want as output ?
I am sure to understand if you want :
Just a way to quickly write this inline expression in your Rmd document, as something like snippet or Rstudio adding with keyboard shortcut could help
A way to write something in your Rmd document (f(x) is too general regarding what you want for me to clearly understand) and get the correct formating and content in the resulting HTML file (or PDF file - not sure what your output is)
If you can provide more information and maybe a reproducible example it would help !
knitr and rmarkdown are pretty customisable (using something like hooks or custom engine for example), so I think you can do what you want.
In principle, a snippet provides functionality I could use (I wasn't aware of them). However, snippets do not seem to work outside of chunks. I'm looking for something that will work in r-markdown outside of {r} chunks.
Note then for markdown snippets within R Markdown documents you always need to use the Shift+Tab sequence as there is no standard tab completion available within the markdown editing mode.
I'm unable to get any snippets to work outside of {r} chunks.
FYI I'm using Rstudio 1.3.1073 on a Debian 10 system.
Re output, I'm using the default settings for R notebook
You can use snippets in rmarkdown outside a chunk, but the snippet needs to be defined in the "Markdown" snippets page (rather than the "R" snippets page) in order for this to work.
If you click on "edit snippets" in Global Options, the snippets file will open. What you see by default are the "R" snippets. However, in the left column of the window, you can see other languages listed, including "Markdown." Click on "Markdown" and you'll see the Markdown snippets page, where you can add your snippet.
For example, I added the following snippet:
snippet yy
\$`r yac_str(x)`\$
This snippet assumes that the object we're turning into a string will always be named x (you can change the snippet to allow a user-provided name, if desired).
To use the snippet, type yy and then shift+tab and it will replace yy with the text string of the equation. If x doesn't exist, the replacement output will be $$.