A pot
object (pieces of text or paragraph of text) is made of one or more chunk of text with different formatting properties.
ReporteRs provide a class of object to enable text formatting: pot
objects.
pot
objects are created with function pot
. These objects can be concatenated: an object can be added with another pot object or with a single text value (a character vector of length 1).
A pot
object is a set of text chunks, each chunk is associated with its own font properties. A Footnote and an hyperlink can be associated to a pot
object.
When \\n
is used, a soft return is used.
These objects are to be used when adding paragraphs into a document or when working with FlexTable.
pot('Hello World!')
Hello World!
Hello World!
Cats and dogs
The function pot has two arguments:
The following code show usage of these parameters:
font.size = 20, font.weight = 'bold', font.family = 'Courier New' )
' is rich. ' +
' and ' +
my_text
My tailor is rich. Cats and dogs
add paragraphs
mydoc = docx( )
It produces this document.
add into FlexTable
MyFTable[1,1, to = 'footer'] = my_text
MyFTable
|
mpg |
cyl |
disp |
hp |
drat |
wt |
qsec |
vs |
am |
gear |
carb |
Mazda RX4 |
21.0 |
6 |
160 |
110 |
3.90 |
2.620 |
16.46 |
0 |
1 |
4 |
4 |
Mazda RX4 Wag |
21.0 |
6 |
160 |
110 |
3.90 |
2.875 |
17.02 |
0 |
1 |
4 |
4 |
Datsun 710 |
22.8 |
4 |
108 |
93 |
3.85 |
2.320 |
18.61 |
1 |
1 |
4 |
1 |
Hornet 4 Drive |
21.4 |
6 |
258 |
110 |
3.08 |
3.215 |
19.44 |
1 |
0 |
3 |
1 |
Hornet Sportabout |
18.7 |
8 |
360 |
175 |
3.15 |
3.440 |
17.02 |
0 |
0 |
3 |
2 |
My tailor is rich. Cats and dogs |
Hyperlink can be added to pot objects.
Use argument hyperlink
with function pot
.
Here is an example:
pot_img
have been implemented to let you arrange text (pot
) and images(pot_img
) into a paragraph.
img.file <- file.path( Sys.getenv("R_HOME"), "doc", "html", "logo.jpg" )
mypot <- "This paragraph mix an image and text into a paragraph: " + pot_img(filename = img.file, width = .3, height = .3) + pot( '4Cats', textBoldItalic( color = '#428BCA', underline = TRUE ) )
mypot
This paragraph mix an image and text into a paragraph: 4Cats
MyFTable[1,1, to = "header"] <- mypot
MyFTable
This paragraph mix an image and text into a paragraph: 4Cats |
mpg |
cyl |
disp |
hp |
drat |
wt |
qsec |
vs |
am |
gear |
carb |
Mazda RX4 |
21.0 |
6 |
160 |
110 |
3.90 |
2.620 |
16.46 |
0 |
1 |
4 |
4 |
Mazda RX4 Wag |
21.0 |
6 |
160 |
110 |
3.90 |
2.875 |
17.02 |
0 |
1 |
4 |
4 |
Datsun 710 |
22.8 |
4 |
108 |
93 |
3.85 |
2.320 |
18.61 |
1 |
1 |
4 |
1 |
Hornet 4 Drive |
21.4 |
6 |
258 |
110 |
3.08 |
3.215 |
19.44 |
1 |
0 |
3 |
1 |
Hornet Sportabout |
18.7 |
8 |
360 |
175 |
3.15 |
3.440 |
17.02 |
0 |
0 |
3 |
2 |
This feature is not available when working with pptx
object (and you can’t mix text and images in PowerPoint).
Footnotes can be added to pot objects.
Use objects of class Footnote
to create a Footnote. Function pot
has an argument footnote
to specify which Footnote to use. If missing, no footnote will be added.
Footnote are not supported within PowerPoint documents.