A function to set some options for the report. The options include the ability to control features such as auto line breaking, auto pagination, and auto page wrapping. These features are normally on by default, but sometimes it is desirable to turn them off. For RTF, it provides options for allowing users to insert RTF code and decide the structure of titles.

report_options(
  x,
  allow_code = FALSE,
  line_break = TRUE,
  line_count = NULL,
  page_wrap = TRUE,
  auto_page = TRUE,
  title_block = "table"
)

Arguments

x

The report spec object.

allow_code

Whether to allow the user to insert custom code into the report. Currently applies only to RTF outputs. Default is FALSE. When TRUE, users can insert RTF code in the data, titles, or footnotes. To insert curly braces, double them so as to not interfere with the glue functionality, which uses single curly braces as an escape.

line_break

Whether to use auto line breaking. Default is TRUE. This option applies to RTF, DOCX, and HTML only. When "line_break" is FALSE, the rendering will not insert a line break code at the end of a line, and instead let the editor wrap the line as needed.

line_count

The number of lines that will fit on page. Normally, the line_count is calculated automatically. You can override the calculated value by setting the line_count directly.

page_wrap

By default, columns that exceed the available width of the page will be wrapped to a new page. The "page_wrap" parameter allows you to turn this feature off for the entire report. Default is TRUE. A "page_wrap" parameter has also been added to the create_table function, so that page wrapping may be controlled at the table level. The table level setting will override the report level setting. Note that turning off page wrapping may cause the report content to exceed the margins.

auto_page

By default, when there are too many lines to fit on a page, a new page will be automatically created. Sometimes it is desirable to turn this feature off. The "auto_page" parameter allows you to turn automatic page breaking off for the entire report. There is a corresponding parameter in create_table that allows you to control page breaking at a table level. The table setting will override the report setting. When a `page_break` variable is set in the define function, you can set `auto_page` to FALSE to let reporter follow the paging variable without any auto paging. Note that turning off auto pagination may cause page overflows.

title_block

To decide whether the structure of titles is "table" or "paragraph". Default is "table". Applies only to RTF. The "paragraph" structure is useful on some editors which do not render the table title block appropriately. Note that if the "paragraph" setting is applied, some features of the titles function may not work as expected.

Value

The report_spec with option settings.

Examples

library(reporter)
library(magrittr)

# Create a temporary file
tmp <- file.path(tempdir(), "bod.rtf")

# Define table
tbl <- create_table(BOD, width = 2.5) %>% 
  titles("Table 3.6", "BOD¹ Sample Report") %>% 
  define(Time, format = "Day %s", align = "left") %>% 
  define(demand, format = "%2.1f mg/l", label = "Demand") %>% 
  footnotes("¹ Biochemical Oxygen Demand")
       
# Define report #1 - No blank margins
rpt <- create_report(tmp, orientation="portrait", output_type = "RTF",
                     font = "Arial", font_size = 9) %>%
  add_content(tbl) %>%
  report_options(allow_code = TRUE, line_break = FALSE, 
                 auto_page = FALSE,page_wrap = FALSE, 
                 title_block = "paragraph")

# Write the report
write_report(rpt)