<jupyter_start><jupyter_text>Generate 500 TEX files<jupyter_code>LatexContent = '''
\\documentclass{article}
\\usepackage[utf8]{inputenc}
\\usepackage{authblk}
\\usepackage{textalpha}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{newunicodechar}
\\newunicodechar{≤}{\\ensuremath{\\leq}}
\\newunicodechar{≥}{\\ensuremath{\\geq}}
\\usepackage{graphicx}
\\graphicspath{{../images/generated_images/}}
\\usepackage[font=small,labelfont=bf]{caption}

\\title{%(Ti)s}
\\author{%(Au)s}
\\affil{\\textsuperscript{1}%(Af)s}
\\date{%(Da)s}

\\begin{document}

\\maketitle

\\begin{center}
\\begin{minipage}{0.75\linewidth}
\\includegraphics[width=\\textwidth]{%(Im)s}
\\captionof{figure}{%(Ca)s}
\\end{minipage}
\\end{center}

%(Bo)s

\\end{document}'''

for i in range(0,500):

    ID = str(i)
    Authors = str(authors[i].split(",")[0])+ "\\textsuperscript{1}, " + ", ".join(authors[i].split(",")[1:])
    Affiliation = affiliations[i]
    Date = month_abc[i] + " " + str(year[i])

    Body = open(f'../fake_text/fake_text/{i}.txt', 'r').read()\
    .replace("\\n","\n\n")\
    .replace("$","\$")\
    .replace("&","\&")\
    .replace("#","\#")\
    .replace("_","\_")\
    .replace("{","\{")\
    .replace("}","\}")[1:-2]

    Title = title[i] #" ".join(Body.split(" ")[:10])
    Image = f"samples_16_{i}.png"
    Caption = captions[i]

    # Create TEX file    
    TexFileName = ID + '.tex'
    TexFile = open(TexFileName,'w')
    TexFile.write(LatexContent %{"Id" : ID,
                                 "Ti" : Title,
                                 "Au" : Authors,
                                 "Af" : Affiliation,
                                 "Da" : Date,
                                 "Bo" : Body ,
                                 "Im" : Image ,
                                 "Ca" : Caption})
    TexFile.close()
    
    # Create PDF
    # subprocess.Popen(['pdflatex', TexFileName],shell=False)
# Double checking that all TEX files are created, no errors
# Should have 500

t_files = []
for i in os.listdir('./'):
    if i[-3:] == "tex":
        t_files.append(i)
print(len(t_files))
t_files.sort()
# t_files<jupyter_output><empty_output><jupyter_text>Extra credit: Generate 1 PDF<jupyter_code>LatexContentExtra = '''
\\documentclass{article}
\\usepackage[utf8]{inputenc}
\\usepackage{authblk}
\\usepackage{textalpha}
\\usepackage{amsmath}
\\usepackage{amssymb}
\\usepackage{newunicodechar}
\\newunicodechar{≤}{\\ensuremath{\\leq}}
\\newunicodechar{≥}{\\ensuremath{\\geq}}
\\usepackage{graphicx}
\\graphicspath{{./images/}}
\\usepackage[font=small,labelfont=bf]{caption}
\\usepackage[parfill]{parskip}

\\title{%(Ti)s}
\\author{%(Au)s}
\\affil{\\textsuperscript{1}%(Af)s}
\\date{%(Da)s}

\\begin{document}

\\maketitle


\\begin{abstract}
%(Ab)s
\\end{abstract}

\\section{Introduction}

%(Bo0)s

\\section{%(Se1)s}

%(Bo1)s

\\section{%(Se2)s}

%(Bo2)s

\\section{%(Se3)s}

%(Bo3)s

\\section{%(Se4)s}

%(Bo4)s

\\section{%(Se5)s}

%(Bo5)s

\\section{%(Se6)s}

%(Bo6)s

\\section{%(Se7)s}

%(Bo7)s

\\section{%(Se8)s}

%(Bo8)s

\\section{%(Se9)s}

%(Bo9)s

\\section{Conclusion}

%(Bo10)s

\\section{Authors}

\\begin{center}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im0)s}
\\captionof{figure}{%(Ca0)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im1)s}
\\captionof{figure}{%(Ca1)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im2)s}
\\captionof{figure}{%(Ca2)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im3)s}
\\captionof{figure}{%(Ca3)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im4)s}
\\captionof{figure}{%(Ca4)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im5)s}
\\captionof{figure}{%(Ca5)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im6)s}
\\captionof{figure}{%(Ca6)s}
\\end{minipage}
\\begin{minipage}{0.24\linewidth}
\\includegraphics[width=\\textwidth]{%(Im7)s}
\\captionof{figure}{%(Ca7)s}
\\end{minipage}
\\end{center}

\\section{References}

%(Re)s

\\end{document}'''

for i in range(0,1):

    ID = "fake_scientific_literature"
    Title = "Research critical for activating the inflammatory cytok that promoted CRC cell associated with pain"
    Authors = str(authors[2].split(",")[0])+ "\\textsuperscript{1}, " + ", ".join(authors[2].split(",")[1:])
    Affiliation = affiliations[2]
    Date = month_abc[2] + " " + str(year[2])
    
    Abstract = open(f'texts/Abstract.txt', 'r').read()\
    .replace("\\n","\n\n")[1:-1]

    t = open(f'texts/All.txt', 'r').read()\
    .replace("\\n","\n\n")\
    .replace("$","\$")\
    .replace("&","\&")\
    .replace("#","\#")\
    .replace("_","\_")\
    .replace("{","\{")\
    .replace("}","\}")[1:-1]
    
    t_list = t.split("\n\n")

    section_headings = []
    for i in t_list:
        if len(i.split(" ")) < 6:
            section_headings.append(i)
    section_headings
    
    Section1 = section_headings[0]
    Section2 = section_headings[1]
    Section3 = section_headings[2]
    Section4 = section_headings[3]
    Section5 = section_headings[4]
    Section6 = section_headings[5]
    Section7 = section_headings[6]
    Section8 = section_headings[7]
    Section9 = section_headings[8]

    b = t.split(section_headings[0] + "\n")
    b_sections = [b[0]]
    for i in range(len(section_headings)-1):
        b = b[1].split(section_headings[i+1] + "\n")
        b_sections.append(b[0])
    b_sections.append(b[1])
    
    Body0 = b_sections[0]
    Body1 = b_sections[1]
    Body2 = b_sections[2]
    Body3 = b_sections[3]
    Body4 = b_sections[4]
    Body5 = b_sections[5]
    Body6 = b_sections[6]
    Body7 = b_sections[7]
    Body8 = b_sections[8]
    Body9 = b_sections[9].split("The next step")[0]
    Body10 = "The next step " + b_sections[9].split("The next step")[1]
    
    Image_Author0 = "samples_16_136.png" # F
    Caption_Author0 = authors[2].split(",")[0]
    Image_Author1 = "samples_16_224.png" # M
    Caption_Author1 = authors[2].split(",")[1]
    Image_Author2 = "samples_16_288.png" # F
    Caption_Author2 = authors[2].split(",")[2]
    Image_Author3 = "samples_16_306.png" # F
    Caption_Author3 = authors[2].split(",")[3]
    Image_Author4 = "samples_16_60.png" # M
    Caption_Author4 = authors[2].split(",")[4]
    Image_Author5 = "samples_16_125.png" # M
    Caption_Author5 = authors[2].split(",")[5]
    Image_Author6 = "samples_16_185.png" # M
    Caption_Author6 = authors[2].split(",")[6]
    Image_Author7 = "samples_16_435.png" # F
    Caption_Author7 = authors[2].split(",")[7]
    
    Caption = f"Alt text: {captions[136]}, {captions[224]}, {captions[288]}, {captions[306]}, {captions[60]}, {captions[125]}, {captions[185]}, {captions[435]}."
    
    r = open(f'texts/References.txt', 'r').read().replace("&","\&").split("\n")
    r = [i for i in r if len(i.split(" ")) > 1]
    r.sort()
    References = "\n\n".join(r)

    # Create TEX file
    TexFileName = ID + '.tex'
    TexFile = open(TexFileName,'w')
    TexFile.write(LatexContentExtra %{"Id" : ID,
                                 "Ti" : Title,
                                 "Au" : Authors,
                                 "Af" : Affiliation,
                                 "Da" : Date,
                                 "Ab" : Abstract ,
                                 "Bo0" : Body0 ,
                                 "Se1" : Section1,
                                 "Bo1" : Body1,
                                 "Se2" : Section2,
                                 "Bo2" : Body2,
                                 "Se3" : Section3 ,
                                 "Bo3" : Body3 ,
                                 "Se4" : Section4,
                                 "Bo4" : Body4 ,
                                 "Se5" : Section5,
                                 "Bo5" : Body5,
                                 "Se6" : Section6,
                                 "Bo6" : Body6,
                                 "Se7" : Section7 ,
                                 "Bo7" : Body7 ,                                      
                                 "Se8" : Section8,
                                 "Bo8" : Body8,
                                 "Se9" : Section9 ,
                                 "Bo9" : Body9 , 
                                 "Bo10" : Body10 ,
                                 "Im0" : Image_Author0 ,
                                 "Ca0" : Caption_Author0 ,
                                 "Im1" : Image_Author1 ,
                                 "Ca1" : Caption_Author1 ,
                                 "Im2" : Image_Author2 ,
                                 "Ca2" : Caption_Author2 ,
                                 "Im3" : Image_Author3 ,
                                 "Ca3" : Caption_Author3 ,
                                 "Im4" : Image_Author4 ,
                                 "Ca4" : Caption_Author4 ,
                                 "Im5" : Image_Author5 ,
                                 "Ca5" : Caption_Author5 ,
                                 "Im6" : Image_Author6 ,
                                 "Ca6" : Caption_Author6 ,
                                 "Im7" : Image_Author7 ,
                                 "Ca7" : Caption_Author7 ,
                                 "Ca" : Caption ,
                                 "Re" : References})
    TexFile.close()

    # Create PDF
    subprocess.Popen(['pdflatex', TexFileName],shell=False)<jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.18473978851337342, 'fraction_numerical': 0.03348538254198632, 'mean_word_length': 1.942055504727051, 'pattern_counts': {'":': 1, '<': 10, '<?xml version=': 0, '>': 10, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 51, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '2', 'dir': 'jupyter-structured-clean-dedup', 'id': '167669', 'license': 'Apache-2.0', 'n_tokens_mistral': 3487, 'n_tokens_neox': 3330, 'n_words': 489, 'path': 'LaTeX/LaTeX.ipynb', 'repo_name': 'alexdseo/Falsified-Scientific-Literature-Generation', 'size': '9646'}