From 5d513c1bfc4680b5074091613676822723000ccf Mon Sep 17 00:00:00 2001 From: Ivanfei Date: Mon, 20 May 2024 17:59:45 +0800 Subject: [PATCH] feat: append and prepend pdf as covers --- docs/main.tex | 10 +++++++--- source/fduthesis.dtx | 47 ++++++++++++++++++++++++++++++++++++++++---- 2 files changed, 50 insertions(+), 7 deletions(-) diff --git a/docs/main.tex b/docs/main.tex index 8c9dbcd..5615bac 100644 --- a/docs/main.tex +++ b/docs/main.tex @@ -145,9 +145,13 @@ % 插入扫描版的声明页 PDF 文档 % 默认使用预定义的声明页,但不带签名 % - % auto-make-cover = true - % 是否自动生成论文封面(封一)、指导小组成员名单(封二)和声明页(封三) - % 除非特殊需要(e.g. 不要封面),否则不建议设为 false + % prepend-cover = {prepend-cover.pdf} + % 插入预先生成的封面 PDF 到文档首,包括论文封面(封一)、论文撰写人承诺书(封二)等 + % 将 PDF 文档放入 thesis 文件夹下 + % + % append-cover = {append-cover.pdf} + % 插入预先生成的封底 PDF 到文档尾,包括教师审查意见(封三)等 + % 将 PDF 文档放入 thesis 文件夹下 }, % % info 类用于录入论文信息 diff --git a/source/fduthesis.dtx b/source/fduthesis.dtx index 02bf17f..24b6806 100644 --- a/source/fduthesis.dtx +++ b/source/fduthesis.dtx @@ -5263,10 +5263,12 @@ Copyright (C) 2017–2024 by Xiangdong Zeng . } % \end{macrocode} % -% \begin{variable}{\l_@@_auto_make_cover_bool,\l_@@_declaration_page_tl} +% \begin{variable}{\l_@@_auto_make_cover_bool,\l_@@_declaration_page_tl, \l_@@_prepend_cover_tl, \l_@@_append_cover_tl} % \begin{macrocode} \bool_new:N \l_@@_auto_make_cover_bool \tl_new:N \l_@@_declaration_page_tl +\tl_new:N \l_@@_prepend_cover_tl +\tl_new:N \l_@@_append_cover_tl % \end{macrocode} % \end{variable} % @@ -5276,7 +5278,7 @@ Copyright (C) 2017–2024 by Xiangdong Zeng . \keys_define:nn { fdu / style } { auto-make-cover .bool_set:N = \l_@@_auto_make_cover_bool, - auto-make-cover .default:n = true, + auto-make-cover .default:n = false, % \end{macrocode} % \end{macro} % @@ -5290,6 +5292,28 @@ Copyright (C) 2017–2024 by Xiangdong Zeng . \tl_set_eq:NN \l_@@_declaration_page_tl \l_keys_value_tl \RequirePackage { pdfpages } }, +% \end{macrocode} +% +% \begin{macro}{style/declaration-page} +% 插入预先生成的封面 PDF 到文档首,包括论文封面(封一)、论文撰写人承诺书(封二)等 +% 仅当 auto-make-cover = false 时有效 +% \begin{macrocode} + prepend-cover .code:n = + { + \tl_set_eq:NN \l_@@_prepend_cover_tl \l_keys_value_tl + \RequirePackage { pdfpages } + }, +% \end{macrocode} +% +% \begin{macro}{style/declaration-page} +% 插入预先生成的封底 PDF 到文档尾,包括教师审查意见(封三)等 +% 仅当 auto-make-cover = false 时有效 +% \begin{macrocode} + append-cover .code:n = + { + \tl_set_eq:NN \l_@@_append_cover_tl \l_keys_value_tl + \RequirePackage { pdfpages } + }, } % \end{macrocode} % \end{macro} @@ -5298,12 +5322,27 @@ Copyright (C) 2017–2024 by Xiangdong Zeng . % \begin{macrocode} \ctex_after_end_preamble:n { - \bool_if:NT \l_@@_auto_make_cover_bool + \bool_if:NTF \l_@@_auto_make_cover_bool { \begin{titlepage} \makecoveri \newpage \makecoverii \end{titlepage} } + { + \begin{titlepage} + \thispagestyle { empty } + \tl_set:Nn \thepage { A } + \tl_if_empty:NTF \l_@@_prepend_cover_tl + { \empty } + { + % separate each pdf file with a comma + \tl_set:Nn \l_tmpa_tl { \l_@@_prepend_cover_tl } + \tl_replace_all:Nnn \l_tmpa_tl { , } { } + + \includepdf { \l_@@_prepend_cover_tl } + } + \end{titlepage} + } } % \end{macrocode} % @@ -6044,7 +6083,7 @@ Copyright (C) 2017–2024 by Xiangdong Zeng . % style / cjk-font = fandol, style / font-size = -4, % style / fullwidth-stop = false, - style / auto-make-cover = true, + style / auto-make-cover = false, style / logo = { fudan-name.pdf }, style / logo-size = { 0.5 \textwidth }, style / hyperlink = color,