Skip to content

Commit 19fed65

Browse files
added files related to pandoc pdf tutorial
1 parent 359befa commit 19fed65

22 files changed

+445
-0
lines changed

files/pandoc_pdf/bullet_style.tex

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
% https://stackoverflow.com/questions/22156999/how-to-change-the-style-of-bullets-in-pandoc-markdown
2+
3+
\usepackage{enumitem}
4+
\usepackage{amsfonts}
5+
6+
\setlist[itemize,1]{label=$\bullet$}
7+
\setlist[itemize,2]{label=$\circ$}
8+
\setlist[itemize,3]{label=$\star$}
9+
10+
%% \setlist[itemize,2]{label=$\diamond$}
11+
%% \setlist[itemize,1]{label=$\star$}
12+
%% \setlist[itemize,1]{label=$\bullet$}
13+
%% \setlist[itemize,1]{label=$\checkmark$}
14+

files/pandoc_pdf/chapter_break.tex

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
%% Adds pagebreak between chapters
2+
% from comments of accepted answer
3+
% https://superuser.com/questions/601469/getting-chapters-to-start-on-a-new-page-in-a-pandoc-generated-pdf
4+
\usepackage{sectsty}
5+
\sectionfont{\clearpage}
6+
7+
% accepted answer gave error
8+
%\usepackage{titlesec}
9+
%\newcommand{\sectionbreak}{\clearpage}
10+

files/pandoc_pdf/inline_code.tex

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
%% https://stackoverflow.com/questions/40975004/pandoc-latex-change-backtick-highlight
2+
\usepackage{fancyvrb,newverbs,xcolor}
3+
4+
%\definecolor{Light}{gray}{.90}
5+
%% https://martin-thoma.com/colors-in-latex/
6+
%% https://en.wikibooks.org/wiki/LaTeX/Colors
7+
\definecolor{Light}{HTML}{F4F4F4}
8+
9+
\let\oldtexttt\texttt
10+
\renewcommand{\texttt}[1]{
11+
\colorbox{Light}{\oldtexttt{#1}}
12+
}
13+

files/pandoc_pdf/md2pdf.sh

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--include-in-header chapter_break.tex \
6+
-V linkcolor:blue \
7+
-V geometry:a4paper \
8+
-V geometry:margin=2cm \
9+
-V mainfont="DejaVu Serif" \
10+
-V monofont="DejaVu Sans Mono" \
11+
--pdf-engine=xelatex \
12+
-o "$2"
13+

files/pandoc_pdf/md2pdf_syn.sh

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--include-in-header chapter_break.tex \
6+
--include-in-header inline_code.tex \
7+
--highlight-style pygments.theme \
8+
-V linkcolor:blue \
9+
-V geometry:a4paper \
10+
-V geometry:margin=2cm \
11+
-V mainfont="DejaVu Serif" \
12+
-V monofont="DejaVu Sans Mono" \
13+
--pdf-engine=xelatex \
14+
-o "$2"
15+
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--include-in-header chapter_break.tex \
6+
--include-in-header inline_code.tex \
7+
--include-in-header bullet_style.tex \
8+
--highlight-style pygments.theme \
9+
-V linkcolor:blue \
10+
-V geometry:a4paper \
11+
-V geometry:margin=2cm \
12+
-V mainfont="DejaVu Serif" \
13+
-V monofont="DejaVu Sans Mono" \
14+
--pdf-engine=xelatex \
15+
-o "$2"
16+
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
#!/bin/bash
2+
3+
pandoc "$1" \
4+
-f gfm \
5+
--include-in-header chapter_break.tex \
6+
--include-in-header inline_code.tex \
7+
--include-in-header bullet_style.tex \
8+
--include-in-header pdf_properties.tex \
9+
--highlight-style pygments.theme \
10+
-V linkcolor:blue \
11+
-V geometry:a4paper \
12+
-V geometry:margin=2cm \
13+
-V mainfont="DejaVu Serif" \
14+
-V monofont="DejaVu Sans Mono" \
15+
--pdf-engine=xelatex \
16+
-o "$2"
17+
Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
% https://tex.stackexchange.com/questions/23235/eliminate-edit-pdf-properties-added-by-pdflatex
2+
3+
\usepackage{hyperref}
4+
5+
\hypersetup{
6+
pdftitle={My awesome book},
7+
pdfauthor={learnbyexample},
8+
pdfsubject={pandoc},
9+
pdfkeywords={pandoc,pdf,xelatex}
10+
}
11+

files/pandoc_pdf/pygments.theme

Lines changed: 211 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,211 @@
1+
{
2+
"text-color": null,
3+
"background-color": "#f8f8f8",
4+
"line-number-color": "#aaaaaa",
5+
"line-number-background-color": null,
6+
"text-styles": {
7+
"Other": {
8+
"text-color": "#007020",
9+
"background-color": null,
10+
"bold": false,
11+
"italic": false,
12+
"underline": false
13+
},
14+
"Attribute": {
15+
"text-color": "#7d9029",
16+
"background-color": null,
17+
"bold": false,
18+
"italic": false,
19+
"underline": false
20+
},
21+
"SpecialString": {
22+
"text-color": "#bb6688",
23+
"background-color": null,
24+
"bold": false,
25+
"italic": false,
26+
"underline": false
27+
},
28+
"Annotation": {
29+
"text-color": "#60a0b0",
30+
"background-color": null,
31+
"bold": true,
32+
"italic": true,
33+
"underline": false
34+
},
35+
"Function": {
36+
"text-color": "#06287e",
37+
"background-color": null,
38+
"bold": false,
39+
"italic": false,
40+
"underline": false
41+
},
42+
"String": {
43+
"text-color": "#4070a0",
44+
"background-color": null,
45+
"bold": false,
46+
"italic": false,
47+
"underline": false
48+
},
49+
"ControlFlow": {
50+
"text-color": "#007020",
51+
"background-color": null,
52+
"bold": true,
53+
"italic": false,
54+
"underline": false
55+
},
56+
"Operator": {
57+
"text-color": "#666666",
58+
"background-color": null,
59+
"bold": false,
60+
"italic": false,
61+
"underline": false
62+
},
63+
"Error": {
64+
"text-color": "#ff0000",
65+
"background-color": null,
66+
"bold": true,
67+
"italic": false,
68+
"underline": false
69+
},
70+
"BaseN": {
71+
"text-color": "#40a070",
72+
"background-color": null,
73+
"bold": false,
74+
"italic": false,
75+
"underline": false
76+
},
77+
"Alert": {
78+
"text-color": "#ff0000",
79+
"background-color": null,
80+
"bold": true,
81+
"italic": false,
82+
"underline": false
83+
},
84+
"Variable": {
85+
"text-color": "#19177c",
86+
"background-color": null,
87+
"bold": false,
88+
"italic": false,
89+
"underline": false
90+
},
91+
"BuiltIn": {
92+
"text-color": null,
93+
"background-color": null,
94+
"bold": false,
95+
"italic": false,
96+
"underline": false
97+
},
98+
"Extension": {
99+
"text-color": null,
100+
"background-color": null,
101+
"bold": false,
102+
"italic": false,
103+
"underline": false
104+
},
105+
"Preprocessor": {
106+
"text-color": "#bc7a00",
107+
"background-color": null,
108+
"bold": false,
109+
"italic": false,
110+
"underline": false
111+
},
112+
"Information": {
113+
"text-color": "#60a0b0",
114+
"background-color": null,
115+
"bold": true,
116+
"italic": true,
117+
"underline": false
118+
},
119+
"VerbatimString": {
120+
"text-color": "#4070a0",
121+
"background-color": null,
122+
"bold": false,
123+
"italic": false,
124+
"underline": false
125+
},
126+
"Warning": {
127+
"text-color": "#60a0b0",
128+
"background-color": null,
129+
"bold": true,
130+
"italic": true,
131+
"underline": false
132+
},
133+
"Documentation": {
134+
"text-color": "#ba2121",
135+
"background-color": null,
136+
"bold": false,
137+
"italic": true,
138+
"underline": false
139+
},
140+
"Import": {
141+
"text-color": null,
142+
"background-color": null,
143+
"bold": false,
144+
"italic": false,
145+
"underline": false
146+
},
147+
"Char": {
148+
"text-color": "#4070a0",
149+
"background-color": null,
150+
"bold": false,
151+
"italic": false,
152+
"underline": false
153+
},
154+
"DataType": {
155+
"text-color": "#902000",
156+
"background-color": null,
157+
"bold": false,
158+
"italic": false,
159+
"underline": false
160+
},
161+
"Float": {
162+
"text-color": "#40a070",
163+
"background-color": null,
164+
"bold": false,
165+
"italic": false,
166+
"underline": false
167+
},
168+
"Comment": {
169+
"text-color": "#9c9c9c",
170+
"background-color": null,
171+
"bold": false,
172+
"italic": false,
173+
"underline": false
174+
},
175+
"CommentVar": {
176+
"text-color": "#60a0b0",
177+
"background-color": null,
178+
"bold": true,
179+
"italic": true,
180+
"underline": false
181+
},
182+
"Constant": {
183+
"text-color": "#880000",
184+
"background-color": null,
185+
"bold": false,
186+
"italic": false,
187+
"underline": false
188+
},
189+
"SpecialChar": {
190+
"text-color": "#4070a0",
191+
"background-color": null,
192+
"bold": false,
193+
"italic": false,
194+
"underline": false
195+
},
196+
"DecVal": {
197+
"text-color": "#40a070",
198+
"background-color": null,
199+
"bold": false,
200+
"italic": false,
201+
"underline": false
202+
},
203+
"Keyword": {
204+
"text-color": "#007020",
205+
"background-color": null,
206+
"bold": true,
207+
"italic": false,
208+
"underline": false
209+
}
210+
}
211+
}

files/pandoc_pdf/sample_1.md

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,68 @@
1+
# Introduction
2+
3+
This is a sample [GitHub style markdown](https://github.github.com/gfm/) file.
4+
Top level headers are chapters and other headings are for sub-sections.
5+
6+
# Python
7+
8+
* Lists are declared within `[]` and elements are separated by `,`
9+
* Each element can be of any data type, including list data type
10+
11+
## Example
12+
13+
Use `for` loop to iterate over a list.
14+
15+
```python
16+
numbers = [2, 12, 3, 25, 624, 21, 5, 9, 12]
17+
odd_numbers = []
18+
even_numbers = []
19+
20+
for num in numbers:
21+
odd_numbers.append(num) if(num % 2) else even_numbers.append(num)
22+
23+
print(f'numbers: {numbers}')
24+
print(f'odd_numbers: {odd_numbers}')
25+
print(f'even_numbers: {even_numbers}')
26+
```
27+
28+
# Ruby
29+
30+
* Arrays are declared within `[]` and elements are separated by `,`
31+
* Each element can be of any data type, including array data type
32+
33+
## Example
34+
35+
Use `each` method to iterate over an array.
36+
37+
```ruby
38+
numbers = [2, 12, 3, 25, 624, 21, 5, 9, 12]
39+
odd_numbers = []
40+
even_numbers = []
41+
42+
numbers.each { |n| n.even? ? even_numbers.append(n) : odd_numbers.append(n) }
43+
44+
puts "numbers: #{numbers}"
45+
puts "odd_numbers: #{odd_numbers}"
46+
puts "even_numbers: #{even_numbers}"
47+
```
48+
49+
# CLI
50+
51+
Executing the Python and Ruby programs mentioned in previous chapters:
52+
53+
```bash
54+
$ python3.7 list_looping.py
55+
numbers: [2, 12, 3, 25, 624, 21, 5, 9, 12]
56+
odd_numbers: [3, 25, 21, 5, 9]
57+
even_numbers: [2, 12, 624, 12]
58+
59+
$ ruby array_looping.rb
60+
numbers: [2, 12, 3, 25, 624, 21, 5, 9, 12]
61+
odd_numbers: [3, 25, 21, 5, 9]
62+
even_numbers: [2, 12, 624, 12]
63+
```
64+
65+
# Conclusion
66+
67+
This sample file helps you see a demo for `markdown` to `pdf` conversion using `pandoc`.
68+

0 commit comments

Comments
 (0)