forked from MiWy/my-pandoc-scripts
-
Notifications
You must be signed in to change notification settings - Fork 0
/
makefiles.sh
71 lines (60 loc) · 2.02 KB
/
makefiles.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
# Script converts multimarkdown file to latex, pdf, doc and others
# Assumptions: source bibliography.bib and manuscript.md in /source, and spbasic.bst in styles
# Directory structure:
# - /styles
# - /output
# - /source
# You need to change author name in these preamble templates:
# - tex_preamble.tex
# - drafttex_preamble.tex
PAPER="manuscript.md"
BIBLIOGRAPHY="bibliography.bib"
# Copy source files
cp source/$PAPER output/$PAPER
cp source/$BIBLIOGRAPHY output/$BIBLIOGRAPHY
cp styles/spbasic.bst output/spbasic.bst
cp styles/apa.csl output/apa.csl
cp -r fonts/ output
cp tex_preamble.tex output/tex_preamble.tex
cp drafttex_preamble.tex output/drafttex_preamble.tex
# CONVERT DOCUMENTS
cd output
# # TeX
pandoc $PAPER -t latex --pdf-engine=xelatex \
-s --natbib --bibliography=$BIBLIOGRAPHY -V natbiboptions:"round" -V biblio-style:"spbasic" \
--number-sections -V indent:true -V papersize:a4 -V fontsize:10pt \
--include-in-header=tex_preamble.tex \
-o manuscript_main.tex
# # Draft TeX
pandoc $PAPER -t latex --pdf-engine=xelatex \
-s --natbib --bibliography=$BIBLIOGRAPHY -V natbiboptions:"round" -V biblio-style:"spbasic" \
--number-sections -V indent:true -V papersize:a4 -V fontsize:10pt \
--include-in-header=drafttex_preamble.tex \
-o manuscript_draft.tex
# # TeX PDF
xelatex manuscript_main
bibtex manuscript_main
xelatex manuscript_main
xelatex manuscript_main
# # Draft PDF
xelatex manuscript_draft
bibtex manuscript_draft
xelatex manuscript_draft
xelatex manuscript_draft
# Docx
pandoc -s -o manuscript.docx $PAPER --filter=pandoc-citeproc --bibliography=$BIBLIOGRAPHY --csl="apa.csl"
# STOP CONVERTING
cd ..
# CLEANUP
cd output
find . -name "*.otf" -type f -delete
find . -name "*.ttf" -type f -delete
find . -name "*.bib" -type f -delete
find . -name "*.log" -type f -delete
find . -name "*.blg" -type f -delete
find . -name "*.aux" -type f -delete
find . -name "*.bst" -type f -delete
find . -name "*.cls" -type f -delete
find . -name "tex_preamble.tex" -type f -delete
find . -name "drafttex_preamble.tex" -type f -delete
cd ..