如何在 bookdown 中使用 zhmakeindex 而不是 makeindex

how to use zhmakeindex instead of makeindex in bookdown

https://github.com/rstudio/bookdown. I find that in ./inst/example, makeindex is much usefull for my book. I want to add Chinese index in my book中,但是makeindex不能像预期的那样为中文索引工作。

我可以编译索引使用 zhmakeindex 而不是 makeindex 而无需更改 tex file,就像 https://github.com/leo-liu/zhmakeindex 中的示例一样。

http://www.ituring.com.cn/article/207412所说。

bash xelatex -interaction=batchmode zhmakeindex.tex bibtex zhmakeindex zhmakeindex zhmakeindex xelatex -interaction=batchmode zhmakeindex.tex xelatex -interaction=batchmode zhmakeindex.tex

如何在 bookdown 中使用 zhmakeindex 而不是 makeindex?我找不到在哪里写 makeindexzhmakeindex 命令。谢谢。

使用 tinytex 包的当前开发版本,您可以在 .Rprofile 中设置全局选项 tinytex.makeindex 或在您的 .Rprofile 中设置 R 代码块书:

devtools::install_github('yihui/tinytex')
options(tinytex.makeindex= 'zhmakeindex')

可以通过全局选项 tinytex.makeindex.args 传递更多命令行选项,例如

options(tinytex.makeindex.args = c('-z', 'pinyin'))

谢谢@yihui 这是我的解决方案。完整的源代码见 https://github.com/bubifengyun/deepin-bible and I had find one bug in pandoc https://github.com/jgm/pandoc/issues/4762

./latex/template.tex我添加这段代码

```胶乳

\usepackage[texindy]{imakeidx}
\makeindex[title=\titleindex,columns=2,intoc=true,columnseprule=true]
\indexsetup{
    othercode={%
        \thispagestyle{main}%
    }
}

```

./index.Rmd中使用zhmakeindex,我添加这段代码

```R

options(
    htmltools.dir.version = FALSE, formatR.indent = 2, width = 55, digits = 4, tinytex.makeindex =  zhmakeindex, tinytex.makeindex.args = '-s imakeidx.ist'
)

```

这是结果