首页
\
问答
\
如何在适用于pdf和html输出的bookdown文档中的表格标题中插入引用(How to insert a reference in a table caption in a bookdown document that works for both pdf and html output)
如何在适用于pdf和html输出的bookdown文档中的表格标题中插入引用(How to insert a reference in a table caption in a bookdown document that works for both pdf and html output)
我使用bookdown来生成html和pdf文档。 如何在表格的标题中插入对文档部分的引用?
使用
\\ref{sec:FirstSection}
可以正常使用pdf_book(但不是gitbook):--- title: "Test" output: bookdown::pdf_book --- # A section {#sec:FirstSection} The dataset in Table \@ref(tab:aTable) contains some data. # Another section ```{r, aTable, echo = FALSE} knitr::kable( cars[1:5, ], caption = "See Section \\ref{sec:FirstSection}." ) ```
使用
\\@ref(sec:FirstSection)
可以正常使用gitbook(但不是pdf_book)--- title: "Test" output: bookdown::gitbook --- # A section {#sec:FirstSection} The dataset in Table \@ref(tab:aTable) contains some data. # Another section ```{r, aTable, echo = FALSE} knitr::kable( cars[1:5, ], caption = "See Section \\@ref(sec:FirstSection)." ) ```
I use bookdown to generate a document in both html and pdf. How could I insert a reference to a section of the document in the caption of a table?
Using
\\ref{sec:FirstSection}
works fine with pdf_book (but not gitbook):--- title: "Test" output: bookdown::pdf_book --- # A section {#sec:FirstSection} The dataset in Table \@ref(tab:aTable) contains some data. # Another section ```{r, aTable, echo = FALSE} knitr::kable( cars[1:5, ], caption = "See Section \\ref{sec:FirstSection}." ) ```
whilst using
\\@ref(sec:FirstSection)
works fine with gitbook (but not pdf_book)--- title: "Test" output: bookdown::gitbook --- # A section {#sec:FirstSection} The dataset in Table \@ref(tab:aTable) contains some data. # Another section ```{r, aTable, echo = FALSE} knitr::kable( cars[1:5, ], caption = "See Section \\@ref(sec:FirstSection)." ) ```
原文:https://stackoverflow.com/questions/46670422
更新时间:2023-09-23 21:09
最满意答案
相关问答
更多-
下列中不属于面向对象的编程语言的是?[2022-05-30]
a -
我不确定你需要,但这里是从字符串中提取所有单词的代码 my @words = ( $sitename =~ m/(\w+)/g ); 它也可以用split完成。 但是你现在需要使用空格: my @words = split( m/\s+/, $sitename ); I'm not sure that you need, but here is code extracting all words from string my @words = ( $sitename =~ m/(\w+)/g ); I ...
-
使用eof来检测您是否在最后一行: echo 'foo,bar' | tr , '\n' | perl -pe 'my $break = (eof) ? "" : "\\"; s/(.*)\n/BAZ($1) $break\n/g' Using eof to detect if you're on the last line: echo 'foo,bar' | tr , '\n' | perl -pe 'my $break = (eof) ? "" : "\\"; s/(.*)\n/BAZ($1) $br ...
-
你混淆了两个非常相似的东西。 如果未使用/m则在字符串末尾的$匹配,在字符串的末尾或字符串的末尾,如果使用/m则为最终换行符。 但是,它实际上并不匹配 (使用)换行符本身。 您仍然可以将换行符本身与\n则表达式中的其他内容匹配,例如\n ; 或者,如果你也使用/s ,那么/blah$./sm理论上会匹配“blah \ n”,即使$不是正则表达式中的最后一件事。 (这实际上不起作用的原因是$.和$\实际上都被解释为特殊变量而不是$ plus .所以实际上很难在正则表达式中放入$之后的东西。令人困惑,不是'是吗 ...
-
Perl的Chomp:Chomp正在删除整个单词而不是换行符(Perl's Chomp: Chomp is removing the whole word instead of the newline)[2022-06-18]
你只看到一个1秒的字符串的原因是你打印$val的值,这是从chomp返回的值。 chomp不返回修剪后的字符串,它就地修改其参数并返回从结尾删除的字符数。 由于它总是只删除一个"\n"字符,因此您可以为数组的每个元素获得1输出。 你真的应该use warnings而不是-w命令行选项,这里没有理由将整个文件读入数组。 但是使用带有三参数形式的open的词法文件句柄做得很好。 这是一个快速重构你的程序,将做你想要的。 #!/usr/bin/perl use strict; use warnings; my ... -
“使用正则表达式模式搜索匹配时,忽略目标字符串中的空格的最佳方法是什么?” 我会动态构造一个正则表达式,插入一个(?:\n\s)? 每个角色之间。 use strict; use warnings; my $needed = 'cats'; my $regex = join '(?:\n\s)?' , split ( '',$needed ); print "\nRegex = $regex\n", '-'x40, "\n\n"; my $target = " cats c ats ...
-
使用splitlines() ,传递True: "amount\nexceeds".splitlines(True) 给你: ["amount\n", "exceeds"] Use splitlines(), passing True: "amount\nexceeds".splitlines(True) gives you: ["amount\n", "exceeds"]
-
这看起来不像perl的问题,这是你键入的bash命令的问题。 在bash输入以下字符串文字时: "Issue: CPU usage is high \n Time: 11:20AM \n" bash不会将\n字符序列解释为换行符。 你需要一个不同的语法。 您可以使用以下任一项: # bash sendEmail.pl $'Issue: CPU usage is high\nTime: 11:20AM\n' 要么 # bash or sh sendEmail.pl 'Issue: CPU usage is ...
-
在Python中包装多行字符串(保留现有的换行符)?(Wrap multiline string (preserving existing linebreaks) in Python?)[2020-11-23]
只需在拆分后添加换行符: import textwrap import pprint import itertools mystr=r""" First line. Second line. The third line is a very long line, which I would like to somehow wrap; wrap at 80 characters - or less, or more! ... can it really be done ??""" wrapper = te ... -
将多行字符串与perl正则表达式匹配并进行替换(matching multiple line string with perl regex and doing a replace)[2022-02-19]
您可以使用s (单行标志)这样的正则表达式: \).*?<<(.*?); 和替换字符串: , \1); 工作演示 In the end the command that successfully did what I wanted was the following: perl -0777pne 's/STDOUT_LOG\((.*?)\)(.*?)<<(.*?);/STDOUT_LOG\(\1\,\2\3\);/gs' sensor.cpp This is alot a superposition ...