-
-
Notifications
You must be signed in to change notification settings - Fork 148
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
capturing show footnote on every page in a clean pull
- Loading branch information
bd-karen-byron
committed
Nov 2, 2024
1 parent
ad8280b
commit 0806c62
Showing
4 changed files
with
168 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,58 @@ | ||
--- | ||
title: "footnote_perm" | ||
author: "Byron" | ||
date: "9/11/2024" | ||
output: pdf_document | ||
--- | ||
|
||
```{r setup, include=FALSE} | ||
knitr::opts_chunk$set(echo = !TRUE) | ||
devtools::load_all() | ||
# library(kableExtra) | ||
dat <- data.frame( | ||
Col1 = LETTERS[rep(1:26, each = 2)], | ||
Col2 = letters[rep(1:26, 2)], | ||
n = 0:51 | ||
) | ||
# "\\tnote{1} is TPT only | ||
names(dat)[3] <- paste0(names(dat)[3], footnote_marker_number(1)) | ||
``` | ||
|
||
|
||
```{r permute, results='asis'} | ||
# Define new environment | ||
latex_opt <- c("basic", "repeat_header") # test basic to show doesn't cause trouble | ||
is_bt <- c(FALSE, TRUE) | ||
is_tpt <- c(FALSE, TRUE) | ||
is_cont_at_btm <- c(FALSE, TRUE) # only shows for booktabs | ||
is_every <- c(FALSE, TRUE) | ||
child_env <- new.env() | ||
for(i_latex_opt in seq_along(latex_opt)){ | ||
for(i_bt in seq_along(is_bt)){ | ||
for(i_tpt in seq_along(is_tpt)){ | ||
for(i_is_cont_at_btm in seq_along(is_cont_at_btm)){ | ||
for(i_every in seq_along(is_every)){ | ||
child_env$i_latex_opt <- i_latex_opt | ||
child_env$i_bt <- i_bt | ||
child_env$i_tpt <- i_tpt | ||
child_env$i_is_cont_at_btm <- i_is_cont_at_btm | ||
child_env$i_every <- i_every | ||
# knit the document and save the character output to an object | ||
res <- knitr::knit_child( | ||
"footnote_latex_perm_child.Rmd", | ||
envir = child_env, | ||
quiet = TRUE | ||
) | ||
# Cat the object to make it render in your main document | ||
cat(res, sep = "\n") | ||
} | ||
} | ||
} | ||
} | ||
} | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
--- | ||
output: | ||
pdf_document | ||
--- | ||
```{r results='asis'} | ||
# i_latex_opt <- i_bt <- i_tpt <- i_is_cont_at_btm <- i_every <- 2 | ||
use_lab <- paste("lab", i_latex_opt, i_bt, i_tpt, | ||
i_is_cont_at_btm, i_every, sep = "-") | ||
``` | ||
|
||
### `r use_lab` | ||
Permutations | ||
\vspace{-10pt} | ||
|
||
* latex option: `r latex_opt[i_latex_opt]` | ||
* booktab: `r is_bt[i_bt]` | ||
* TPT: `r is_tpt[i_tpt]` | ||
* continue on bottom: `r is_cont_at_btm[i_is_cont_at_btm]` | ||
* every page: `r is_every[i_every]` | ||
|
||
|
||
```{r results='asis'} | ||
dat |> | ||
kbl(format = "latex", caption = "Table caption", | ||
label = use_lab, escape = FALSE, | ||
booktabs = is_bt[i_bt], longtable = TRUE) |> | ||
kable_styling( | ||
latex_options = latex_opt[i_latex_opt], | ||
repeat_header_continued = is_cont_at_btm[i_is_cont_at_btm]) |> | ||
footnote( | ||
number = c("footnote on colname"), | ||
threeparttable = is_tpt[i_tpt], | ||
show_every_page = is_every[i_every]) | ||
``` | ||
|
||
\clearpage |