37 lines
1.8 KiB
Python
37 lines
1.8 KiB
Python
notetitle = "2026届高一上学期周末卷06" #讲义标题, 也是文件标题
|
|
problems = ["022323,022324,022325,022326,022327,022328,022329,022330,022331,022338,022339,022332,022333,022336,022337,022340"] #题号列表, 每个字符串表示一个分块的题目
|
|
sectiontitles = ["集合与逻辑","等式与不等式","幂、指数与对数","幂函数、指数函数与对数函数","函数的概念、性质及应用","数列"] #小节标题列表, 如果与题号列表长度不符则作为不设小节处理
|
|
consecutivenumbering = True #不同小节是否连续编号, True表示连续编号, False表示每小节从1开始编号
|
|
answered = False #是否展示答案, True表示展示答案, False表示不展示答案
|
|
spaceflag = True #是否留空格, True表示留空格, False表示不留空格
|
|
|
|
|
|
|
|
from database_tools import *
|
|
|
|
prodictpath = "../题库0.3/Problems.json"
|
|
pro_dict = load_dict(prodictpath)
|
|
|
|
outputdir = "临时文件" #输出文件的目录
|
|
outputfilepath = os.path.join(outputdir,notetitle+".tex")
|
|
print("输出文件目录: %s\n输出文件名: %s"%(os.path.join(os.getcwd(),outputdir),notetitle+".tex"))
|
|
|
|
latex_raw = ReadTextFile("模板文件/讲义模板.txt")
|
|
|
|
if sys.platform != "win32": #非win系统用默认字体
|
|
latex_raw = re.sub(r"fontset[\s]*=[\s]*none","fontset = fandol",latex_raw)
|
|
latex_raw = re.sub(r"\\setCJKmainfont",r"% \\setCJKmainfont",latex_raw)
|
|
|
|
|
|
bodystring = GenerateStudentBodyString(problems,sectiontitles,pro_dict,consecutivenumbering,answered,spaceflag) #生成.tex中的内容主体字符串, 用于替换模板中的相应部分
|
|
|
|
latex_data = StringSubstitute(r"<<[\s\S]*?待替换[\s\S]*?>>",latex_raw,(notetitle,bodystring)) #替换标题和bodystring
|
|
SaveTextFile(latex_data,outputfilepath) #保存.tex文件
|
|
|
|
if XeLaTeXCompile(outputdir,notetitle+".tex"):
|
|
print("编译成功")
|
|
else:
|
|
print("编译失败")
|
|
|
|
|