【问题标题】:Hold apa_table position in Rmarkdown/papaja在 Rmarkdown/papaja 中保持 apa_table 位置
【发布时间】:2021-08-13 13:09:58
【问题描述】:

我确实有另一个 Rmarkdown/papaja 包问题,如果有人愿意提供帮助,我会非常高兴:)

互联网上有很多人,我很难控制我的桌子的位置。 我有

floatsintext: yes

选项包含在 YAML 标头中。 我知道有诸如 fig.pos = "!H" 之类的 LATEX 选项,我必须为此加载 float 包

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

【问题讨论】:

  • 你能发一个minimal reproducible example吗?
  • 我编辑了帖子,抱歉我不知道创建可重现示例的其他方法。我必须删除 R 块之前的 `` 符号,因此必须将它们添加到结束.. 感谢您的回复!
  • 如果你使用更多的反引号,你可以在你的代码中包含```,例如```` 将代码块嵌入到您的问题中。

标签: latex r-markdown papaja


【解决方案1】:

对于 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")

【讨论】:

    猜你喜欢
    • 2021-10-14
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-04-22
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-07-06
    相关资源
    最近更新 更多