Skip to content

Commit

Permalink
option control on height & width in body_add_gg2()
Browse files Browse the repository at this point in the history
fixes #68
  • Loading branch information
DanChaltiel committed Aug 12, 2024
1 parent dc01461 commit 1919e69
Show file tree
Hide file tree
Showing 5 changed files with 12 additions and 3 deletions.
1 change: 1 addition & 0 deletions NEWS.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ Crosstables for descriptive analyses. See documentation at <https://danchaltiel.
- Moved the legend above the table in `body_add_table_section()` (#73).
- Fixed `get_label()` on named vector columns (#72).
- Fixed `crosstable(drop_levels)` (#69, #70, #71).
- Option control on height & width in `body_add_gg2()` (#68).
- Flextable autofit now uses the recommended method (#62).
- Fixed a bug happening when NA is already a level (#59).
- Fixed error where `by` contains "label" (#56).
Expand Down
4 changes: 3 additions & 1 deletion R/officer.R
Original file line number Diff line number Diff line change
Expand Up @@ -682,7 +682,9 @@ body_add_img2 = function(doc, src, width, height,
#' body_add_gg2(p, w=14, h=10, scale=1.5) %>% #or units="cm" instead of using options
#' body_add_normal("Text after")
#' write_and_open(doc)
body_add_gg2 = function(doc, value, width = 6, height = 5,
body_add_gg2 = function(doc, value,
width = getOption("crosstable_gg_width", 6),
height = getOption("crosstable_gg_height", 5),
units = getOption("crosstable_units", "in"),
style = getOption("crosstable_style_image", doc$default_styles$paragraph),
res = 300, ... ){
Expand Down
2 changes: 2 additions & 0 deletions R/options.R
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@
#' @param normal_squish Should you squish text in normal paragraphs?
#' @param title_squish Should you squish text in headers paragraphs?
#' @param allow_break allow crosstable rows to break across pages
#' @param gg_width,gg_height cf. [body_add_gg2()]
#' @param section_title,section_title_level,section_sentence cf. [body_add_table_section()]
#' @param style_normal For specifying styles used in your `{officer}` template.
#' @param style_image For specifying styles used in your `{officer}` template.
Expand Down Expand Up @@ -100,6 +101,7 @@ crosstable_options = function(
peek_docx=TRUE,
font_code="Consolas",
add_max_cols=25,
gg_width, gg_height,
format_legend_name,
table_legend_par_before,
table_legend_prefix,
Expand Down
4 changes: 2 additions & 2 deletions man/body_add_gg2.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions man/crosstable_options.Rd

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit 1919e69

Please sign in to comment.