as.latex("See what is added by as.latex", label = "a label",
inline = FALSE, count = TRUE)
### Run this example to see what is written to the file
## Not run:
# ### An inline expression will be written to standard output as is
# ### Note that the backslashes remain duplicated in this case
# ### I think this is due to a line of code in hwriter::hwriteString
# ### if (is.null(page)) txt
# ### which writes the txt literally rather than using cat
# hwrite("Here is an inline mathematical expression:
# `\int_{-\infty}^{1}f(x)dx`")
# ### The same expression but displayed
# hwriteLatex(as.latex("\int_{-\infty}^{1}f(x)dx",
# inline = FALSE, count = FALSE),
# table.attributes = "border = '1'",
# tr.attributes = "bgcolor = 'white'")
#
#
# ### The same example written to a file
# ### Create a temporary file first
# tmpDir <- tempdir()
# fileName <- file.path(tmpDir, 'hwriteLatex.html')
# ### Copy some necessary files
# cssDir <- file.path(system.file(package = 'hwriterPlus'), 'css')
# file.copy(file.path(cssDir, "BrowserExample.css"), tmpDir)
#
# ### Open file for writing
# p <- newPage(fileName,
# title = "Example of a Document for Display in a Browser",
# link.css = c("BrowserExample.css"))
# hwrite("Here is an inline mathematical expression:
# `\int_{-\infty}^{1}f(x)dx`", p, br)
# ### The same expression but displayed
# hwrite("Here is a displayed version of the same expression enclosed in a
# box", p, br)
# hwriteLatex(as.latex("\int_{-\infty}^{1}f(x)dx",
# inline = FALSE, count = FALSE),
# p,
# table.attributes = "border = '1'",
# tr.attributes = "bgcolor = 'white'")
# ### We can also have equation numbers and labels when writing to a file
# hwrite("Here is a different expression which has an equation number and
# assigned a label", p, br)
# hwriteLatex(as.latex("\{ 26.119 < \sum_{i=1}^n(X_i-\bar{X})^2\}
# \bigcup\ \{ 5.629 > \sum_{i=1}^n (X_i-\bar{X})^2 \}.",
# inline = FALSE, label = "anequationlabel"),
# page = p,
# tr.attributes = "bgcolor = 'gray'",
# td.attributes = c("width = '50'",
# "align = 'center' bgcolor = 'yellow'",
# "align = 'right' width = '50'"))
# closePage(p)
# ### Open a web browser and examine the resulting file
# if (interactive()) try(browseURL(fileName))
# ## End(Not run)
Run the code above in your browser using DataLab