问题描述
我确实有另一个 Rmarkdown/papaja 包问题,如果有人愿意提供帮助,我会很高兴 :)
由于互联网上的许多人,我无法控制桌子的位置。 我有
floatsintext: yes
选项包含在 YAML 标头中。 我知道有诸如 fig.pos = "!H" 之类的 LATEX 选项,我必须为其加载浮点包
header-includes:
- usepackage\{float}
但是,这样做我收到以下错误消息:
! LaTeX Error: UnkNown float option `H'.
哪个告诉我浮动包无法加载我猜? (我确实安装了 MacTex 以及最新的 R 版本)。
让我感到绝对困惑的是,当我保留默认间距时,表格(使用 app_table() 生成)出现在(大约)正确的位置,但仅在我添加时出现在我的工作结束时
header-includes:
- \usepackage{setspace}
- \AtBeginEnvironment{tabular}{\singlespacing}
- \AtBeginEnvironment{lltable}{\singlespacing}
- \AtBeginEnvironment{tablenotes}{\singlespacing}
到 YAML 标题以控制我的表格的间距。
我真的很感激任何帮助! 提前致谢!
编辑: 我不知道这是否符合目的,但如果我创建以下选项,我的表格会出现在最后(而不是它应该出现的位置)
title : "TITLE"
shorttitle : "short title"
author:
- name : "me"
affiliation : "1"
corresponding : yes # Define only one corresponding author
address : "x"
email : "y"
role: # Contributorship roles (e.g.,CRediT,https://casrai.org/credit/)
- Conceptualization
- Writing - Original Draft Preparation
- Writing - Review & Editing
# - name : "Ernst-August Doelle"
# affiliation : "1,2"
# role:
# - Writing - Review & Editing
affiliation:
- id : "1"
institution : ""
# - id : "2"
# institution : "Konstanz Business School"
authornote: |
Enter author note here.
abstract: |
keywords : "keywords"
wordcount : "X"
bibliography :
floatsintext : yes
figurelist : no
tablelist : no
footnotelist : no
linenumbers : no
mask : no
draft : no
csl: "apa.csl"
documentclass : "apa7"
classoption : "man"
output : papaja::apa6_pdf
toc: true
header-includes:
- \usepackage{float}
- \usepackage{setspace}
- \AtBeginEnvironment{tabular}{\singlespacing}
- \AtBeginEnvironment{lltable}{\singlespacing}
- \AtBeginEnvironment{tablenotes}{\singlespacing}
---
{r setup,include = FALSE}
library("papaja")
library("apa")
library("tidyverse")
library("apaTables")
r_refs("r-references.bib")
{r analysis-preferences}
# Seed for random number generation
set.seed(42)
knitr::opts_chunk$set(cache.extra = knitr::rand_seed)
{r}
cor_table <- apa.cor.table(iris)
Text BLABLABLABLA
{r tab,results = "asis",fig.pos = "!h"}
apa_table(cor_table$table.body,caption = "Means,standard deviations,and correlations with confidence intervals for study variables.",note = "Note. M and SD are used to represent mean and standard deviation,respectively.Values in square brackets indicate the 95% confidence interval.The confidence interval is a plausible range of population correlations that Could have caused the sample correlation (Cumming,2014). * indicates p < .05. ** indicates p < .01.",font_size = "footnotesize",row.names = F,placement = "p")
# Methods
We report how we determined our sample size,all data exclusions (if any),all manipulations,and all measures in the study. <!-- 21-word solution (Simmons,Nelson & Simonsohn,2012; retrieved from http://ssrn.com/abstract=2160588) -->
## Participants
## Material
## Procedure
## Data analysis
We used `r cite_r("r-references.bib")` for all our analyses.
# Results
# discussion
\newpage
# References
\begingroup
\setlength{\parindent}{-0.5in}
\setlength{\leftskip}{0.5in}
<div id="refs" custom-style="Bibliography"></div>
\endgroup
解决方法
对于 PDF 输出,有一种推荐的方法来自定义通过 apa_table()
创建的表格的位置。 (您不必通过标头包含加载 float
包。)
首先,设置 YAML 标头选项 floatsintext: yes
。
其次,使用 apa_table()
创建表时,使用函数的 placement
参数:
```{r tab}
apa_table(cor_table$table.body,caption = "Means,standard deviations,and correlations with confidence intervals for study variables.",note = "Note. M and SD are used to represent mean and standard deviation,respectively.Values in square brackets indicate the 95% confidence interval.The confidence interval is a plausible range of population correlations that could have caused the sample correlation (Cumming,2014). * indicates p < .05. ** indicates p < .01.",font_size = "footnotesize",row.names = F,placement = "H")