File: flextable_to_rmd.Rd

package info (click to toggle)
r-cran-flextable 0.8.4-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,264 kB
  • sloc: sh: 15; makefile: 2
file content (136 lines) | stat: -rw-r--r-- 5,119 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
% Generated by roxygen2: do not edit by hand
% Please edit documentation in R/printers.R
\name{flextable_to_rmd}
\alias{flextable_to_rmd}
\title{flextable raw code}
\usage{
flextable_to_rmd(
  x,
  ft.align = opts_current$get("ft.align"),
  ft.split = opts_current$get("ft.split"),
  ft.keepnext = opts_current$get("ft.keepnext"),
  ft.tabcolsep = opts_current$get("ft.tabcolsep"),
  ft.arraystretch = opts_current$get("ft.arraystretch"),
  ft.latex.float = mcoalesce_options(opts_current$get("ft.latex.float"),
    opts_current$get("ft-latex-float")),
  ft.left = opts_current$get("ft.left"),
  ft.top = opts_current$get("ft.top"),
  text_after = "",
  webshot = opts_current$get("webshot"),
  ft.htmlscroll = opts_current$get("ft.htmlscroll"),
  ft.shadow = opts_current$get("ft.shadow"),
  bookdown = FALSE,
  quarto = FALSE,
  pandoc2 = TRUE,
  print = TRUE,
  ...
)
}
\arguments{
\item{x}{a flextable object}

\item{ft.align}{flextable alignment, supported values are 'left', 'center' and 'right'.}

\item{ft.split}{Word option 'Allow row to break across pages' can be
activated when TRUE.}

\item{ft.keepnext}{default \code{FALSE}. Word option 'keep rows
together' is activated when TRUE. It avoids page break
within tables. This is handy for small tables, i.e. less than
a page height.

Be careful, if you print long tables, you should
rather set its value to \code{FALSE} to avoid that the tables
also generate a page break before being placed in the
Word document. Since Word will try to keep it with the \strong{next
paragraphs that follow the tables}.}

\item{ft.tabcolsep}{space between the text and the left/right border of its containing
cell, the default value is 0 points.}

\item{ft.arraystretch}{height of each row relative to its default
height, the default value is 1.5.}

\item{ft.latex.float}{type of floating placement in the document, one of:
\itemize{
\item 'none' (the default value), table is placed after the preceding
paragraph.
\item 'float', table can float to a place in the text where it fits best
\item 'wrap-r', wrap text around the table positioned to the right side of the text
\item 'wrap-l', wrap text around the table positioned to the left side of the text
\item 'wrap-i', wrap text around the table positioned inside edge-near the binding
\item 'wrap-o', wrap text around the table positioned outside edge-far from the binding
}}

\item{ft.left, ft.top}{Position should be defined with options \code{ft.left}
and \code{ft.top}. Theses are the top left coordinates in inches
of the placeholder that will contain the table. Their
default values are 1 and 2 inches.}

\item{text_after}{The string you put here will be added after printing the content of the flextable.
For example, you can put "\\\\pagebreak" here to have tables produced with page breaks.}

\item{webshot}{webshot package as a scalar character, one of "webshot" or
"webshot2".}

\item{ft.htmlscroll}{\code{TRUE} or \code{FALSE} (default) to enable horizontal scrolling.}

\item{ft.shadow}{\code{TRUE} (default) or \code{FALSE} to use shadow dom (for HTML only), this option is existing
to disable shadow dom (set to \code{FALSE}) for pagedown and Quarto that can
not support it for now.}

\item{bookdown}{\code{TRUE} or \code{FALSE} (default) to support cross referencing with bookdown.}

\item{quarto}{\code{TRUE} or \code{FALSE} (default) to indicate the source document is a 'Quarto'
file (ending with \verb{*.qmd}).}

\item{pandoc2}{\code{TRUE} (default) or \code{FALSE} to get the string in a pandoc raw HTML attribute
(only valid when pandoc version is \verb{>= 2}.}

\item{print}{print output if TRUE}

\item{...}{unused arguments}
}
\description{
Print openxml, latex or html code of a
flextable. The function is particularly useful when you want
to generate flextable in a loop from a R Markdown document.

Inside R Markdown document, chunk option \code{results} must be
set to 'asis'.

All arguments whose name starts with \code{ft.} can be set in the chunk options.

See \link{knit_print.flextable} for more details.
}
\examples{
demo_loop <- system.file(package = "flextable", "examples/rmd", "loop_with_flextable.Rmd")
rmd_file <- tempfile(fileext = ".Rmd")
file.copy(demo_loop, to = rmd_file, overwrite = TRUE)
rmd_file # R Markdown document used for demo
if (require("rmarkdown", quietly = TRUE)) {
  #  render(input = rmd_file, output_format = "word_document",
  #    output_file = "loop_with_flextable.docx")
  #  render(input = rmd_file, output_format = "html_document",
  #    output_file = "loop_with_flextable.html")
  #  render(input = rmd_file,
  #    output_format = rmarkdown::pdf_document(latex_engine = "xelatex"),
  #    output_file = "loop_with_flextable.pdf")
}

}
\seealso{
Other flextable print function: 
\code{\link{as_raster}()},
\code{\link{df_printer}()},
\code{\link{gen_grob}()},
\code{\link{htmltools_value}()},
\code{\link{knit_print.flextable}()},
\code{\link{plot.flextable}()},
\code{\link{print.flextable}()},
\code{\link{save_as_docx}()},
\code{\link{save_as_html}()},
\code{\link{save_as_image}()},
\code{\link{save_as_pptx}()}
}
\concept{flextable print function}