From 18964ed8a2c033f289936c4b75e1706e00c914b3 Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 11:49:36 +0800 Subject: [PATCH 01/19] wip --- TeXmacs/packages/custom/appendix-toc.ts | 96 ++++++++++++++++++++ devel/222_54.md | 115 ++++++++++++++++++++++++ 2 files changed, 211 insertions(+) create mode 100644 TeXmacs/packages/custom/appendix-toc.ts create mode 100644 devel/222_54.md diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts new file mode 100644 index 0000000000..e91821408d --- /dev/null +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -0,0 +1,96 @@ + + +> + +<\body> + + + + <\src-purpose> + Support for independent table of contents in appendix sections. + This package allows creating a separate table of contents that only + includes appendix chapters, sections, and subsections. + + + + + <\src-license> + This software falls under the . It comes WITHOUT ANY + WARRANTY WHATSOEVER. You should have received a copy of the license + which the software. If not, see . + + > + + <\active*> + <\src-comment> + Appendix table of contents support. + + Usage: + 1. Add to your document + 2. Use to start appendix sections + 3. Use to display appendix-only TOC + + The appendix sections will be written to "appendix-toc" prefix + instead of the default "toc" prefix, creating an independent TOC. + + + + ;; Redefine appendix to use "appendix-toc" prefix for TOC entries + > + |the-section|the-chapter>>>> + + + |> + ;; Write to appendix-toc instead of default toc + |>> + | + |> + |> + > + > + > + > + >> + + ;; Appendix section - also uses appendix-toc prefix + > + > + >> + + ;; Appendix subsection - also uses appendix-toc prefix + > + > + >> + + ;; Appendix subsubsection - also uses appendix-toc prefix + > + > + >> + + ;; Convenient macro to display appendix table of contents + > + >> + + ;; Alternative: use with-toc to wrap any content with custom TOC prefix + |> + >> + + +<\initial> + <\collection> + + + diff --git a/devel/222_54.md b/devel/222_54.md new file mode 100644 index 0000000000..6c8b68d94e --- /dev/null +++ b/devel/222_54.md @@ -0,0 +1,115 @@ +# [222_54] 添加附录子目录 (appendix-toc) 宏包 + +## 如何测试 + +### 测试场景 1:基本附录子目录功能 +1. 创建新文档,使用 `article` 或 `book` 样式 +2. 添加 `` +3. 添加正文章节: + ``` + + + ``` +4. 插入主目录:`>` +5. 添加附录:`` +6. 在附录内添加子章节:`` +7. 插入附录子目录:`` + +### 测试场景 2:多个附录章节 +1. 创建包含多个附录的文档 +2. 验证每个附录章节都出现在附录子目录中 +3. 验证正文章节不出现在附录子目录中 + +### 测试场景 3:使用 with-subtoc 宏 +1. 在文档中使用: + ``` + + + > + > + ``` +2. 验证特殊范围内的章节只出现在对应的子目录中 + +## 2025/03/11 实现附录子目录宏包 + +### What +创建了 `appendix-toc.ts` 宏包,位于 `TeXmacs/packages/custom/`,提供以下功能: +- `` - 重定义的附录命令,使用 "appendix-toc" 前缀 +- `` - 附录内的 section,使用 "appendix-toc" 前缀 +- `` - 附录内的 subsection,使用 "appendix-toc" 前缀 +- `` - 附录内的 subsubsection,使用 "appendix-toc" 前缀 +- `` - 显示只包含附录章节的子目录 +- `` - 通用宏,用于创建任意范围的子目录 + +### Why +- 原系统所有章节标题都写入同一个 `local_aux["toc"]`,无法实现范围限定的子目录 +- 用户需要在附录范围内有一个独立的目录,只包含附录章节 +- 通过切换 `toc-prefix` 参数,可以实现任意范围的子目录 + +### How +1. 利用现有的 `with-toc` 宏切换 `toc-prefix`: + ```ts + |>>> + ``` + +2. 重定义 `appendix` 宏,包装在 `with|toc-prefix|appendix-toc` 中: + ```ts + |>> + > + >> + ``` + +3. 附录内的 section/subsection 同样使用 `with|toc-prefix|appendix-toc` 包装 + +4. 核心原理: + - `toc-entry` 宏使用 `|...>` 写入 aux 数据 + - 通过 `with|toc-prefix|` 临时改变前缀 + - 不同前缀的数据存储在独立的 `local_aux` 键中 + - `` 只读取 "appendix-toc" 键的数据 + +## 使用示例 + +### 示例 1:基本用法 +```ts + + +;; 正文部分 - 写入默认 "toc" + + + +;; 显示主目录 +> + +;; 附录部分 - 自动使用 "appendix-toc" 前缀 + + + + +;; 显示附录子目录(只包含附录章节) + +``` + +### 示例 2:使用 with-subtoc 创建自定义范围 +```ts + + +;; 第一部分 - 使用 "part1-toc" 前缀 + + + +> +> + +;; 第二部分 - 使用 "part2-toc" 前缀 + + + +> +> +``` From d6f616ace3b6bd9042e5a3182896e9e52dad794b Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 12:03:12 +0800 Subject: [PATCH 02/19] fix --- TeXmacs/packages/custom/appendix-toc.ts | 93 ++++++++----------------- 1 file changed, 30 insertions(+), 63 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index e91821408d..fa85ce53ec 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -1,4 +1,4 @@ - + > @@ -7,9 +7,9 @@ <\src-purpose> - Support for independent table of contents in appendix sections. - This package allows creating a separate table of contents that only - includes appendix chapters, sections, and subsections. + Support for independent table of contents in appendix sections. This + package allows creating a separate table of contents that only includes + appendix chapters, sections, and subsections. @@ -22,75 +22,42 @@ > - <\active*> - <\src-comment> - Appendix table of contents support. - - Usage: - 1. Add to your document - 2. Use to start appendix sections - 3. Use to display appendix-only TOC - - The appendix sections will be written to "appendix-toc" prefix - instead of the default "toc" prefix, creating an independent TOC. - - + + > + |the-section|the-chapter>>>> + |>|>>| |> + |> + > - ;; Redefine appendix to use "appendix-toc" prefix for TOC entries - > - |the-section|the-chapter>>>> - - - |> - ;; Write to appendix-toc instead of default toc - |>> - | - |> - |> - > - > - > - > - >> + + >.>>>>|>|>> + > - ;; Appendix section - also uses appendix-toc prefix - > - > - >> + + >> + > - ;; Appendix subsection - also uses appendix-toc prefix - > - > - >> + + >> + > - ;; Appendix subsubsection - also uses appendix-toc prefix - > - > - >> + + >> + > - ;; Convenient macro to display appendix table of contents - > - >> + + \; + >> - ;; Alternative: use with-toc to wrap any content with custom TOC prefix - |> - >> + > <\initial> <\collection> - + \ No newline at end of file From b69b03297d416c8423767dfe6ba5d0beb8667feb Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 12:06:09 +0800 Subject: [PATCH 03/19] =?UTF-8?q?[222=5F54]=20=E4=BF=AE=E5=A4=8D=20appendi?= =?UTF-8?q?x=20=E5=AE=8F=EF=BC=8C=E6=B7=BB=E5=8A=A0=20toc-prefix=20?= =?UTF-8?q?=E5=8C=85=E8=A3=85=E5=B9=B6=E5=88=A0=E9=99=A4=20backup?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/custom/appendix-toc.ts | 19 +++++++++---------- 1 file changed, 9 insertions(+), 10 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index fa85ce53ec..495f0d1433 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -22,17 +22,16 @@ > - - > - |the-section|the-chapter>>>> - |>|>>| |> - |> - > - - >.>>>>|>|>> + > + .>> + + + > + > + |>|>> + >> > From 73210684335dc8b741e4e07015e06a55cbab4bea Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 12:13:40 +0800 Subject: [PATCH 04/19] wip --- TeXmacs/packages/custom/appendix-toc.ts | 10 +--------- 1 file changed, 1 insertion(+), 9 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 495f0d1433..bb1e289caf 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -23,15 +23,7 @@ > - > - .>> - - - > - > - |>|>> - >> + >.>>>>|>|>>> > From 872cf72c44813860ee0a61f4e1ed19c16d755504 Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 12:16:05 +0800 Subject: [PATCH 05/19] =?UTF-8?q?[222=5F54]=20=E4=BF=AE=E5=A4=8D=20appendi?= =?UTF-8?q?x=20=E5=AE=8F=EF=BC=8C=E5=90=8C=E6=97=B6=E5=86=99=E5=85=A5?= =?UTF-8?q?=E4=B8=BB=E7=9B=AE=E5=BD=95=E5=92=8C=E5=AD=90=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/custom/appendix-toc.ts | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index bb1e289caf..b1749a75ab 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -22,8 +22,22 @@ > + ;; 附录章节:同时写入主目录(toc)和子目录(appendix-toc) - >.>>>>|>|>>> + >> + ;; 再写入子目录 + > + .>> + + + > + > + |>|>> + >> + > > From 8a9e103801da024dcf3964999810bb07ebd3fd34 Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 12:18:09 +0800 Subject: [PATCH 06/19] =?UTF-8?q?[222=5F54]=20=E4=BF=AE=E5=A4=8D=20appendi?= =?UTF-8?q?x=20=E5=AE=8F=EF=BC=8C=E5=8F=AA=E5=86=99=E5=85=A5=E4=B8=BB?= =?UTF-8?q?=E7=9B=AE=E5=BD=95=EF=BC=8C=E4=B8=8D=E5=86=99=E5=85=A5=E5=AD=90?= =?UTF-8?q?=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/custom/appendix-toc.ts | 21 +++++++++------------ 1 file changed, 9 insertions(+), 12 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index b1749a75ab..b7e3817eca 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -22,21 +22,18 @@ > - ;; 附录章节:同时写入主目录(toc)和子目录(appendix-toc) + ;; 附录章节:只写入主目录(toc),不写入子目录(appendix-toc) >> - ;; 再写入子目录 - > - .>> - - - > - > - |>|>> - >> + ;; 显示标题(不写入子目录) + > + .>> + + + > + |>|>> > > From 46e8dd78ad6dc1db511ec9a5848242d0e34aadd2 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 12:22:23 +0800 Subject: [PATCH 07/19] wip-1 --- TeXmacs/packages/custom/appendix-toc.ts | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index b7e3817eca..ad1b894e9b 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -22,19 +22,8 @@ > - ;; 附录章节:只写入主目录(toc),不写入子目录(appendix-toc) - >> - ;; 显示标题(不写入子目录) - > - .>> - - - > - |>|>> - > + >>>.>>>|>|>>> > From 9f86b548776164dfcc11bf8d379c766763e362b2 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 12:36:29 +0800 Subject: [PATCH 08/19] wip-2 --- TeXmacs/packages/custom/appendix-toc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index ad1b894e9b..b42f4f4f74 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -27,15 +27,15 @@ > - >> + >> > - >> + >> > - >> + >> > From 666a23cab7cadde9d2e07c607b0a1bf338287050 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 15:00:03 +0800 Subject: [PATCH 09/19] wip-3 --- TeXmacs/packages/custom/appendix-toc.ts | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index b42f4f4f74..3ad2aea736 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -38,9 +38,11 @@ >> > - - \; - >> + |>>|||>>>>>>> + + |>>|||>>>>>>> + + |>>|>>>> |> From 3aedade6172513a6ce7557637b8c55dcc1bd9486 Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 15:04:07 +0800 Subject: [PATCH 10/19] =?UTF-8?q?[222=5F54]=20=E7=AE=80=E5=8C=96=20section?= =?UTF-8?q?-toc/subsection-toc=EF=BC=8C=E4=BD=BF=E7=94=A8=E6=9B=B4?= =?UTF-8?q?=E9=AB=98=E7=BA=A7=E5=88=AB=E7=9A=84=20toc=20=E6=A0=B7=E5=BC=8F?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/custom/appendix-toc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 3ad2aea736..a8dda1e720 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -38,11 +38,11 @@ >> > - |>>|||>>>>>>> + >>>> - |>>|||>>>>>>> + >>>>> - |>>|>>>> + >>>> |> From 1ac65b0adf601e26d1e296a75e30faf53594f0db Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 15:32:32 +0800 Subject: [PATCH 11/19] wip --- TeXmacs/packages/custom/appendix-toc.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index a8dda1e720..3deebd9522 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -27,22 +27,22 @@ > - >> + >>>> > - >> + >>>> > - >> + >>>> > - >>>> + >>>> - >>>>> + >>>> - >>>> + >>>> |> From 68bbd3bcd7c666b090650d2d5eaca15aa86b71eb Mon Sep 17 00:00:00 2001 From: Soyo Date: Wed, 11 Mar 2026 15:44:16 +0800 Subject: [PATCH 12/19] =?UTF-8?q?[222=5F54]=20=E4=BF=AE=E5=A4=8D=20appendi?= =?UTF-8?q?x-section-toc=20=E7=AD=89=EF=BC=8C=E6=89=8B=E5=8A=A8=E6=9E=84?= =?UTF-8?q?=E5=BB=BA=E6=A0=87=E9=A2=98=E4=BB=A5=E6=98=BE=E7=A4=BA=E6=AD=A3?= =?UTF-8?q?=E7=A1=AE=E7=BC=96=E5=8F=B7?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/packages/custom/appendix-toc.ts | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 3deebd9522..0fb6765315 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -38,11 +38,11 @@ >>>> > - >>>> + >>>>> - >>>> + >>>>> - >>>> + >>>>> |> From ec4dd05a1f75859f3147649ca3f19d4b0c3cfbdd Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 15:59:26 +0800 Subject: [PATCH 13/19] wip --- TeXmacs/packages/custom/appendix-toc.ts | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 0fb6765315..7ae73512ef 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -38,11 +38,17 @@ >>>> > - >>>>> + + > + > - >>>>> + + > + > - >>>>> + + > + > |> From 0537a3ce99bcda5762489f63425e4695a9005cf3 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 16:38:59 +0800 Subject: [PATCH 14/19] wip-5 --- TeXmacs/packages/custom/appendix-toc.ts | 18 +++--------------- 1 file changed, 3 insertions(+), 15 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 7ae73512ef..decb25fb0a 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -27,27 +27,15 @@ > - >>>> + >>> > - >>>> + >>> > - >>>> - > - - - > - > - - - > - > - - - > + >>> > From 4bac9f3fbba6e128382c40c0085debcd0be94768 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 18:39:23 +0800 Subject: [PATCH 15/19] wip --- TeXmacs/packages/custom/appendix-toc.ts | 13 +++- TeXmacs/packages/section/section-base.ts | 2 + TeXmacs/plugins/lang/dic/en_US/zh_CN.scm | 1 + TeXmacs/progs/text/text-menu.scm | 9 +++ TeXmacs/tests/tmu/222_54.tmu | 81 ++++++++++++++++++++++++ devel/222_54.md | 43 ------------- 6 files changed, 105 insertions(+), 44 deletions(-) create mode 100644 TeXmacs/tests/tmu/222_54.tmu diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index decb25fb0a..687bfbaf87 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -12,7 +12,7 @@ appendix chapters, sections, and subsections. - + <\src-license> This software falls under the |> > + + + ||>|> + > + + + |section-toc||>> + + > + > + <\initial> diff --git a/TeXmacs/packages/section/section-base.ts b/TeXmacs/packages/section/section-base.ts index 13c1d3c6c9..bf3e8511e0 100644 --- a/TeXmacs/packages/section/section-base.ts +++ b/TeXmacs/packages/section/section-base.ts @@ -56,6 +56,8 @@ >> + >> + >> >> diff --git a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm index a7497e5621..788a087d38 100644 --- a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm +++ b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm @@ -4,6 +4,7 @@ ("Advanced page numbering" "高级页码") ("Allow multiple spaces" "允许多个空格") ("Angle brackets ⟨ ⟩" "尖括号 ⟨ ⟩") +("Appendix Table of Contents" "附录目录") ("Applying from" "起始于") ("Applying to" "结束于") ("As" "作为") diff --git a/TeXmacs/progs/text/text-menu.scm b/TeXmacs/progs/text/text-menu.scm index ba6ccc20f9..335e6512d1 100644 --- a/TeXmacs/progs/text/text-menu.scm +++ b/TeXmacs/progs/text/text-menu.scm @@ -135,6 +135,10 @@ ("Subparagraph" (make-section 'subparagraph)) --- ("Appendix" (make-section 'appendix)) + (if (style-has? "appendix-toc") + ("Appendix section" (make-section 'appendix-section)) + ("Appendix subsection" (make-section 'appendix-subsection)) + ("Appendix subsubsection" (make-section 'appendix-subsubsection))) ("Prologue::menu" (begin (make-unnamed-section 'prologue) @@ -471,6 +475,11 @@ (begin (make-aux "table-of-contents" "toc-prefix" "toc") (update-document "all"))) + (if (style-has? "appendix-toc") + ("Appendix Table of Contents" + (begin + (make-aux "table-of-contents" "toc-prefix" "appendix-toc") + (update-document "all")))) ("Bibliography" (open-bibliography-inserter)) ("Index" (begin diff --git a/TeXmacs/tests/tmu/222_54.tmu b/TeXmacs/tests/tmu/222_54.tmu new file mode 100644 index 0000000000..e65cb9ca2f --- /dev/null +++ b/TeXmacs/tests/tmu/222_54.tmu @@ -0,0 +1,81 @@ +> + +> + +<\body> + <\hide-preamble> + >>>> + + + <\table-of-contents|toc> + chapter>|.>>>>|> + + section|.>>>>|>> + + subsection|.>>>>|>> + + appendix>|.>>>>|> + + + + + + + + + \; + + + + <\table-of-contents|appendix-toc> + section>|.>>>>|> + + subsecton|.>>>>|>> + + + <\appendix-section> + section + + + <\appendix-subsection> + subsecton + + + +<\initial> + <\collection> + + + > + + + +<\references> + <\collection> + > + > + > + > + > + > + + + +<\auxiliary> + <\collection> + <\associate|appendix-toc> + |math-font-series||A.1section>|.>>>>|> + + |A.1.1subsecton|.>>>>|>> + + <\associate|toc> + |math-font-series||第 1 章chapter>|.>>>>|> + + |1.1section|.>>>>|>> + + |1.1.1subsection|.>>>>|>> + + |math-font-series||附录appendix>|.>>>>|> + + + diff --git a/devel/222_54.md b/devel/222_54.md index 6c8b68d94e..a02ff9bc0a 100644 --- a/devel/222_54.md +++ b/devel/222_54.md @@ -70,46 +70,3 @@ - 通过 `with|toc-prefix|` 临时改变前缀 - 不同前缀的数据存储在独立的 `local_aux` 键中 - `` 只读取 "appendix-toc" 键的数据 - -## 使用示例 - -### 示例 1:基本用法 -```ts - - -;; 正文部分 - 写入默认 "toc" - - - -;; 显示主目录 -> - -;; 附录部分 - 自动使用 "appendix-toc" 前缀 - - - - -;; 显示附录子目录(只包含附录章节) - -``` - -### 示例 2:使用 with-subtoc 创建自定义范围 -```ts - - -;; 第一部分 - 使用 "part1-toc" 前缀 - - - -> -> - -;; 第二部分 - 使用 "part2-toc" 前缀 - - - -> -> -``` From 7c42526633aa0b2e14000b03e8f1f752e2e08e59 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 19:12:57 +0800 Subject: [PATCH 16/19] =?UTF-8?q?=E9=99=84=E5=BD=95=E7=9B=AE=E5=BD=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- TeXmacs/plugins/lang/dic/en_US/zh_CN.scm | 5 ++- TeXmacs/progs/text/text-menu.scm | 8 ++--- devel/222_54.md | 43 +++++++----------------- 3 files changed, 21 insertions(+), 35 deletions(-) diff --git a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm index 788a087d38..e63c086b61 100644 --- a/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm +++ b/TeXmacs/plugins/lang/dic/en_US/zh_CN.scm @@ -4,7 +4,10 @@ ("Advanced page numbering" "高级页码") ("Allow multiple spaces" "允许多个空格") ("Angle brackets ⟨ ⟩" "尖括号 ⟨ ⟩") -("Appendix Table of Contents" "附录目录") +("Appendix section" "附录节") +("Appendix subsection" "附录子节") +("Appendix subsubsection" "附录小节") +("Appendix table of contents" "附录目录") ("Applying from" "起始于") ("Applying to" "结束于") ("As" "作为") diff --git a/TeXmacs/progs/text/text-menu.scm b/TeXmacs/progs/text/text-menu.scm index 335e6512d1..056ea1c03a 100644 --- a/TeXmacs/progs/text/text-menu.scm +++ b/TeXmacs/progs/text/text-menu.scm @@ -135,7 +135,7 @@ ("Subparagraph" (make-section 'subparagraph)) --- ("Appendix" (make-section 'appendix)) - (if (style-has? "appendix-toc") + (if (has-style-package? "appendix-toc") ("Appendix section" (make-section 'appendix-section)) ("Appendix subsection" (make-section 'appendix-subsection)) ("Appendix subsubsection" (make-section 'appendix-subsubsection))) @@ -475,10 +475,10 @@ (begin (make-aux "table-of-contents" "toc-prefix" "toc") (update-document "all"))) - (if (style-has? "appendix-toc") - ("Appendix Table of Contents" + (if (has-style-package? "appendix-toc") + ("Appendix table of contents" (begin - (make-aux "table-of-contents" "toc-prefix" "appendix-toc") + (insert `(table-of-contents "appendix-toc" (document ""))) (update-document "all")))) ("Bibliography" (open-bibliography-inserter)) ("Index" diff --git a/devel/222_54.md b/devel/222_54.md index a02ff9bc0a..c865c67554 100644 --- a/devel/222_54.md +++ b/devel/222_54.md @@ -1,35 +1,19 @@ -# [222_54] 添加附录子目录 (appendix-toc) 宏包 +# [222_54] 添加附录目录 (appendix-toc) 宏包 ## 如何测试 +- 打开测试文件`TeXmacs/tests/tmu/222_54.tmu` + - 检查效果 +- 新建文件 + - 查看 `插入->自动`里是否有 附录目录 + - 查看 `插入->章节`里是否有 附录节 附录子节 附录小节 + - 测试使用 + - 结构如下 + |- + |- + |- + |- + |- -### 测试场景 1:基本附录子目录功能 -1. 创建新文档,使用 `article` 或 `book` 样式 -2. 添加 `` -3. 添加正文章节: - ``` - - - ``` -4. 插入主目录:`>` -5. 添加附录:`` -6. 在附录内添加子章节:`` -7. 插入附录子目录:`` - -### 测试场景 2:多个附录章节 -1. 创建包含多个附录的文档 -2. 验证每个附录章节都出现在附录子目录中 -3. 验证正文章节不出现在附录子目录中 - -### 测试场景 3:使用 with-subtoc 宏 -1. 在文档中使用: - ``` - - - > - > - ``` -2. 验证特殊范围内的章节只出现在对应的子目录中 ## 2025/03/11 实现附录子目录宏包 @@ -39,7 +23,6 @@ - `` - 附录内的 section,使用 "appendix-toc" 前缀 - `` - 附录内的 subsection,使用 "appendix-toc" 前缀 - `` - 附录内的 subsubsection,使用 "appendix-toc" 前缀 -- `` - 显示只包含附录章节的子目录 - `` - 通用宏,用于创建任意范围的子目录 ### Why From 5d928de50294554e65bb3448ad0b1cf94f9646fa Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 19:17:49 +0800 Subject: [PATCH 17/19] wip --- devel/222_54.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/devel/222_54.md b/devel/222_54.md index c865c67554..d3325656c8 100644 --- a/devel/222_54.md +++ b/devel/222_54.md @@ -6,6 +6,8 @@ - 新建文件 - 查看 `插入->自动`里是否有 附录目录 - 查看 `插入->章节`里是否有 附录节 附录子节 附录小节 + - 点击工具栏 `增加宏包->custom->appendix-toc`,添加本宏包 + - 重复查看上述部分 - 测试使用 - 结构如下 |- From f34519c12f8c78b955e989af5505505bf931e818 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 23:35:15 +0800 Subject: [PATCH 18/19] Update appendix-toc.ts --- TeXmacs/packages/custom/appendix-toc.ts | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/TeXmacs/packages/custom/appendix-toc.ts b/TeXmacs/packages/custom/appendix-toc.ts index 687bfbaf87..719484b9ad 100644 --- a/TeXmacs/packages/custom/appendix-toc.ts +++ b/TeXmacs/packages/custom/appendix-toc.ts @@ -22,10 +22,6 @@ > - - >>>.>>>|>|>>> - > - >>> > @@ -58,4 +54,4 @@ <\collection> - \ No newline at end of file + From 28f31e55467d5b88aa123e80ebeba26e13c9f859 Mon Sep 17 00:00:00 2001 From: Yuki Date: Wed, 11 Mar 2026 23:37:46 +0800 Subject: [PATCH 19/19] Update 222_54.md --- devel/222_54.md | 16 +++------------- 1 file changed, 3 insertions(+), 13 deletions(-) diff --git a/devel/222_54.md b/devel/222_54.md index d3325656c8..190fffd7d7 100644 --- a/devel/222_54.md +++ b/devel/222_54.md @@ -1,6 +1,7 @@ # [222_54] 添加附录目录 (appendix-toc) 宏包 ## 如何测试 +- 涉及ts文件的需要先清理缓存 - 打开测试文件`TeXmacs/tests/tmu/222_54.tmu` - 检查效果 - 新建文件 @@ -21,7 +22,6 @@ ### What 创建了 `appendix-toc.ts` 宏包,位于 `TeXmacs/packages/custom/`,提供以下功能: -- `` - 重定义的附录命令,使用 "appendix-toc" 前缀 - `` - 附录内的 section,使用 "appendix-toc" 前缀 - `` - 附录内的 subsection,使用 "appendix-toc" 前缀 - `` - 附录内的 subsubsection,使用 "appendix-toc" 前缀 @@ -38,19 +38,9 @@ |>>> ``` -2. 重定义 `appendix` 宏,包装在 `with|toc-prefix|appendix-toc` 中: - ```ts - |>> - > - >> - ``` - -3. 附录内的 section/subsection 同样使用 `with|toc-prefix|appendix-toc` 包装 +2. 附录内的 section/subsection 同样使用 `with|toc-prefix|appendix-toc` 包装 -4. 核心原理: +3. 核心原理: - `toc-entry` 宏使用 `|...>` 写入 aux 数据 - 通过 `with|toc-prefix|` 临时改变前缀 - 不同前缀的数据存储在独立的 `local_aux` 键中