首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >Rmarkdown YAML头中的作者从属关系,使用rticle

Rmarkdown YAML头中的作者从属关系,使用rticle
EN

Stack Overflow用户
提问于 2019-10-18 02:28:08
回答 1查看 617关注 0票数 4

我想在我的YAML头中添加author从属关系,正如这里推荐的(Authors and affiliations in the YAML of RMarkdown),使用rticles::elsevier_article输出格式做得很好,而且还省略了第一页上的页码,这也是可取的。问题是,1)文本引用定义在呈现为pdf时显示(它们不应该),2)文本引用不起作用-调用它们只会导致显示调用的文本(而不是引用的文本),以及3)对表和图形的引用不能像bookdown::pdf_document2输出那样工作。如何在bookdown::pdf_document2输出中获取作者和页码,或者如何在rticles::elsevier_article中获取引用

下面是一个例子,说明了这个问题。我使用的是RStudio 1.2.1335。

代码语言:javascript
复制
---
title: Problems with `rticles::elsevier_article` output 
author:
  - name: Alice Anonymous
    email: alice@example.com
    affiliation: Some Institute of Technology
    footnote: Corresponding Author
  - name: Bob Security
    email: bob@example.com
    affiliation: Another University
address:
  - code: Some Institute of Technology
    address: Department, Street, City, State, Zip
  - code: Another University
    address: Department, Street, City, State, Zip
abstract: |
  This is the abstract.

journal: "Ecological Monographs"
date: "`r Sys.Date()`"
csl: elsevier-harvard.csl
output: rticles::elsevier_article
#output:bookdown::pdf_document2
geometry: margin=2.54cm
---

The Problems I have
==========================

I would like to use the `rticles::elsevier_article` output because it 1) handles authors and affiliations the way I want, and 2) it nicely omits the page number from the firat page. Both of these things I can't seem to easily (if at all) accomplish using `bookdown::pdf_document2` output. 

However, when I specify `rticles::elsevier_article` output, I run into several problems: 1) text reference definitions are displayed upon rendering to pdf (they should not), 2) text references do not work - calling them results only in the text of the call (not the referenced text) being displayed, and 3) references to table and figures does not work as it does with `bookdown::pdf_document2` output. There is one more issue too - in one test case I inserted a table (using `kableExtra`), and knitting failed because of some latex `tabu` environment error, even though it looks to me like the `rticles::elsevier_article` output does indeed load the `tabu` package (but I had to load it in the YAML header to get the knitting to work). 

For example, lets define a text reference so I can use a super script 2 to specify square kilometers in a figure caption. The reference definition should not show in the rendered pdf (and it does not when I use the `bookdown::pdf_document2` output, but it frustratingly does so when I use the `rticles::elsevier_article` output).

<!-- text references for use in tables and captions (must be separated by empty line)-->
(ref:km2) km^2^

Now lets make a figure (below) and reference it here (Figure \@ref(fig:testfig)). The figure includes the text reference in the caption, but it does not display the referenced text, but only the exact text that is suppose to call the reference text. And my inline reference to the figure does not work.

```{r,testfig, echo=FALSE, fig.height = 2.5, fig.width = 3, fig.align = "center",fig.cap=paste0("This is a classic quadratic plot - it could represent ","(ref:km2)",".")}

x=-5:5

plot(x,x**2,xlab="my assets",ylab="my joy",main="Not true")

代码语言:javascript
复制
EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2019-10-18 17:09:14

作为detailed in the documentation,您可以将bookdown功能与其他格式相结合。在您的情况下,您必须替换

代码语言:javascript
复制
output: rticles::elsevier_article

使用

代码语言:javascript
复制
output:
  bookdown::pdf_book:
      base_format: rticles::elsevier_article
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/58438723

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档