**rticles** 包的 `jss_article()` 中的格式化问题
Formatting questions in `jss_article()` of **rticles** package
我正在根据 R Studio 中的 JSS 模板准备手稿。间接地,我使用 rticles 包中的 jss_article()
。现在,按照期刊提交的说明,我使用精确的 LaTex 命令准备好我的文章。
不过,我运行进入了以下格式问题。
[ ] 我希望 jss_article()
执行内联代码命令,如 r print(x)
。保持不变,它无法像 Rmarkdown error #385 (along with others) 那样编译。在解决方案之后,我在它周围加上了美元符号。然而,内联代码并没有被执行,而是被打印到了屏幕上。在JSS格式中,内联命令是不是在rticles::jss_article()
中执行?
[ ] 通常,我想使用内联代码从列表中提取元素,例如 r print(x$B)
。由于“$”是一个 LaTex 符号,我需要使用“\”。执行 $r print(x$B)
$ 导致
[ ] 长名称 运行 关闭页面,如 # Example 4: Interval-Censored data with univariate Bayesian multivariate imputation .
tidy
和 tidy.opts
选项的使用 knitr似乎在 JSS 模板中被忽略了。
[ ] jss_article()
似乎不支持 knitr::kable() 功能。你能推荐一个函数来构建具有出版价值的表(类似于 kable()
的输出)吗?
已编辑 RStudio 模板以反映这些问题:
---
documentclass: jss
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name@company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
---
#Issues here
[ ] It seems that inline R code does not run. As mentioned in rmardown error#385, I need to put dollar signs around it. <!-- $ r print(x)$ --> Is this the case.
[ ] If I want to use inline R code while picking an element from the list I'll need to use the "$" sign. However, it is a special character; do I hit escape?
[ ] Long names run off the page, like `# Example 4: Interval-Censored data with univariate Bayesian multivariate imputation .`
[ ] `knitr::kable()` does not seem to be supported. Can you recommend a function that provides publication-worthy tables using `jss_article()`?
# Example 4: Interval-Censored data with univariate Bayesian multivariate imputation
This template demonstrates some of the basic latex you'll need to know to create a JSS article.
```{r echo = FALSE}
knitr::opts_chunk$set(tidy = "styler",
tidy.opts = list(blank = FALSE, width.cutoff = 40)
)
# options for tidy to remove blank lines [blank = FALSE] and set the approximate line width to be 80.
```
# R code
Can be inserted in regular R markdown blocks.
```{r}
x <- as.list(1:10)
names(x) <- LETTERS[1:10]
x$A
```
blah blah blah $`r print(x)`.$ I want 2 here.
and <!--$ r print(x). $ I want to print element B of x, or 2. -->
```{r}
l <- list(x = x, a = letters)
fit <- lm(y~x, data = data.frame(x = 1:10, y = rnorm(10)))
knitr::kable( summary(fit)$coefficients )
# label = "bootWQS",
# digits = 3, caption = "WQS estimates using bootstrap multiple imputation. Summary of statistics after performing WQS regression across two datasets. " )
```
# Computational Details
Using Github versions of **rticles** package had the same result.
```{r, echo =FALSE}
xfun::session_info('rticles')
```
Xiangyun Huang,文章的作者,通过以下方式解决了这些问题:
- 使用 the booktabs LaTex package and the
booktabs::pdf_book()
output option.
- 将
tidy
选项设置为 "formatR"
而不是“styler
”。
关于问题的进一步说明:
- 要执行内联 R 代码,请不要使用美元符号并使用常规
r ...
语法。
- 主要 header
#
的长标题仍然 运行 在页面之外。该行为由日志文档 class (jss.cls
) 定义。最简单的解决方案:避免使用太长的 first-level headers。
- 长辅助headers
##
保持在线并且不会运行离开页面,感谢booktabs包。
- 要制作漂亮的表格,仍然使用
kable()
但添加 format
和 booktabs
参数:
knitr::kable(summary(fit)$coefficients, digits = 3,
label = "demo-table" caption = " A CAPTION HERE ",
format = "latex", booktabs = TRUE
)
See the cross-post for more information.
documentclass: jss
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name@company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
\usepackage{booktabs}
output:
bookdown::pdf_book:
base_format: rticles::jss_article
---
```
knitr::opts_chunk$set(
tidy = "formatR",
tidy.opts = list(blank = FALSE, width.cutoff = 40)
)
```
## Example 4: Interval-Censored data with univariate Bayesian multivariate imputation
1. Executing R commands. Dollar signs are not needed.
blah blah blah `r x$B`.
1. A pretty table
```r
fit <- lm(y ~ x, data = data.frame(x = 1:10, y = rnorm(10)))
knitr::kable(summary(fit)$coefficients,
label = "demo-table",
digits = 3, caption = " A CAPTION HERE ", format = "latex", booktabs = TRUE
)
```
demo table \@ref(tab:demo-table)
我正在根据 R Studio 中的 JSS 模板准备手稿。间接地,我使用 rticles 包中的 jss_article()
。现在,按照期刊提交的说明,我使用精确的 LaTex 命令准备好我的文章。
不过,我运行进入了以下格式问题。
[ ] 我希望 jss_article()
执行内联代码命令,如 r print(x)
。保持不变,它无法像 Rmarkdown error #385 (along with others) 那样编译。在解决方案之后,我在它周围加上了美元符号。然而,内联代码并没有被执行,而是被打印到了屏幕上。在JSS格式中,内联命令是不是在rticles::jss_article()
中执行?
[ ] 通常,我想使用内联代码从列表中提取元素,例如 r print(x$B)
。由于“$”是一个 LaTex 符号,我需要使用“\”。执行 $r print(x$B)
$ 导致
[ ] 长名称 运行 关闭页面,如 # Example 4: Interval-Censored data with univariate Bayesian multivariate imputation .
tidy
和 tidy.opts
选项的使用 knitr似乎在 JSS 模板中被忽略了。
[ ] jss_article()
似乎不支持 knitr::kable() 功能。你能推荐一个函数来构建具有出版价值的表(类似于 kable()
的输出)吗?
已编辑 RStudio 模板以反映这些问题:
---
documentclass: jss
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name@company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
output: rticles::jss_article
---
#Issues here
[ ] It seems that inline R code does not run. As mentioned in rmardown error#385, I need to put dollar signs around it. <!-- $ r print(x)$ --> Is this the case.
[ ] If I want to use inline R code while picking an element from the list I'll need to use the "$" sign. However, it is a special character; do I hit escape?
[ ] Long names run off the page, like `# Example 4: Interval-Censored data with univariate Bayesian multivariate imputation .`
[ ] `knitr::kable()` does not seem to be supported. Can you recommend a function that provides publication-worthy tables using `jss_article()`?
# Example 4: Interval-Censored data with univariate Bayesian multivariate imputation
This template demonstrates some of the basic latex you'll need to know to create a JSS article.
```{r echo = FALSE}
knitr::opts_chunk$set(tidy = "styler",
tidy.opts = list(blank = FALSE, width.cutoff = 40)
)
# options for tidy to remove blank lines [blank = FALSE] and set the approximate line width to be 80.
```
# R code
Can be inserted in regular R markdown blocks.
```{r}
x <- as.list(1:10)
names(x) <- LETTERS[1:10]
x$A
```
blah blah blah $`r print(x)`.$ I want 2 here.
and <!--$ r print(x). $ I want to print element B of x, or 2. -->
```{r}
l <- list(x = x, a = letters)
fit <- lm(y~x, data = data.frame(x = 1:10, y = rnorm(10)))
knitr::kable( summary(fit)$coefficients )
# label = "bootWQS",
# digits = 3, caption = "WQS estimates using bootstrap multiple imputation. Summary of statistics after performing WQS regression across two datasets. " )
```
# Computational Details
Using Github versions of **rticles** package had the same result.
```{r, echo =FALSE}
xfun::session_info('rticles')
```
Xiangyun Huang,文章的作者,通过以下方式解决了这些问题:
- 使用 the booktabs LaTex package and the
booktabs::pdf_book()
output option. - 将
tidy
选项设置为"formatR"
而不是“styler
”。
关于问题的进一步说明:
- 要执行内联 R 代码,请不要使用美元符号并使用常规
r ...
语法。 - 主要 header
#
的长标题仍然 运行 在页面之外。该行为由日志文档 class (jss.cls
) 定义。最简单的解决方案:避免使用太长的 first-level headers。 - 长辅助headers
##
保持在线并且不会运行离开页面,感谢booktabs包。 - 要制作漂亮的表格,仍然使用
kable()
但添加format
和booktabs
参数:
knitr::kable(summary(fit)$coefficients, digits = 3,
label = "demo-table" caption = " A CAPTION HERE ",
format = "latex", booktabs = TRUE
)
See the cross-post for more information.
documentclass: jss
author:
- name: FirstName LastName
affiliation: University/Company
address: >
First line
Second line
email: \email{name@company.com}
url: http://rstudio.com
- name: Second Author
affiliation: Affiliation
title:
formatted: "A Capitalized Title: Something about a Package \pkg{foo}"
# If you use tex in the formatted title, also supply version without
plain: "A Capitalized Title: Something about a Package foo"
# For running headers, if needed
short: "\pkg{foo}: A Capitalized Title"
abstract: >
The abstract of the article.
keywords:
# at least one keyword must be supplied
formatted: [keywords, not capitalized, "\proglang{Java}"]
plain: [keywords, not capitalized, Java]
preamble: >
\usepackage{amsmath}
\usepackage{booktabs}
output:
bookdown::pdf_book:
base_format: rticles::jss_article
---
```
knitr::opts_chunk$set(
tidy = "formatR",
tidy.opts = list(blank = FALSE, width.cutoff = 40)
)
```
## Example 4: Interval-Censored data with univariate Bayesian multivariate imputation
1. Executing R commands. Dollar signs are not needed.
blah blah blah `r x$B`.
1. A pretty table
```r
fit <- lm(y ~ x, data = data.frame(x = 1:10, y = rnorm(10)))
knitr::kable(summary(fit)$coefficients,
label = "demo-table",
digits = 3, caption = " A CAPTION HERE ", format = "latex", booktabs = TRUE
)
```
demo table \@ref(tab:demo-table)