internal link in pdf report

Pdf report with summary and detail pages. First page is a summary page about performance of cars with cylinders, say 4, 6, 8. Is it possible to have 4, 6, 8 as a internal link and jump to desired detail page when click on Cylinders column on the first page display table? Thanks,


title: ''
geometry: margin=2cm
output:
pdf_document:
latex_engine: xelatex
urlcolor: blue
classoption: landscape

knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(tidyverse)
library(knitr)
library(kableExtra)
library(data.table)
test <- mtcars
setDT(test, keep.rownames = TRUE[])
test1 <- test %>% arrange(cyl)
pgm <- test1 %>% select(cyl,mpg)
cylsum <- test1 %>% group_by(cyl) %>%  
  summarise(n=n(),
  max_mpg=max(mpg),
  min_mpg=min(mpg),
  mean_mpg=mean(mpg))

Summary Report: Mileage Per Gallons vs Cylinders

carsub <- cylsum %>% 
select(
  "Cylinders"=cyl,
  "Number of Rows"=n,
  "Max Mileage Per Gallon"=max_mpg,
  "Min Mileage Per Gallon"=min_mpg,
  "Average Mileage Per Gallon"=mean_mpg
  )  
carsub %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                      column_spec(2:4,width="1.8cm")%>%
                      column_spec(5,border_right = TRUE)%>%
                      kable_styling("bordered", font_size = 16)
cat("\n\n\\pagebreak\n")

Detail Report for Cylinder 4

pg2 <- test1 %>% filter(cyl==4) 
pg2 %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                  column_spec(12,border_right = TRUE)%>%
                  kable_styling("bordered", font_size = 11)
cat("\n\n\\pagebreak\n")

Detail Report for Cylinder 6

pg3 <- test1 %>% filter(cyl==6) 
pg3 %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                  column_spec(12,border_right = TRUE)%>%
                  kable_styling("bordered", font_size = 11)
cat("\n\n\\pagebreak\n")

Detail Report for Cylinder 8

pg4 <- test1 %>% filter(cyl==8)
pg4 %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                  column_spec(12,border_right = TRUE)%>%
                  kable_styling("bordered", font_size = 11)
cat("\n\n\\pagebreak\n")
```

Hi @tjcnnl1,

I wasn't able to use your specific example because it isn't a reprex. When pasting R Markdown content, place it inside 4 back-ticks to avoid the text being treated as literal markdown.

Here is an example that should get you started, let me know if you have any questions. Basically I created a table which includes hyperlink references to Table 1 and Table 2. Then, each table is given a unique label to refer to it by.

---
output: pdf_document
latex_engine: xelatex
extra_dependencies: [hyperref]
linkcolor: blue
---

Here is some text.

```{r}
library(tidyverse)
tibble::tribble(
  ~text, ~link,
  "First Table", "\\hyperref[tab:id1]{Table 1}",
  "Second Table", "\\hyperref[tab:id2]{Table 2}"
) %>% 
  knitr::kable(format = "latex", escape = FALSE)
```

\pagebreak

```{r}
mtcars %>% 
  head() %>% 
  knitr::kable(caption = "\\label{tab:id1} Here is my sweet caption for Table 1", escape = FALSE)
```

\pagebreak

```{r}
mtcars %>% 
  tail() %>% 
  knitr::kable(caption = "\\label{tab:id2} Here is my sweet caption for Table 2", escape = FALSE)
```
---
output: pdf_document
latex_engine: xelatex
extra_dependencies: [hyperref]
linkcolor: blue
---

Here is some text.

```{r}
library(tidyverse)
tibble::tribble(
  ~text, ~link,
  "First Table", "\\hyperref[tab:id1]{Table 1}",
  "Second Table", "\\hyperref[tab:id2]{Table 2}"
) %>% 
  knitr::kable(format = "latex", escape = FALSE)
```

\pagebreak

```{r}
mtcars %>% 
  head() %>% 
  knitr::kable(caption = "\\label{tab:id1} Here is my sweet caption for Table 1", escape = FALSE)
```

\pagebreak

```{r}
mtcars %>% 
  tail() %>% 
  knitr::kable(caption = "\\label{tab:id2} Here is my sweet caption for Table 2", escape = FALSE)
```

I am not good on R and thought you could copy/paste my R markdown code to your RStudio environment. Sorry, I don't know how to use reprex. Based on my code, would that be too much to ask step by step instructions to send my code that you are able to use? Thanks again!

Reprex just stands for reproducible example. It's just a short-hand way of describing whether or not someones post is easily reproducible by the person trying to help.

Your original post looks like it is close to being a reprex, you just need to edit the original post and put 4 back-ticks (usually found below the ESC key on the keyboard) in a line before the start of your R Markdown content, and 4 back-ticks after the last line.

This will keep the R Markdown as literal text and not try to format it as it if were standard markdown text in your post.

Putting 4 back-ticks before and after, as shown below, stops the content contained therein to be formatted on this website. Note, when you do this, you won't see the four back-ticks, I have purposefully made them visible for illustrative purposes.

````
---
title: ...
output: ...
---

# Header 1

```{r}
head(mtcars)
```
````

Got it. Hopefully, this post is easier for you to show jumping pages. Thanks a lots!

---
title: ''
geometry: margin=2cm
output:
  pdf_document: 
  latex_engine: xelatex
urlcolor: blue
classoption: landscape
---
Pdf report with summary and detail pages.  First page is a summary page about performance of cars with cylinders, say 4, 6, 8. Is it possible to have 4, 6, 8 as a internal link and jump to desired detail page when click on Cylinders column on the first page display table?
 
```{r prelim, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(tidyverse)
library(knitr)
library(kableExtra)
library(data.table)
```
```{r echo = FALSE}
test <- mtcars
setDT(test, keep.rownames = TRUE[])
test1 <- test %>% arrange(cyl)
pgm <- test1 %>% select(cyl,mpg)
cylsum <- test1 %>% group_by(cyl) %>%  
  summarise(n=n(),
  max_mpg=max(mpg),
  min_mpg=min(mpg),
  mean_mpg=mean(mpg))
```
**Summary Report:** Mileage Per Gallons vs Cylinders  
```{r echo = FALSE}
carsub <- cylsum %>% 
select(
  "Cylinders"=cyl,
  "Number of Rows"=n,
  "Max Mileage Per Gallon"=max_mpg,
  "Min Mileage Per Gallon"=min_mpg,
  "Average Mileage Per Gallon"=mean_mpg
  )  
carsub %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                      column_spec(2:4,width="1.8cm")%>%
                      column_spec(5,border_right = TRUE)%>%
                      kable_styling("bordered", font_size = 16)
```
```{r results='asis'}
cat("\n\n\\pagebreak\n")
```
**Detail Report for Cylinder 4**   
```{r echo = FALSE,results='asis'}
pg2 <- test1 %>% filter(cyl==4) 
pg2 %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                  column_spec(12,border_right = TRUE)%>%
                  kable_styling("bordered", font_size = 11)
cat("\n\n\\pagebreak\n")
```
**Detail Report for Cylinder 6**  
```{r echo = FALSE,results='asis'}
pg3 <- test1 %>% filter(cyl==6) 
pg3 %>% kable %>% column_spec(1, border_left = TRUE) %>% 
                  column_spec(12,border_right = TRUE)%>%
                  kable_styling("bordered", font_size = 11)
cat("\n\n\\pagebreak\n")
```


Try this:

---
title: ''
geometry: margin=2cm
output:
  pdf_document: 
    latex_engine: xelatex
linkcolor: blue
classoption: landscape
---

Pdf report with summary and detail pages.  First page is a summary page about performance of cars with cylinders, say 4, 6, 8. Is it possible to have 4, 6, 8 as a internal link and jump to desired detail page when click on Cylinders column on the first page display table?
 
```{r prelim, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(tidyverse)
library(knitr)
library(kableExtra)
library(data.table)
library(glue)
```

```{r echo = FALSE}
test <- mtcars
setDT(test, keep.rownames = TRUE[])
test1 <- test %>% arrange(cyl)
pgm <- test1 %>% select(cyl,mpg)
cylsum <- 
  test1 %>% group_by(cyl) %>%  
  summarise(n=n(),
  max_mpg=max(mpg),
  min_mpg=min(mpg),
  mean_mpg=mean(mpg))
```

**Summary Report:** Mileage Per Gallons vs Cylinders  

```{r echo = FALSE}
carsub <- cylsum %>% 
select(
  "Cylinders"=cyl,
  "Number of Rows"=n,
  "Max Mileage Per Gallon"=max_mpg,
  "Min Mileage Per Gallon"=min_mpg,
  "Average Mileage Per Gallon"=mean_mpg
  )  
carsub %>% 
  mutate(
    Cylinders = glue("\\hyperref[tab:cyl<<Cylinders>>]{<<Cylinders>>}",
                     .open = "<<", .close = ">>")
  ) %>% 
  kable(format = "latex", escape = FALSE) %>% 
  column_spec(1, border_left = TRUE) %>% 
  column_spec(2:4,width="1.8cm") %>%
  column_spec(5,border_right = TRUE) %>%
  kable_styling("bordered", font_size = 16)
```

\newpage

```{r echo=FALSE, results='asis'}
pg2 <- test1 %>% filter(cyl==4) 
pg2 %>% 
  kable(format = "latex", 
        caption = "\\label{tab:cyl4}Detail Report for Cylinder 4") %>% 
  column_spec(1, border_left = TRUE) %>%
  column_spec(12,border_right = TRUE) %>%
  kable_styling("bordered", font_size = 11, latex_options = "H")
```

\newpage

```{r echo=FALSE, results='asis'}
pg3 <- test1 %>% filter(cyl==6) 
pg3 %>% 
  kable(format = "latex", 
        caption = "\\label{tab:cyl6}Detail Report for Cylinder 6") %>% 
  column_spec(1, border_left = TRUE) %>%
  column_spec(12,border_right = TRUE) %>%
  kable_styling("bordered", font_size = 11, latex_options = "H")
```

\newpage

```{r echo=FALSE, results='asis'}
pg4 <- test1 %>% filter(cyl==8) 
pg4 %>% 
  kable(format = "latex", 
        caption = "\\label{tab:cyl8}Detail Report for Cylinder 8") %>% 
  column_spec(1, border_left = TRUE) %>%
  column_spec(12,border_right = TRUE) %>%
  kable_styling("bordered", font_size = 11, latex_options = "H")
```
1 Like

The page jumping function works perfect. Thank you so much! I need to get that page but keep the page layout without change. Here is the real code used in the report generation. I want to click on any row in description column, say math, and jump to math page. Again, thanks much

---
title: ''
geometry: margin=2cm
output:
  pdf_document: 
  latex_engine: xelatex
  html_document: default
  word_document: default
urlcolor: blue
classoption: landscape
---

```{r prelim, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(autodep = TRUE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)

library(glue)
library(dplyr)
library(tidyverse)
library(gridExtra)
library(ggplot2)
library(knitr)
library(kableExtra)
library(ggpubr)
library(cowplot)
```
```{r create_ds}
# summary page
sum_tbl <- data.frame(
  stringsAsFactors = FALSE,
  msr_cd = c("CAB-01", "CAB-03", "CAB-04", "CAB-05", "CAB-06"),
  Measure_Name = c("Math",
                   "Physics",
                   "Chemistry",
                   "English",
                   "Music"),
  Score = c(95.42, 94.737, 100, 0, 100),
  St_Score = c(92.1302549822323,
                     84.095435198563,92.1090387374462,4.98731673760695,93.7851163857356),
  Nat_Score = c(94.45295404814,
                   86.4454976303318,96,4.31482221334399,92.0296570898981),
  pctle = c(68, 86, 100, 100, 100)
) 
# trend plot
tre_tbl<-data.frame(
  stringsAsFactors = FALSE,
  YrQtr = c("2018Q3","2018Q3","2018Q4",
            "2018Q4","2019Q1","2019Q1","2019Q2",
            "2019Q2","2019Q3","2019Q3",
            "2019Q4","2019Q4","2020Q1","2020Q1",
            "2020Q2","2020Q2"),
  group = c("Rate_Qtrly","Rate_Qtrly_Cert",
            "Rate_Qtrly","Rate_Qtrly_Cert",
            "Rate_Qtrly","Rate_Qtrly_Cert",
            "Rate_Qtrly","Rate_Qtrly_Cert","Rate_Qtrly",
            "Rate_Qtrly_Cert","Rate_Qtrly",
            "Rate_Qtrly_Cert","Rate_Qtrly",
            "Rate_Qtrly_Cert","Rate_Qtrly",
            "Rate_Qtrly_Cert"),
  rate = c(100,99.445725764452,100,
           99.5072431551258,100,99.5243966883918,
           100,99.4535890039029,98.5915492957747,
           99.5167785234899,100,
           99.5289961730939,100,99.6394917190177,100,
           99.6281996281996)
)
# histogram 
his_tbl<-data.frame(
  Rate = c(99.669,99.487,100,100,99.475,99.452,
           100,100,98.028,100,100,99.153,99.577,100,99.785,99.433,
           100,100,99.441,100,98.778,99.56,100,99.446,100,99.234,
           100,99.281,99.177,98.936,99.048,100,96.154,100,99.718,
           99.481,99.765,99.811,100,100,100,100,97.544,99.457,
           100,100,97.611,97.17,99.752,97.99,97.674,100,100,99.888,
           100,99.419,100,99.76,100,99.754,100,99.287,97.273,
           98.381,99.476,100,99.389,100,99.802,99.559,100,99.842,
           100,100,100,99.438,100,99.855,99.769,100,100,99.707,100,
           99.718,100,97.877,100,100,99.816,98.725,100,100,
           99.378,100,99.825,99.512,99.827,99.677,100,98.983)
)
# data display
dp_tbl <- data.frame(
  stringsAsFactors = FALSE,
  Date_Range = c("2019Q3-2020Q2"),
  Rate = c(99.669),
  CountsByMeasure = c(1541L),
  Rate_Year_ST = c(99.5400919816037),
  Rate_Year_Cert = c(99.5730012435082),
  pctle = c(39)
)
```
\pagebreak

**School ID: ** School 12345, IL    
**Comparative Report:  Subject Scores for School with National and State Comparison**

```{r sumpg, echo=FALSE, results='asis'}
sum_tbl$new_msr_nm <- paste0(sum_tbl$msr_cd," - ",sum_tbl$Measure_Name)
sum_tblt <- sum_tbl %>% 
  select(
    "Subject Description"=new_msr_nm, 
    "School's Score"=Score, 
    "State Score"=St_Score,  
    "National Score"=Nat_Score,  
    "School Percentile"=pctle
  )
sum_tblt %>%
  kable(digits=1) %>% column_spec(1, width="11cm",border_left = TRUE) %>% 
  column_spec(2:4, width="1.8cm") %>%
  column_spec(5,width="1.8cm",border_right = TRUE)%>%
  kable_styling("bordered", font_size = 14)
cat("\n\\pagebreak\n")
```

**School ID: ** School 12345, IL       
**Subject Name: ** Math     
**Measure Description: ** Evaluation    
**Link to QI Resources:** <http://rmarkdown.rstudio.com>

```{r mathpg, echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) + 
    geom_point(size=3) +
    geom_line(size=2) + 
    xlab(" ") + ylab("Score (%)") +
    scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"), 
                        breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
                        labels=c("School Scores","National Scores")) +
    theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) + 
   geom_histogram(bins=50, fill="steelblue", color="white") +
   xlab("Score (%)") + ylab("School Reporting") +
   theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select( 
    "Reporting Period"=Date_Range,
    "School's Score"=Rate, 
    "Number of School Reporting"=CountsByMeasure, 
    "State Score"=Rate_Year_ST,
    "National Score"=Rate_Year_Cert,  
    "School Percentile"=pctle) 
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
              theme = ttheme("blank",
                             tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(10, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1)) 
cat("\n\\pagebreak\n")
```

**School ID: ** School 12345, IL       
**Subject Name: ** Physics  
**Measure Description: ** Evaluation  
**Link to QI Resources:** <http://rmarkdown.rstudio.com>

```{r phypg,echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) + 
    geom_point(size=3) +
    geom_line(size=2) + 
    xlab(" ") + ylab("Score (%)") +
    scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"), 
                        breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
                        labels=c("School Scores","National Scores")) +
    theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) + 
   geom_histogram(bins=50, fill="steelblue", color="white") +
   xlab("Score (%)") + ylab("School Reporting") +
   theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select( 
    "Reporting Period"=Date_Range,
    "School's Score"=Rate, 
    "Number of School Reporting"=CountsByMeasure, 
    "State Score"=Rate_Year_ST,
    "National Score"=Rate_Year_Cert,  
    "School Percentile"=pctle) 
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
              theme = ttheme("blank",
                             tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(5, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
cat("\n\\pagebreak\n")
```

**School ID: ** School 12345, IL       
**Subject Name: ** Chemistry  
**Measure Description: ** Evaluation  
**Link to QI Resources:** <http://rmarkdown.rstudio.com>

```{r chepg, echo=F,results='asis'}
o1 <- ggplot(tre_tbl, aes(y=rate, x=YrQtr, group=group, color=group)) + 
    geom_point(size=3) +
    geom_line(size=2) + 
    xlab(" ") + ylab("Score (%)") +
    scale_colour_manual(name=" ", values=c(Rate_Qtrly_Cert="orange",Rate_Qtrly="blue"), 
                        breaks=c("Rate_Qtrly","Rate_Qtrly_Cert"),
                        labels=c("School Scores","National Scores")) +
    theme(legend.position = "bottom", axis.text.x = element_text(angle=30, hjust=1, vjust=.5))
o2 <- ggplot(his_tbl,aes(x=Rate, y=..count..)) + 
   geom_histogram(bins=50, fill="steelblue", color="white") +
   xlab("Score (%)") + ylab("School Reporting") +
   theme(title=element_text(size=11,face='bold'))
orgwide <- dp_tbl %>% select( 
    "Reporting Period"=Date_Range,
    "School's Score"=Rate, 
    "Number of School Reporting"=CountsByMeasure, 
    "State Score"=Rate_Year_ST,
    "National Score"=Rate_Year_Cert,  
    "School Percentile"=pctle) 
orglong <- t(orgwide)
o3 <- ggtexttable(orglong, cols = NULL,
              theme = ttheme("blank",
                             tbody.style = c(hjust=1, x=0.9)))
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', rel_widths = c(10, 1), axis="l")
bottom_row <- plot_grid(o1, o2, align = 'h', rel_widths = c(1.5, 1.5), axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1)) 
```

I 've adopted your method to my work, but can't make it work as expected. Could you please help? Thanks in advance

---
title: ''
output:
  pdf_document: 
  latex_engine: xelatex
urlcolor: blue
classoption: landscape
---

```{r prelim, include=FALSE}
knitr::opts_chunk$set(echo = FALSE)
knitr::opts_chunk$set(warning = FALSE)
knitr::opts_chunk$set(message = FALSE)
knitr::opts_chunk$set(dev = 'pdf', fig.width = 12, fig.height = 7)
library(dplyr)
library(ggplot2)
library(ggpubr)
library(gridExtra)
library(kableExtra)
library(cowplot)
library(glue)
```
```{r create_ds}
# summary page data
sum_tbl <- data.frame(
  stringsAsFactors = FALSE,
  subj_cd = c("CAB-01", "CAB-03", "CAB-05", "CAB-07"),
  subj_name = c("Math","Physics","Chemistry","English"),
  Score = c(95, 94, 100, 100),
  St_Score = c(92,84,92,93)
) 

# histogram data
his_tbl<-data.frame(
  Score = c(99.669,99.487,100,100,99.475,99.452,
           100,100,98.028,100,100,99.153,99.577,100,99.785,99.433,
           100,100,99.441,100,98.778,99.56,100,99.446,100,99.234,
           100,99.281,99.177,98.936,99.048,100,96.154,100,99.718,
           99.481,99.765,99.811,100,100,100,100,97.544,99.457,
           100,100,97.611,97.17,99.752,97.99,97.674,100,100,99.888,
           100,99.419,100,99.76,100,99.754,100,99.287,97.273,
           98.381,99.476,100,99.389,100,99.802,99.559,100,99.842,
           100,100,100,99.438,100,99.855,99.769,100,100,99.707,100,
           99.718,100,97.877,100,100,99.816,98.725,100,100,
           99.378,100,99.825,99.512,99.827,99.677,100,98.983)
)
# table display data 
dp_tbl <- data.frame(
  stringsAsFactors = FALSE,
  date = c("2019Q3-2020Q3"),
  Score = c(99.65),
  cnt = c(1541),
  st_s = c(99.54),
  nat_s = c(99.57),
  p = c(39)
)
```
```{r func_def}
g_hist <- function(){
   ggplot(his_tbl,aes(x=Score, y=..count..)) + 
   geom_histogram(bins=50, fill="steelblue", color="white") +
   theme(title=element_text(size=11,face='bold')) 
}
d_tab <- function() {
  wide <- dp_tbl %>% select( 
    "Reporting Period"=date,
    "School's Score"=Score, 
    "Number of School Reporting"=cnt, 
    "State Score"=st_s,
    "National Score"=nat_s,  
    "School Percentile"=p) 
 long <- t(wide)
 ggtexttable(long, cols = NULL,theme = ttheme("blank",tbody.style = c(hjust=1, x=0.9)))
}
```
This is a sample report for school subjects evaluation in pdf format. It has summary and detail pages. The first page is report description.  2nd page is a subject table with 4 rows as example (it has more then 40 rows in real). I want to have a internal link column, say SubjectID, and jump to desired detail page when click on it. For example, when click on CAB-01, it leads to Math detail page. I've used 'glue' to create a label, but some parts are missing; it don't work for me. Help needed. Thanks!

\pagebreak
**School ID: ** School 12345, IL    
**Comparative Report:  Subject Scores for School with National and State Comparison**
\
\
```{r sumpg, echo=FALSE}
sum_tblt <- sum_tbl %>% 
  select(
    "SubjectID"=subj_cd, 
    "Subject Description"=subj_name, 
    "School's Score"=Score, 
    "State Score"=St_Score  
  )
sum_tblt <- as_tibble(sum_tblt)

sum_tblt %>%
  mutate(SubjectID = glue("\\hyperref[tab:ids<<SubjectID>>]{<<SubjectID>>}",
                     .open = "<<", .close = ">>")) %>%
  kable(format = "latex", escape = FALSE) %>%
  column_spec(1, width="2cm", border_left = TRUE) %>% 
  column_spec(2:3, width="2.5cm") %>%
  column_spec(4, width="2.5cm", border_right = TRUE)%>%
  kable_styling("bordered", font_size = 12)
```
\pagebreak

**School: ** School 12345, IL       
**Subject Name: ** Math  
**Subject Description: ** Evaluation Report   
**Link to QA Resources:** <http://rmarkdown.rstudio.com> {CAB-01}  

```{r echo=F}
o2 <- g_hist()
o3 <- d_tab()
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', axis="r")
bottom_row <- plot_grid(o2, align = 'h', axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
```

\pagebreak

**School: ** School 12345, IL       
**Subject Name: ** Physics  
**Subject Description: ** Evaluation Report  
**Link to QA Resources:** <http://rmarkdown.rstudio.com> {CAB-03}

```{r phypg,echo=F}
o2 <- g_hist()
o3 <- d_tab()
text <- paste(" ")
text.p <- ggparagraph(text = text, color="white")
top_row <- plot_grid(o3, text.p, align = 'h', axis="r")
bottom_row <- plot_grid(o2, align = 'h', axis="l")
ggarrange(top_row, bottom_row, ncol = 1, nrow = 2, heights = c(.6, 1))
```

It is hard to offer good advice for such a complex example. It takes a while just to understand the document itself. In general it is best if you can boil down the problem to a minimal reproducible example (i.e. the least amount of code necessary to reproduce the issue).

Anyway, in your case it seems like you are using the hyperlinks incorrectly. For a hyperlink to work it needs two things, (1) a starting point and, (2) an end point, or in other words, the link you click on and its target location. You have created the link (though there were some issues with the code), but you do not have any target locations - so the links are pointing to something that doesn't exist.

Here is a simple demonstration of how to create links and locations:

---
title: "Hyperlink Example"
output: pdf_document
linkcolor: blue
---

This is a sentence with a \hyperlink{target}{clickable link}.

\pagebreak

This is the \hypertarget{target}{target location}.

Try rendering this and seeing how it works.

Note: You can basically achieve the same effect with \label{id} and \hyperref[id]{some text}, but the principle is the same, you need a link (created by \hyperref) and a target (created by \label).

This topic was automatically closed 45 days after the last reply. New replies are no longer allowed.

If you have a query related to it or one of the replies, start a new topic and refer back with a link.