metrumresearchgroup / pmtables

TeX tables for pharmacometrics.
https://metrumresearchgroup.github.io/pmt-book
11 stars 1 forks source link

Better caption handling for preview and tex files #313

Closed kylebaron closed 11 months ago

kylebaron commented 12 months ago

Big picture

Details

Example

library(dplyr)
#> 
#> Attaching package: 'dplyr'
#> The following objects are masked from 'package:stats':
#> 
#>     filter, lag
#> The following objects are masked from 'package:base':
#> 
#>     intersect, setdiff, setequal, union
library(pmtables)

a <-
  stdata() %>%
  st_new() %>%
  st_caption(
    "[Short title]. Main caption text. \\label{tab::example}",
    write = TRUE
  ) %>% stable()

stable_save(a, file = "foo.tex", dir = "~/")

readLines("~/foo.tex")[1]
#> [1] "\\caption[Short title]{Short title. Main caption text. \\label{tab::example}}"

b <-
  stdata() %>%
  st_new() %>%
  st_caption(
    "[Final Model: Population simulations for every 4 week dosing in adults].
    Covariates from the adult analysis population were resampled with
    replacement to a population of N=1,000 and used to simulate
    PK for the following regimen: 50 mg IV every 4 weeks.
    Subject-level variability, but not interoccasion or residual error,
    was included in the simulations. Summary statistics for pre-dose
    concentration and average concentration at steady state were calculated
    across all 1,000 resampled patients. \\label{tab:pop-sims-adult}"
  ) %>% stable_long()

c <-
  stdata() %>%
  st_new() %>%
  st_caption(
    "Full Model: Final model parameter estimates\\label{tab:param}",
    short = "Full Model Estimates", short_repeat = FALSE
  ) %>% stable_long()

st2report(list(a,b,c), ntex = 2, output_dir = "~/")

Created on 2023-07-14 with reprex v2.0.2 view-st2report.pdf