Skip to content

在章节中使用中文数字编号遇到的问题 #899

@AzureRabbit

Description

@AzureRabbit

在chapter_name使用“!expr function(i) paste('第',i,'章',sep='')”可以正常生成“第1章"...,但是我想将阿拉伯数字换成中文的数字,如1换成一。我做了如下尝试:
!expr function(i) paste('第',c('一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一','二十二','二十三','二十四','二十五')[i],'章',sep='')
build没有问题,但是所有的章的编号都是“第NA章”。
在console中单独运行这个函数是没有问题的,如下所示:

y <- function(i) paste('第',c('一','二','三','四','五','六','七','八','九','十','十一','十二','十三','十四','十五','十六','十七','十八','十九','二十','二十一','二十二','二十三','二十四','二十五')[i],'章',sep='')
y(25)
[1] "第二十五章"

非常期待并感谢您的解答。


By filing an issue to this repo, I promise that

  • I have fully read the issue guide at https://yihui.org/issue/.
  • I have provided the necessary information about my issue.
    • If I'm asking a question, I have already asked it on Stack Overflow or RStudio Community, waited for at least 24 hours, and included a link to my question there.
    • If I'm filing a bug report, I have included a minimal, self-contained, and reproducible example, and have also included xfun::session_info('bookdown'). I have upgraded all my packages to their latest versions (e.g., R, RStudio, and R packages), and also tried the development version: remotes::install_github('rstudio/bookdown').
    • If I have posted the same issue elsewhere, I have also mentioned it in this issue.
  • I have learned the Github Markdown syntax, and formatted my issue correctly.

I understand that my issue may be closed if I don't fulfill my promises.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions