为什么用点分隔的两位数字只在html_document2中显示? [英] Why figure numbers with two digits separated by dot are shown only in html_document2?

查看:42
本文介绍了为什么用点分隔的两位数字只在html_document2中显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是一个包含两个部分和两个图像的简单 RMarkdown 文档.

Here is simple RMarkdown document with two sections and two images.

---
output:
  bookdown::html_document2: default
  bookdown::word_document2: default
  bookdown::pdf_document2: default
---

\newpage

# Part 1

Part 1 starts here. See Figure \@ref(fig:fig1-1) 

![(\#fig:fig1-1) expected to be Figure 1.1.](/usr/lib/rstudio/www/images/rstudio.png)

# Part 2

Part 2 starts here. See Figure \@ref(fig:fig2-1) 

![(\#fig:fig2-1) expected to be Figure 2.1.](/usr/lib/rstudio/www/images/rstudio.png)

我希望用 Knit 将两个图像呈现为以下编号 - 第一个是图 1.1,第二个是图 2.1.但我只在 html_document2 中得到这个渲染(见下图):

I expect that two images will render with Knit to the following numbering - first is Figure 1.1, second is Figure 2.1. But I get this rendering only in html_document2 (see image below):

我使用最新的 RStudio 1.1.414 和来自 Git 的最新 bookdown (38a>efc82.我在这里有两个问题:

I use latest RStudio 1.1.414 with latest bookdown from Git (38efc82). I have two questions here:

  1. 为什么我在 Word 或 PDF 中没有图 1.1图 2.1?
  2. 如何在 Word 或 PDF 中获得图 1.1图 2.1?
  1. Why I don't have Figure 1.1 and Figure 2.1 in Word or PDF?
  2. How can I get Figure 1.1 and Figure 2.1 in Word or PDF?

推荐答案

我只能通过 LaTeX 处理 PDF 输出.默认情况下使用 LaTeX 文档类 article,它使用连续的图形编号.如果您的文档太长以至于需要为每个顶级部分中的数字编号,那么您可能需要使用 reportbook 代替,例如:

I can only address PDF output via LaTeX. By default the LaTeX documentclass article is used which uses continuous figure numbering. If your document is so long that it makes sense to number the figures within each top-level section, then you might want to use report or book instead, e.g.:

---
documentclass: book
output:
  bookdown::pdf_document2: default
  bookdown::word_document2: default
  bookdown::html_document2: default
---

或者,您可以使用一些 LaTeX 包来更改图形编号的格式,例如:

Alternatively you can use some LaTeX package to change the formatting of figure numbers, e.g.:

---
header-includes:
  \usepackage{chngcntr}
  \counterwithin{figure}{section}
output:
  bookdown::pdf_document2: default
  bookdown::word_document2: default
  bookdown::html_document2: default
---

另一种选择是 amsmath 中的 \numberwithin 命令,以防您无论如何都在使用该软件包.

An alternative would be the \numberwithin command from amsmath in case you are using that package anyway.

这篇关于为什么用点分隔的两位数字只在html_document2中显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆