This function is used to insert equations into flextable.
It is used to add it to the content of a cell of the flextable with the functions compose()
, append_chunks()
or prepend_chunks()
.
To use this function, package 'equatags' is required; also equatags::mathjax_install()
must be executed only once to install necessary dependencies.
as_equation(x, width = 1, height = 0.2, unit = "in", props = NULL)
Arguments
values containing the 'MathJax' equations
size of the resulting equation
unit for width and height, one of "in", "cm", "mm".
an fp_text_default()
or officer::fp_text()
object to be used to format the text. If not specified, it will be the default value corresponding to the cell.
Other chunk elements for paragraph: as_b()
, as_bracket()
, as_chunk()
, as_highlight()
, as_i()
, as_image()
, as_sub()
, as_sup()
, as_word_field()
, colorize()
, gg_chunk()
, grid_chunk()
, hyperlink_text()
, linerange()
, minibar()
, plot_chunk()
library(flextable)
if (require("equatags")) {
eqs <- c(
"(ax^2 + bx + c = 0)",
"a \\ne 0",
"x = {-b \\pm \\sqrt{b^2-4ac} \\over 2a}"
)
df <- data.frame(formula = eqs)
df
ft <- flextable(df)
ft <- compose(
x = ft, j = "formula",
value = as_paragraph(as_equation(formula, width = 2, height = .5))
)
ft <- align(ft, align = "center", part = "all")
ft <- width(ft, width = 2)
ft
}
#> Loading required package: equatags
formula
(
a
x2
+
b
x
+
c
=
0
)
(ax^2 + bx + c = 0)
(ax2+bx+c=0)
a
≠
0
a \ne 0
a=0
x
=
−
b
±
b2
−
4
a
c
2
a
x = {-b \pm \sqrt{b^2-4ac} \over 2a}
x=2a−b±b2−4ac
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4