Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ asar::create_template(
species = "Petrale sole",
spp_latin = "Eopsetta jordani",
year = 2023,
author = c("Ian G. Taylor"="NWFSC", "Vladlena Gertseva"="NWFSC", "Nick Tolimieri"="NWFSC"),
authors = c("Ian G. Taylor"="NWFSC", "Vladlena Gertseva"="NWFSC", "Nick Tolimieri"="NWFSC"),
include_affiliation = TRUE,
simple_affiliation = FALSE,
param_names = c("nf","sf"),
Expand Down
132 changes: 64 additions & 68 deletions inst/templates/safe/01c_plan-team.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -5,29 +5,33 @@
```{r}
#| eval: false
#| echo: false
# install.packages("devtools")
# devtools::install_github("BenWilliams-NOAA/safe")

year <- format(Sys.time(), "%Y")

ptdata <- safe::ptdata

flextable::font(
flextable::footnote(flextable::flextable(ptdata),
j = 3, part = "header", ref_symbols = "1",
value = flextable::as_paragraph("Total biomass (age 4+) estimates from age-structured model.")
),
fontname = "Times New Roman",
part = "all"
) %>%
flextable::footnote(
i = 2, j = 7, part = "body", ref_symbols = "2",
value = flextable::as_paragraph(
flextable::as_chunk(paste0(paste0("Current as of ", date, " . Source: NMFS Alaska Regional Office Catch Accounting System
via the AKFIN database (http://www.akfin.org).")))
)
) %>%
flextable::set_formatter(Year = function(x) sprintf("%s", x)) %>%
flextable::merge_at(i = 1:4, j = 1) %>%
flextable::hrule(rule = "exact") %>%
flextable::hline_top(part = "all") %>%
flextable::hline_bottom() %>%
flextable::fix_border_issues()
ptdata |>
gt::gt() |>
gt::tab_footnote(
footnote = "Total biomass (age 4+) estimates from age-structured model.",
locations = gt::cells_column_labels(columns = Biomass)
) |>
gt::tab_footnote(
footnote = paste0("Current as of ", year, ". Source: NMFS Alaska Regional Office Catch Accounting System
via the AKFIN database (http://www.akfin.org)."),
locations = cells_column_labels(columns = Catch)
) |>
gt::fmt_integer(columns = Year, sep_mark = "") |>
gt::fmt_integer(columns = Biomass:Catch, sep_mark = ",") |>
gt::tab_options(
column_labels.font.weight = "bold",
table_body.hlines.style = "none"
) |>
gt::sub_missing(
missing_text = ""
)
```

{{< pagebreak >}}
Expand All @@ -37,51 +41,43 @@ via the AKFIN database (http://www.akfin.org).")))
#| echo: false
ptdata2 <- safe::ptdata2

flextable::font(
flextable::footnote(flextable::flextable(ptdata2[-1, ]),
j = 6, part = "header", ref_symbols = "2",
value = flextable::as_paragraph(flextable::as_chunk(
paste0(paste0(
"Current as of ", date,
" . Source: NMFS Alaska Regional Office Catch Accounting System
via the AKFIN database (http://www.akfin.org)."
))
))
),
fontname = "Times New Roman",
part = "all"
) %>%
flextable::add_header(values = ptdata2[1, ]) %>%
flextable::border_remove() %>%
flextable::merge_at(j = 1) %>%
flextable::compose(
i = 1, j = 3:6,
value = flextable::as_paragraph(as.character(year - 1)),
part = "header"
) %>%
flextable::compose(
i = 1, j = 7:8,
value = flextable::as_paragraph(as.character(year)),
part = "header"
) %>%
flextable::compose(
i = 1, j = 9:10,
value = flextable::as_paragraph(as.character(year + 1)),
part = "header"
) %>%
flextable::merge_at(i = 1, j = 3:6, part = "header") %>%
flextable::merge_at(i = 1, j = 7:8, part = "header") %>%
flextable::merge_at(i = 1, j = 9:10, part = "header") %>%
flextable::align(i = 1, part = "header", align = "center") %>%
flextable::compose(
i = 2, j = 7:10,
value = flextable::as_paragraph(rep(c("ABC", "OFL"), 2)),
part = "header"
) %>%
flextable::hline_top(part = "body") %>%
flextable::hline_top(part = "header") %>%
flextable::vline(j = c(2, 6, 8)) %>%
flextable::hline_bottom(part = "body") %>%
flextable::fix_border_issues(part = "all") %>%
flextable::set_table_properties(width = .5, layout = "autofit")
year <- format(Sys.time(), "%Y")
date <- Sys.Date()

yr_prev <- ptdata2[1, 3] # "2021"
yr_curr <- ptdata2[1, 7] # "2022"
yr_next <- ptdata2[1, 9] # "2023"

ptdata2[-1, ] |>
gt::gt() |>
gt::tab_options(
column_labels.font.weight = "bold",
table_body.hlines.style = "none"
) |>
gt::cols_label(
OFL = paste(yr_prev, "OFL"),
ABC = paste(yr_prev, "ABC"),
TAC = paste(yr_prev, "TAC"),
Catch = paste(yr_prev, "Catch"),
OFL.1 = paste(yr_curr, "ABC"),
ABC.1 = paste(yr_curr, "OFL"),
OFL.2 = paste(yr_next, "ABC"),
ABC.2 = paste(yr_next, "OFL")
) |>
gt::tab_footnote(
footnote = paste0("Current as of ", date, ". Source: NMFS Alaska Regional Office Catch Accounting System via the AKFIN database (http://www.akfin.org)."),
locations = cells_column_labels(columns = 6)
) |>
gt::fmt_integer() |>
gt::cols_align(align = "center", columns = 3:10) |>
gt::cols_align(align = "left", columns = 1:2) |>
gt::sub_missing(
missing_text = ""
) |>
gt::tab_style(
style = cell_borders(sides = "right", color = "mediumgrey", weight = px(2)),
locations = list(
cells_body(columns = c(6, 8)),
cells_column_labels(columns = c(6, 8))
) )
```
15 changes: 6 additions & 9 deletions inst/templates/safe/05_data.qmd
Original file line number Diff line number Diff line change
Expand Up @@ -32,15 +32,12 @@ data.frame(
"1991-1997, 2003, 2007, 2009, 2011, 2013, 2015, 2017, 2019"
)
) |>
flextable::flextable() |>
flextable::width(j = ~Source, width = 1) |>
flextable::width(j = ~Data, width = 1.5) |>
flextable::width(j = ~Years, width = 4) |>
flextable::merge_v(j = 1) |>
flextable::font(fontname = "Times", part = "all") |>
flextable::fontsize(size = 10) |>
flextable::theme_vanilla() |>
flextable::fix_border_issues()
gt::gt() |>
gt::cols_width(
Source ~ px(100),
Data ~ px(150),
Years ~ px(400)
)
```

## Fishery
Expand Down
2 changes: 2 additions & 0 deletions vignettes/accessibility_guide.Rmd
Original file line number Diff line number Diff line change
Expand Up @@ -185,6 +185,8 @@ recruitment_alt_text <- new_alt_text

3. As stated earlier, if you see text that looks like a placeholder (e.g., "The x axis, showing the year, spans from B.start.year to B.end.year..."), that means that there was at least one instance where our tool failed to extract a specific value from the model results and substitute it into the placeholder. Please make sure that your alt text and captions contain the expected values before moving forward with your report. Check out the inst/resources/captions_alt_text_template.csv file in the `stockplotr` package to view the template with placeholders. The same package's `write_captions()` function shows how values are extracted from the model results and substituted into the placeholders.

4. If you add a special character (e.g., percentage sign (%) or dollar sign ($); see [full list on this wiki page](https://en.wikibooks.org/wiki/LaTeX/Special_Characters#Other_symbols)), please add two backslashes before the character to avoid issues compiling your report later on (specifically, the conversion from Quarto to LaTeX via Pandoc, and then compilation of the LaTeX report after running `add_accessibility()` or `add_alttext()`). For example, "The 95% CI" would be written as "The 95\\\\% CI".

### More resources

Looking for more resources for writing alt text? Check out the [NOAA Library's website for creating accessible documents](https://library.noaa.gov/Section508/CreatingDocs).
Expand Down
Loading