Thesisdown:加载huxtable包并创建表时,编织到PDF失败

问题描述 投票:1回答:1

我想在使用thesisdow包创建的文档中使用huxtable包创建表。编织为html可以很好地处理HTML。但是,在装入huxtable之后,一旦包含表格,编织到PDF就会失败,并出现以下错误:

 ! LaTeX Error: Environment threeparttable undefined.

似乎与LaTex软件包在后台发生冲突。在MWE下方,用于thesisdown index.file。有趣的是,在一个简单的markdown文件中,编织成html和PDF的文件都没有问题。由于thesisdown建立在bookdown上,因此当将bookdown文件编织成PDF时,也有可能发生错误。

index.Rmd


    ---
    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始终有效
  • 仅当“ library(huxtable)”之后没有表时,即,当未执行代码块“ pressure-table2”时,编织为PDF才有效

UPDATE:

((1)如果使用thesisdown,包括@ dash2建议的YAML标头中huxtable所需的LaTex程序包,效果很好。

((2)但是,如果使用huskydown,则问题仍然存在。

1。 index.Rmd(thesisdown)


    ---
    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(huskydown)


    ---
    # 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程序包,但编制索引。huskydown的Rmd再次引发错误:

 ! LaTeX Error: Environment threeparttable undefined.

[LaTex软件包是否已被[[huskydown忽略?

r bookdown
1个回答
0
投票
@ dash2建议的解决方案:手动包括LaTex软件包

“装有header-includes的LaTex软件包被huskydown忽略了?”-似乎实际上是这种假设。因此,LaTex软件包不能包含在index.Rmd文件的YAML标头中。

huskydown论文模板包括文件“ header-includes”,该文件定义了文档类并提供了多个LaTex软件包。将template.tex所需的所有LaTex软件包手动添加到此文件即可解决此问题:

huxtable

© www.soinside.com 2019 - 2024. All rights reserved.