├── README.md └── arxiv.sh /README.md: -------------------------------------------------------------------------------- 1 | # arxiv_script 2 | A single script to facilitate submitting papers to ArXiv.org 3 | With questions (and improvements), please email me@emilianodc.com 4 | 5 | 6 | # How to use 7 | Please read the comments, the script is pretty self-explanatory. 8 | 9 | 10 | # Input 11 | At the moment, the script takes in input: 12 | $main: your main source file 13 | $bib: your bib file 14 | fig_f: the folder with all your figures 15 | 16 | # Ouput 17 | upload: tex file without comments 18 | archive: tar file you can upload with (hopefully) all files you need 19 | -------------------------------------------------------------------------------- /arxiv.sh: -------------------------------------------------------------------------------- 1 | #!/bin/bash 2 | 3 | ##### INPUT ##### 4 | ##Modify this accordingly 5 | main="main" #main source file 6 | bib="bibliography" #bib file 7 | fig_f="plots/" #folder with figures 8 | 9 | ##### OUTPUT ##### 10 | ##Modify this with your preferred file names 11 | upload="no_comments" #tex file without comments 12 | archive="all.tar" #compress files so you can upload a single tar 13 | 14 | ##### FLAGS ##### 15 | #Set this to 1 if you want to upload only figures used in the tex 16 | select_figures=0 17 | 18 | if [ ! -f $main.tex ]; then 19 | echo $main.tex "not found!" 20 | exit 0 21 | fi 22 | if [ ! -f $bib.bib ]; then 23 | echo $bib.bib "not found!" 24 | exit 0 25 | fi 26 | if [ ! -d $fig_f ]; then 27 | echo "Folder" $fig_f "not found!" 28 | exit 0 29 | fi 30 | 31 | #Delete previous files 32 | rm -rf $archive $upload 33 | 34 | #Removing all comments from the source 35 | perl -pe 's/(^|[^\\])%.*/\1%/' < $main.tex > $upload.tex 36 | 37 | ##Compiling source and bibliography 38 | pdflatex $upload.tex 39 | bibtex $upload 40 | 41 | #Switch from using the bibfile to including a bbl as requested by ArXiv 42 | s='\\bibliography{'$bib'}' 43 | r='%'$s'\n\\input{'$upload.bbl'}' 44 | #echo $s 45 | #echo $r 46 | perl -pi -e "s/$s/$r/g" $upload.tex 47 | 48 | if [ $select_figures -eq "1" ]; then 49 | echo "here" 50 | s='\\begin{document}' 51 | r='\\listfiles\n'$s 52 | perl -pi -e "s/$s/$r/g" $upload.tex 53 | pdflatex $upload.tex 54 | r='\\begin{document}' 55 | s='\\listfiles\n'$r 56 | perl -pi -e "s/$s/$r/g" $upload.tex 57 | awk '/\*File List*/{flag=1;next}/ \*\*\*\*\*\*\*\*\*\*\*/{flag=0}flag' $upload.log | grep $fig_f > __figures.txt 58 | #cat __figures.txt 59 | tar -czf _figures_bk.tar $fig_f 60 | tar -cf __selectfigs.tar -T __figures.txt 61 | rm -rf $fig_f 62 | tar -xf __selectfigs.tar 63 | rm -rf __selectfigs.tar __figures.txt 64 | fi 65 | 66 | 67 | ##Remove Copyright 68 | perl -pi -e 's/\\begin{document}/\\makeatletter\n\\def\\\@copyrightspace{\\relax}\n\\makeatother\n\\begin{document} /g' $upload 69 | 70 | ##Final compilation 71 | pdflatex $upload.tex 72 | pdflatex $upload.tex 73 | 74 | ##Creating an archive with (hopefully) all files 75 | rm -rf $archive 76 | tar -czf $archive $upload.tex $upload.bbl $fig_f *.cls 77 | 78 | ##Cleaning up 79 | rm -f *~ 80 | rm -f *.log 81 | rm -f *.blg 82 | rm -f $main.bbl 83 | rm -f *.aux 84 | rm -f *.lof 85 | rm -f *.toc 86 | rm -f *.loa 87 | rm -f *.lot 88 | rm -f *.lot 89 | rm -f *.out 90 | rm -f *.ps 91 | rm -f *.dvi 92 | rm -f *.dep 93 | rm -f *.synctex.gz 94 | 95 | --------------------------------------------------------------------------------