pandoc markdown在不同文件之间保留部分数字

发布于 2025-01-17 19:15:56 字数 1218 浏览 2 评论 0原文

是否可以在不同文件之间保留节编号?

例如,我有这个文件:

 ---
 title: Title
 number_sections: true
 output: latex
 graphics: yes
 header-includes:
   - '\usepackage{graphics}'
 ---
           
    # Section 1
    
    ## SUbsection
    
    # Section 2

输出文件(pdf)将具有以下编号:

1 Section 1
1.1 Subsection
2 Section 2

如果我有第二个文件,例如:

 ---
 title: Title
 number_sections: true
 output: latex
 graphics: yes
 header-includes:
   - '\usepackage{graphics}'
 ---
    
    # Section 3

输出文件(pdf)将具有以下编号:

1 Section 3

但我希望它是这样的:

3 Section 3

唯一的我现在找到的解决方法是重复以前文件的内容:

---
title: Title
number_sections: true
output: latex
graphics: yes
header-includes:
  - '\usepackage{graphics}'
---

# Section 1

## SUbsection

# Section 2

## Another subsection

\newpage

# Section 3

The new content

这给出了一个 pdf 文件,例如:

1 Section 1
1.1 Subsection
2 Section 2

3 Section 3
New content...

我也可以保留小节的编号。

我正在编译:

pandoc file.md -o file.pdf --pdf-engine=xelatex --number-sections --highlight-style tango

感谢任何帮助。

Is it possible to keep section numeration between different files?

For instance, I have this file:

 ---
 title: Title
 number_sections: true
 output: latex
 graphics: yes
 header-includes:
   - '\usepackage{graphics}'
 ---
           
    # Section 1
    
    ## SUbsection
    
    # Section 2

The output file (pdf) will have the following numeration:

1 Section 1
1.1 Subsection
2 Section 2

If I have a 2nd file like:

 ---
 title: Title
 number_sections: true
 output: latex
 graphics: yes
 header-includes:
   - '\usepackage{graphics}'
 ---
    
    # Section 3

The output file (pdf) will have the following numeration:

1 Section 3

But I wanted it to be like:

3 Section 3

The only workaround I found for now is to repeat the content of previous files:

---
title: Title
number_sections: true
output: latex
graphics: yes
header-includes:
  - '\usepackage{graphics}'
---

# Section 1

## SUbsection

# Section 2

## Another subsection

\newpage

# Section 3

The new content

Which gives a pdf file like:

1 Section 1
1.1 Subsection
2 Section 2

3 Section 3
New content...

I would also be able to keep numeration of subsections as well.

I'm compiling with:

pandoc file.md -o file.pdf --pdf-engine=xelatex --number-sections --highlight-style tango

Any help is appreciated.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

东走西顾 2025-01-24 19:15:56

正如@tarleb建议的那样

\setcounter{section}{3}

\setcounter{subsection}{3}

手动完成工作。

As suggested by @tarleb

\setcounter{section}{3}

and

\setcounter{subsection}{3}

get the job done manually.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文