首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >在Rmarkdown/papaja中保持apa_table位置

在Rmarkdown/papaja中保持apa_table位置
EN

Stack Overflow用户
提问于 2021-05-25 17:41:42
回答 1查看 88关注 0票数 0

我这边还有另一个Rmarkdown/papaja包问题,如果有人愿意帮助我,我将非常高兴:)

就像互联网上的许多人一样,我很难控制我的桌子的位置。我有

代码语言:javascript
复制
floatsintext: yes

选项包含在YAML标头中。我知道有一些LATEX选项,比如fig.pos = "!H“,我必须加载浮动包

代码语言:javascript
复制
header-includes:
- usepackage\{float}

然而,这样做我得到了以下错误消息:

代码语言:javascript
复制
! LaTeX Error: Unknown float option `H'.

这告诉我浮动包不能加载我猜?(我安装了MacTex,也安装了最新的R版本)。

同样让我感到困惑的是,当我保留默认间距时,表格(使用app_table()生成)出现在(大致)正确的位置,但只有在我添加

代码语言:javascript
复制
header-includes:
  - \usepackage{setspace}
  - \AtBeginEnvironment{tabular}{\singlespacing}
  - \AtBeginEnvironment{lltable}{\singlespacing}
  - \AtBeginEnvironment{tablenotes}{\singlespacing}

添加到YAML标题,以便控制表格的间距。

如果有任何帮助,我将不胜感激!提前感谢!

编辑:我不知道这是否有用,但是如果我创建了以下选项,我的表会出现在末尾(而不是它应该在的位置)

代码语言:javascript
复制
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
EN

回答 1

Stack Overflow用户

发布于 2021-05-26 20:06:15

对于PDF输出,有一种推荐的方法可以自定义通过apa_table()创建的表的位置。(您不必通过header includes加载float包。)

首先,设置YAML头选项floatsintext: yes

其次,在使用apa_table()创建表时,使用函数的placement参数:

代码语言:javascript
复制
```{r tab}

apa_table(cor_table$table.body,

代码语言:javascript
复制
      caption = "Means, standard deviations, and correlations with confidence intervals for study variables.", 
代码语言:javascript
复制
      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,
代码语言:javascript
复制
      placement = "H")
代码语言:javascript
复制
票数 2
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/67685449

复制
相关文章

相似问题

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