From af83c43fb0d1b0b842ce5c621419707cfdcf89b9 Mon Sep 17 00:00:00 2001 From: qingxu fu <505030475@qq.com> Date: Wed, 18 Oct 2023 16:33:14 +0800 Subject: [PATCH] =?UTF-8?q?=E8=A1=A5=E5=85=85=E7=BC=BA=E5=A4=B1=E6=91=98?= =?UTF-8?q?=E8=A6=81=E7=9A=84=E6=8E=AA=E6=96=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- crazy_functions/latex_fns/latex_toolbox.py | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/crazy_functions/latex_fns/latex_toolbox.py b/crazy_functions/latex_fns/latex_toolbox.py index e5484ca..0d5554f 100644 --- a/crazy_functions/latex_fns/latex_toolbox.py +++ b/crazy_functions/latex_fns/latex_toolbox.py @@ -366,6 +366,14 @@ def insert_abstract(tex_content): # insert "abs_str" on the next line modified_tex = tex_content[:end_line_index+1] + '\n\n' + insert_missing_abs_str + '\n\n' + tex_content[end_line_index+1:] return modified_tex + elif r"\begin{document}" in tex_content: + # find the position of "\maketitle" + find_index = tex_content.index(r"\begin{document}") + # find the nearest ending line + end_line_index = tex_content.find("\n", find_index) + # insert "abs_str" on the next line + modified_tex = tex_content[:end_line_index+1] + '\n\n' + insert_missing_abs_str + '\n\n' + tex_content[end_line_index+1:] + return modified_tex else: return tex_content