gpt4 book ai didi

bookdown - 无法为 LaTeX/PDF 输出创建索引

转载 作者:行者123 更新时间:2023-12-02 13:20:31 25 4
gpt4 key购买 nike

我关注了bookdown创建索引的指令。尽管代码运行没有错误,但它没有在 pdf 输出中显示索引。还有指令here 。我一定是做了什么蠢事!

可重现的代码在这里:

#####################
##### index.Rmd #####
#####################

---
title: "Linear Models using R"
author:
- J Smith
- ABC Inc
site: bookdown::bookdown_site
bookdown::gitbook:
fontsize: 12pt
geometry: margin=0.8in
bookdown::pdf_book:
template: null
keep_tex: yes
toc: yes
includes:
in_header:
- \usepackage{makeidx}
- \makeindex
after_body:
- \printindex
documentclass: book
classoption: openany
bibliography: [book.bib, packages.bib]
biblio-style: apalike
link-citations: yes
description: "Linear Models using R"
---


####################
###### 01.Rmd ######
####################

# Model

This is an R Markdown\index{rmarkdown} document\index{document}.

This book\index{book} describes linear\index{linear} model.

In this chapter\index{chapter}, we will discuss polynomial\index{polynomial} model.


# Index{-}

####### Error
####### \printindex

为了增加清晰度,带有多个“#”的行是注释或文件名。请注意,如果我在文档末尾运行简单的 \printindex (上面已注释),它会显示以下错误:

!未定义的控制序列。\打印索引

sessionInfo() 在这里:

R version 3.4.1 (2017-06-30)
Platform: x86_64-pc-linux-gnu (64-bit)
Running under: CentOS Linux 7 (Core)

Matrix products: default
BLAS: /cm/shared/apps/R/3.4.1/lib64/R/lib/libRblas.so
LAPACK: /cm/shared/apps/R/3.4.1/lib64/R/lib/libRlapack.so

locale:
[1] LC_CTYPE=en_GB.UTF-8 LC_NUMERIC=C
[3] LC_TIME=en_GB.UTF-8 LC_COLLATE=en_GB.UTF-8
[5] LC_MONETARY=en_GB.UTF-8 LC_MESSAGES=en_GB.UTF-8
[7] LC_PAPER=en_GB.UTF-8 LC_NAME=C
[9] LC_ADDRESS=C LC_TELEPHONE=C
[11] LC_MEASUREMENT=en_GB.UTF-8 LC_IDENTIFICATION=C

attached base packages:
[1] stats graphics grDevices utils datasets methods base

loaded via a namespace (and not attached):
[1] Rcpp_0.12.17 bookdown_0.7.15 digest_0.6.15 withr_2.1.2
[5] R6_2.2.2 jsonlite_1.5 git2r_0.18.0 magrittr_1.5
[9] evaluate_0.11 httr_1.3.1 stringi_1.2.2 curl_3.1
[13] rmarkdown_1.10.8 devtools_1.13.4 htmldeps_0.1.1 tools_3.4.1
[17] stringr_1.3.1 xfun_0.3 yaml_2.2.0 compiler_3.4.1
[21] memoise_1.1.0 htmltools_0.3.6 knitr_1.20.8

最佳答案

未正确指定 YAML。以下内容对我有用。

index.Rmd

--- 
title: "Linear Models using R"
author:
- J Smith
- ABC Inc
site: bookdown::bookdown_site
fontsize: 12pt
geometry: margin=0.8in
output:
bookdown::pdf_book:
template: null
keep_tex: yes
toc: yes
includes:
after_body: after_body.tex
in_header: include_header.tex
bibliography: [book.bib, packages.bib]
---

# Model

This is an R Markdown\index{rmarkdown} document\index{document}.

This book\index{book} describes linear\index{linear} model.

In this chapter\index{chapter}, we will discuss polynomial\index{polynomial} model.

include_header.tex

\usepackage{makeidx}
\makeindex

after_body.tex

\printindex

并在您的图书目录的控制台上运行

bookdown::render_book("index.Rmd", "bookdown::pdf_book")

输出:

index

关于bookdown - 无法为 LaTeX/PDF 输出创建索引,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/51549015/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com