先生成该表格:
# In[1]
import pandas as pd
import os
df = pd.read_excel(‘list.xlsx‘)
ids = df[‘Pap ID‘].to_list()
lens = df[‘Page Length‘].to_list()
titles = df[‘Pap Title ‘].to_list()
cor_authors = df[‘Corresponding Author‘].to_list()
authors = df[‘Authors‘].to_list()
emails = df[‘Corresponding Author Email‘].to_list()
affs = df[‘Affiliation‘].to_list()
affs
# In[1]
f = open(‘latex_mode.txt‘, ‘w+‘, encoding=‘utf-8‘)
Name = ‘LNAI‘
page = 12430
cor_mod = ‘{0}\\thanks{{\\mbox{{Corresponding author}}}}‘
latex_mod = """\setcounter{{page}}{{{0}}}
\\title{{{1}}}
\\author{{{2}}}
\\tocauthor{{{3}}}
{4}
\\institute{{{5}\\\ \\email{{{6}}}}}
\\maketitle
\\clearpage
"""
latex_mod
# In[3]
import re
all_latexs = ""
cur_length = 1
for id, length, title, author, cor_author, aff, email in zip(ids, lens, titles, authors, cor_authors, affs, emails):
id_name = ‘{0:05d}‘.format(cur_length)
cur_page = int(id_name)
# print(‘cur_page: ‘, cur_page, cur_page % 800, cur_page % 801)
if cur_page % 800 == 0 or cur_page % 801 == 0 % cur_page % 802 == 0:
page += 1
cur_name = Name + str(page) + id_name
print(cur_name)
# os.rename(str(id), cur_name)
print(‘==============latex================‘)
print(title, author, cor_author, aff, email)
#### title ####
###############
#### author ####
author_li = re.split(‘,|and‘, author)
new_author = []
for li in author_li:
li = li.strip()
if li == cor_author:
li = cor_mod.format(li)
new_author.append(li)
new_author = ‘ \\and ‘.join(new_author)
# print(new_author)
################
#### tocauthor ####
tocauthor = author
####################
###### index #######
indexs = ""
for li in author_li:
li = li.strip().split(‘ ‘)
if len(li) == 2:
idx = "\index{{{0}, {1}}}".format(li[1], li[0])
indexs += idx + ‘\n‘
####################
###### aff #######
first_aff = aff.split(‘\n‘)[0]
###################
###### email ######
###################
print(cur_length)
cur_latex = latex_mod.format(cur_length, title,
new_author, tocauthor,
indexs[:-1], first_aff, email)
print(cur_latex)
# 更新 页码
cur_length += length
all_latexs = all_latexs + cur_latex + ‘\n‘
print(all_latexs)
# %%
f.write(all_latexs)
f.close()
将生成代码复制到LaTeX封面模板中,生成如: