簡體   English   中英

引用 RMarkdown 中的數字不起作用

[英]Referencing to figures in RMarkdown does not work

首先,我制作了兩個 Waffleplots(我想我是用 ggplot 做的)

(...)
waffle_school <- make_waffle(schoolsoort, StudentId)

(...)
waffle_bench <- make_waffle(schoolsoort, benchStudentId)
(...)

使用一些 function:

make_waffle <- function(variableCol, uniqueIdentifiers, numberRowsWaffle = 5, deleteZeros=1) {
(...)  
 waffle <- waffle(categ_table, colors = Kleuren_schoolsoort[names(Kleuren_schoolsoort) %in% names(categ_table)], rows = numberRowsWaffle) + 
    theme(legend.position = "bottom") + colScale #+ guides(fill=guide_legend(ncol=4, byrow=TRUE)) 
  return(waffle)
}

然后我實際上在文本中的某個點顯示了情節

{r Waffleplot-school, fig.height = 2.5, fig.margin=TRUE, fig.cap="\\textcolor{TIGcaptioncolor}{Leerlingen per schoolsoort 21/22 op jullie school}"}
  waffle_school

{r Waffleplot-landelijk, fig.height = 2.5, fig.margin=TRUE, fig.cap=cap1}
  waffle_bench
}

我稍后想在我的文本中引用它,說:“在圖 \ref{fig:Waffleplot-school} 中你可以看到 (..),在圖 \ref{fig:Waffleplot-landelijk} 中你可以看到 (.. .)”

這讓我在 de pdf 中的實際參考中留下了問號。順便說一下,我使用 pdflatex 作為渲染器。

此外,這是我的主要 Rmd 文件具有的 yaml header 的一部分,我從另一個 R 文件運行。

---
output: 
  pdf_document:
    number_sections: true
    keep_tex: true
    fig_caption: yes
    latex_engine: pdflatex
    extra_dependencies: ["flafter"]

然后,我調用其中包含圖片和文本(包括參考文獻)的 Rmd 文件,其中包含以下 header:

---
title: "SchoolInBeeld"
author: "Marja"
date: "`r Sys.Date()`"
bookdown::pdf_document2
---

我已經看到符號 \@ref{},它產生了精確的引用 latex 調用而不是引用本身:“\ref{fig:Waffleplot-school}”。 另外,我已經訪問過很多關於這個的問題,比如

我覺得 output 格式是問題所在。 像我這樣的人試圖使用 bookdown 東西,但不知道如何調用 package。

僅供參考,我能熟練使用 Latex,但對 R 比較陌生。

你能試試這個嗎:

---
output: 
  bookdown::pdf_document2:
    number_sections: true
    keep_tex: true
    fig_caption: yes
    latex_engine: pdflatex
    extra_dependencies: ["flafter"]

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM