Reputation: 1335
I have an equation that I wrote in r-markdown as follows
$$ 2 \frac{meter}{day} * 3 ~ days $$
I'd like to show that the days
cancel by striking them out. You can strike out text in r-markdown normally by ~~surrounding the text in tildaes~~
However, the tildae in the expression seems to only insert spaces.
$$ 2 \frac{meter}{~~day~~} * 3 ~ ~~days~~ $$
I also tried as one might in latex
$$ 2 \frac{meter}{sout{day}} * 3 ~ days $$
But this doesn't seem to work either.
Are there any options for striking out bits of equation that work in r-markdown equations?
Upvotes: 6
Views: 3842
Reputation: 143
For HTML, add at the beginning of the markdown,
<script type="text/x-mathjax-config">
MathJax.Hub.Register.StartupHook("TeX Jax Ready",function () {
MathJax.Hub.Insert(MathJax.InputJax.TeX.Definitions.macros,{
cancel: ["Extension","cancel"],
bcancel: ["Extension","cancel"],
xcancel: ["Extension","cancel"],
cancelto: ["Extension","cancel"]
});
});
</script>
and then
$$2 \frac{\text{meter}}{\cancel{\text{day}}} * 3 ~ \cancel{\text{days}}$$
will work
Upvotes: 3
Reputation: 26833
For PDF output you can use the LaTeX style cancel
:
---
header-includes: \usepackage[makeroom]{cancel}
output: pdf_document
---
$$ 2 \frac{\text{meter}}{\cancel{\text{day}}} * 3 ~ \cancel{\text{days}} $$
Result:
Note that the usage of \text
is unrelated to your question and only used for typographical reasons.
Unfortunately this does not work with HTML output.
Upvotes: 3