首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >下载:当加载huxtable包和创建表时,编织到PDF失败

下载:当加载huxtable包和创建表时,编织到PDF失败
EN

Stack Overflow用户
提问于 2019-08-24 11:37:25
回答 1查看 494关注 0票数 1

我希望在用thesisdow包创建的文档中使用huxtable包创建表。编织到HTML很好地工作与html。但是,在加载huxtable之后,一旦包含了一个表,编织但PDF就会失败,并出现以下错误:

代码语言:javascript
复制
 ! LaTeX Error: Environment threeparttable undefined.

在后台,似乎与LaTex包发生了冲突。在MWE的下面是关于index.file的。有趣的是,在一个简单的标记文件编织到html和PDF都没有问题。由于下标是建立在预订之上的,所以在将预订文件编成PDF时也可能会发生错误。

index.Rmd

代码语言:javascript
复制
    ---
    knit: "bookdown::render_book"
    site: bookdown::bookdown_site
    output: 
     thesisdown::thesis_pdf: default
      # thesisdown::thesis_gitbook: default
    ---

    ```{r include_packages, include = FALSE}
    # Ensure that the thesisdown package is installed and loaded
    if(!require(devtools))
      install.packages("devtools", repos = "http://cran.rstudio.com")
    if(!require(thesisdown))
      devtools::install_github("ismayc/thesisdown")
    library(thesisdown)
    ```

    # Random Test Output - *before* calling "library(huxtable)"
    a table with pressure data
    ```{r pressure-table, echo=FALSE}
    pressure
    ```

    ```{r echo=FALSE}
    library(huxtable)
    ```

    # Random Test Output - *after* calling "library(huxtable)"
    a table with pressure data
    ```{r pressure-table2, echo=FALSE}
    pressure
    ```

MWE摘要:

  • 编织到HTML总是有效的
  • 只有在“库(Huxtable)”之后没有表时,即当代码块“2”未被执行时,才能编写到PDF。

更新:

(1)如果按照@dash2 2的建议,在YAML-header中使用huxtable所需的LaTex包,则可以使用该方法。

(2)然而,如果与哈士金合作,不幸的是,问题仍然存在。

1. index.Rmd (thesisdown)

代码语言:javascript
复制
    ---
    knit: "bookdown::render_book"
    site: bookdown::bookdown_site
    output: 
     thesisdown::thesis_pdf: default
      # thesisdown::thesis_gitbook: default
    header-includes:
      - \usepackage{array}
      - \usepackage{caption}
      - \usepackage{graphicx}
      - \usepackage{siunitx}
      - \usepackage{colortbl}
      - \usepackage{multirow}
      - \usepackage{hhline}
      - \usepackage{calc}
      - \usepackage{tabularx}
      - \usepackage{threeparttable}
      - \usepackage{wrapfig}
    ---
    ...

2. index.Rmd (哈士克羽绒)

代码语言:javascript
复制
    ---
    # UW thesis fields
    title: "My thesis title - edit in index.Rmd"
    author: "My Name"
    year: "2017"
    program: "My Department"
    chair: "Name of my committee chair"
    chairtitle: "Title of my chair"
    signature1: "person 1"
    signature2: "person 2"
    signature3: "person 3"
    abstract: |
      "Here is my abstract"
    acknowledgments: |
      "My acknowledgments"
    dedication: |
      "My dedication"
    knit: "bookdown::render_book"
    site: bookdown::bookdown_site
    output: 
      huskydown::thesis_pdf: 
        latex_engine: xelatex
    bibliography: bib/thesis.bib
    csl: csl/apa.csl
    lot: true
    lof: true
    header-includes:
      - \usepackage{tikz}
      - \usepackage{array}
      - \usepackage{caption}
      - \usepackage{graphicx}
      - \usepackage{siunitx}
      - \usepackage{colortbl}
      - \usepackage{multirow}
      - \usepackage{hhline}
      - \usepackage{calc}
      - \usepackage{tabularx}
      - \usepackage{threeparttable}
      - \usepackage{wrapfig}
    ---


    ```{r include_packages, include = FALSE}
    # This chunk ensures that the huskydown package is
    # installed and loaded. This huskydown package includes
    # the template files for the thesis.
    if(!require(devtools))
      install.packages("devtools", repos = "http://cran.rstudio.com")
    if(!require(huskydown))
      devtools::install_github("benmarwick/huskydown")
    library(huskydown)
    ```

    # Random Test Output - *before* calling "library(huxtable)"
    a table with pressure data
    ```{r pressure-table, echo=FALSE}
    pressure
    ```

    ```{r echo=FALSE}
    library(huxtable)
    ```

    # Random Test Output - *after* calling "library(huxtable)"
    a table with pressure data
    ```{r pressure-table2, echo=FALSE}
    pressure
    ```

尽管加载了LaTex包,但是编织用于哈士基向下的index.Rmd仍然会引发错误:

代码语言:javascript
复制
 ! LaTeX Error: Environment threeparttable undefined.

是否任何带有LaTex的header-includes包都可能被huskydown忽略?

EN

回答 1

Stack Overflow用户

回答已采纳

发布于 2020-02-04 09:01:21

@dash2 2推荐的解决方案:手动包含LaTex包

"LaTex包装载了header-includes,被赫斯基敦忽略了?“因此,LaTex包不能包含在index.Rmd文件的YAML头中。

下一篇论文模板包含文件"template.tex“,该文件定义了文档类,并提供了几个LaTex包。手动向此文件中添加huxtable所需的所有huxtable包可以解决以下问题:

代码语言:javascript
复制
 %-------------------------------
 % Huxtable
 %-------------------------------
 % load LaTex packages needed for huxtable 
 \usepackage{array}
 \usepackage{caption}
 \usepackage{graphicx}
 \usepackage{siunitx}
 \usepackage{colortbl}
 \usepackage{multirow}
 \usepackage{hhline}
 \usepackage{calc}
 \usepackage{tabularx}
 \usepackage{tabulary}
 \usepackage{threeparttable}
 \usepackage{wrapfig}
票数 1
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57637596

复制
相关文章

相似问题

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