Skip to content

Commit

Permalink
fix underbrace copy
Browse files Browse the repository at this point in the history
  • Loading branch information
philchalmers committed Nov 22, 2024
1 parent 838754a commit 5478c1f
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions dev/under-over.R
Original file line number Diff line number Diff line change
Expand Up @@ -75,7 +75,7 @@ underbrace <- function(x,
)
{
if(is.matrix(x)) x <- latexMatrix(x)
res <- paste0("\\overbrace{",
res <- paste0("\\underbrace{",
ifelse(inherits(x, 'latexMatrix'), getLatex(x), x),
"}")
if (!is.null(label)) {
Expand Down Expand Up @@ -115,10 +115,12 @@ if (FALSE) {
Eqn(Lambda)
# fails miserably
Eqn(overset(Lambda, "\\Lambda"))
Eqn(underset(Lambda, "\\Lambda"))

# over/underbrace

Eqn(overbrace(A, "A"))
Eqn(underbrace(A, "A"))

# data(dogfood, package = "heplots") -- not yet on CRAN
load(here::here("dev", "dogfood.RData"))
Expand Down Expand Up @@ -169,10 +171,10 @@ if (FALSE) {
## -------Underbrace:
# I want to generate the equation \hat{y} = X (X'X)^{-1} X' y with a brace underneath showing the H matrix
# This manual LaTeX works:
eqn <- "
\mathbf{\hat{y}}
= \underbrace{\mathbf{X}(\mathbf{X}^{\top}\mathbf{X})^{-1}\mathbf{X}^{\top}}_\mathbf{H}\mathbf{y}
"
# eqn <- "
# \mathbf{\hat{y}}
# = \underbrace{\mathbf{X}(\mathbf{X}^{\top}\mathbf{X})^{-1}\mathbf{X}^{\top}}_\mathbf{H}\mathbf{y}
# "

# generate this with underbrace()
H <- "\\mathbf{X}(\\mathbf{X}^{\\top}\\mathbf{X})^{-1}\\mathbf{X}^{\\top}"
Expand Down

0 comments on commit 5478c1f

Please sign in to comment.