Skip to content

Commit 2e9632b

Browse files
authored
Merge pull request #6 from twihno/update_din_a_graph_paper
Added grey option to dashed and dotted grid 10+5mm
2 parents 0249749 + 02be43b commit 2e9632b

12 files changed

Lines changed: 286 additions & 0 deletions

templates/din_a/graph_paper/dashed_grid/5+10mm/compile_template.py renamed to templates/din_a/graph_paper/dashed_grid/5+10mm/black/compile_template.py

File renamed without changes.

templates/din_a/graph_paper/dashed_grid/5+10mm/printablepaperlib.json renamed to templates/din_a/graph_paper/dashed_grid/5+10mm/black/printablepaperlib.json

File renamed without changes.

templates/din_a/graph_paper/dashed_grid/5+10mm/template.latex_template renamed to templates/din_a/graph_paper/dashed_grid/5+10mm/black/template.latex_template

File renamed without changes.

templates/din_a/graph_paper/dotted_grid/5+10mm/compile_template.py renamed to templates/din_a/graph_paper/dashed_grid/5+10mm/grey/compile_template.py

File renamed without changes.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
{
2+
"template_name": "dashed_grid_grey_5+10mm",
3+
"version": "1.0.0",
4+
"page_sizes": [
5+
"a4paper",
6+
"a3paper",
7+
"a2paper",
8+
"a1paper"
9+
],
10+
"orientations": [
11+
"portrait",
12+
"landscape"
13+
]
14+
}
Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
\documentclass{article}
2+
\usepackage[{{ paperformat }}, {{ paperorientation }}]{geometry}
3+
\usepackage{tikz}
4+
\usetikzlibrary{calc}
5+
6+
\newcommand*{\largelinewidth}{0.3mm}
7+
\newcommand*{\smalllinewidth}{0.1mm}
8+
9+
\begin{document}
10+
\pagestyle{empty}
11+
\begin{tikzpicture}[remember picture,overlay]
12+
13+
\definecolor{line_color}{RGB}{128,128,128}
14+
15+
% horizontal lines 5mm
16+
\foreach \i in {5,15,...,{{ vertical_5mm_count }}}{
17+
\draw[line_color, line width=\smalllinewidth, dashed] ($(current page.north west)+(0,-\i mm)$) -- ($(current page.north east)+(0,-\i mm)$);}
18+
19+
% vertical lines 5mm
20+
\foreach \i in {5,15,...,{{ horizontal_5mm_count }}}{
21+
\draw[line_color, line width=\smalllinewidth, dashed] ($(current page.north west)+(\i mm,0)$) -- ($(current page.south west)+(\i mm,0)$);}
22+
23+
% horizontal lines 10mm
24+
\foreach \i in {10,20,...,{{ vertical_10mm_count }}}{
25+
\draw[line_color, line width=\largelinewidth, dashed] ($(current page.north west)+(0,-\i mm)$) -- ($(current page.north east)+(0,-\i mm)$);}
26+
27+
% vertical lines 10mm
28+
\foreach \i in {10,20,...,{{ horizontal_10mm_count }}}{
29+
\draw[line_color, line width=\largelinewidth, dashed] ($(current page.north west)+(\i mm,0)$) -- ($(current page.south west)+(\i mm,0)$);}
30+
31+
32+
\end{tikzpicture}
33+
34+
\end{document}
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""Generate latex files"""
2+
3+
import json
4+
import os
5+
import traceback
6+
import sys
7+
from jinja2 import Environment, FileSystemLoader
8+
9+
if __name__ == "__main__":
10+
11+
# Change working directory to this directory
12+
abspath = os.path.abspath(__file__)
13+
dirname = os.path.dirname(abspath)
14+
os.chdir(dirname)
15+
16+
# Load printablepaperlib parameters
17+
try:
18+
with open('./printablepaperlib.json') as f:
19+
parameters = json.load(f)
20+
except FileNotFoundError:
21+
traceback.print_exc()
22+
sys.exit(1)
23+
24+
# Load paperlib
25+
TEMPLATE_SUBDIR = str(dirname).find(
26+
"/", str(dirname).find("templates/")+10)+1
27+
PAPERLIB_PATH = str(dirname)[0:TEMPLATE_SUBDIR] + "paperlib.json"
28+
29+
try:
30+
with open(PAPERLIB_PATH) as f:
31+
paperlib = json.load(f)
32+
except FileNotFoundError:
33+
traceback.print_exc()
34+
sys.exit(1)
35+
36+
# Load template
37+
38+
env = Environment(loader=FileSystemLoader(dirname))
39+
template = env.get_template('template.latex_template')
40+
41+
# printablepaperlib specific code
42+
43+
for page_size in parameters["page_sizes"]:
44+
page_size_name = paperlib[page_size]["displayname"]
45+
for orientation in parameters["orientations"]:
46+
FILENAME = "{}_{}_{}.latex".format(
47+
parameters["template_name"],
48+
page_size_name,
49+
orientation)
50+
51+
# 10mm lines
52+
53+
py_horizonzal_10mm_count = int(
54+
paperlib[page_size][orientation]["width"])-int(
55+
paperlib[page_size][orientation]["width"] % 10)
56+
57+
# Remove lines on the page borders
58+
if py_horizonzal_10mm_count == round(paperlib[page_size][orientation]["width"]):
59+
py_horizonzal_10mm_count -= 10
60+
61+
py_vertical_10mm_count = int(
62+
paperlib[page_size][orientation]["height"])-int(
63+
paperlib[page_size][orientation]["height"] % 10)
64+
65+
# Remove lines on the page borders
66+
if py_vertical_10mm_count == round(paperlib[page_size][orientation]["height"]):
67+
py_vertical_10mm_count -= 10
68+
69+
# 5mm lines
70+
71+
py_horizonzal_5mm_count = int(
72+
paperlib[page_size][orientation]["width"])-int(
73+
paperlib[page_size][orientation]["width"] % 5)
74+
75+
# Remove lines on the page borders
76+
if py_horizonzal_5mm_count == round(paperlib[page_size][orientation]["width"]):
77+
py_horizonzal_5mm_count -= 5
78+
79+
py_vertical_5mm_count = int(
80+
paperlib[page_size][orientation]["height"])-int(
81+
paperlib[page_size][orientation]["height"] % 5)
82+
83+
# Remove lines on the page borders
84+
if py_vertical_5mm_count == round(paperlib[page_size][orientation]["height"]):
85+
py_vertical_5mm_count -= 5
86+
87+
with open(FILENAME, "w") as f:
88+
f.write(template.render(
89+
paperformat=page_size,
90+
paperorientation=orientation,
91+
horizontal_5mm_count=py_horizonzal_5mm_count,
92+
vertical_5mm_count=py_vertical_5mm_count,
93+
horizontal_10mm_count=py_horizonzal_10mm_count,
94+
vertical_10mm_count=py_vertical_10mm_count,
95+
))

templates/din_a/graph_paper/dotted_grid/5+10mm/printablepaperlib.json renamed to templates/din_a/graph_paper/dotted_grid/5+10mm/black/printablepaperlib.json

File renamed without changes.

templates/din_a/graph_paper/dotted_grid/5+10mm/template.latex_template renamed to templates/din_a/graph_paper/dotted_grid/5+10mm/black/template.latex_template

File renamed without changes.
Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
"""Generate latex files"""
2+
3+
import json
4+
import os
5+
import traceback
6+
import sys
7+
from jinja2 import Environment, FileSystemLoader
8+
9+
if __name__ == "__main__":
10+
11+
# Change working directory to this directory
12+
abspath = os.path.abspath(__file__)
13+
dirname = os.path.dirname(abspath)
14+
os.chdir(dirname)
15+
16+
# Load printablepaperlib parameters
17+
try:
18+
with open('./printablepaperlib.json') as f:
19+
parameters = json.load(f)
20+
except FileNotFoundError:
21+
traceback.print_exc()
22+
sys.exit(1)
23+
24+
# Load paperlib
25+
TEMPLATE_SUBDIR = str(dirname).find(
26+
"/", str(dirname).find("templates/")+10)+1
27+
PAPERLIB_PATH = str(dirname)[0:TEMPLATE_SUBDIR] + "paperlib.json"
28+
29+
try:
30+
with open(PAPERLIB_PATH) as f:
31+
paperlib = json.load(f)
32+
except FileNotFoundError:
33+
traceback.print_exc()
34+
sys.exit(1)
35+
36+
# Load template
37+
38+
env = Environment(loader=FileSystemLoader(dirname))
39+
template = env.get_template('template.latex_template')
40+
41+
# printablepaperlib specific code
42+
43+
for page_size in parameters["page_sizes"]:
44+
page_size_name = paperlib[page_size]["displayname"]
45+
for orientation in parameters["orientations"]:
46+
FILENAME = "{}_{}_{}.latex".format(
47+
parameters["template_name"],
48+
page_size_name,
49+
orientation)
50+
51+
# 10mm lines
52+
53+
py_horizonzal_10mm_count = int(
54+
paperlib[page_size][orientation]["width"])-int(
55+
paperlib[page_size][orientation]["width"] % 10)
56+
57+
# Remove lines on the page borders
58+
if py_horizonzal_10mm_count == round(paperlib[page_size][orientation]["width"]):
59+
py_horizonzal_10mm_count -= 10
60+
61+
py_vertical_10mm_count = int(
62+
paperlib[page_size][orientation]["height"])-int(
63+
paperlib[page_size][orientation]["height"] % 10)
64+
65+
# Remove lines on the page borders
66+
if py_vertical_10mm_count == round(paperlib[page_size][orientation]["height"]):
67+
py_vertical_10mm_count -= 10
68+
69+
# 5mm lines
70+
71+
py_horizonzal_5mm_count = int(
72+
paperlib[page_size][orientation]["width"])-int(
73+
paperlib[page_size][orientation]["width"] % 5)
74+
75+
# Remove lines on the page borders
76+
if py_horizonzal_5mm_count == round(paperlib[page_size][orientation]["width"]):
77+
py_horizonzal_5mm_count -= 5
78+
79+
py_vertical_5mm_count = int(
80+
paperlib[page_size][orientation]["height"])-int(
81+
paperlib[page_size][orientation]["height"] % 5)
82+
83+
# Remove lines on the page borders
84+
if py_vertical_5mm_count == round(paperlib[page_size][orientation]["height"]):
85+
py_vertical_5mm_count -= 5
86+
87+
with open(FILENAME, "w") as f:
88+
f.write(template.render(
89+
paperformat=page_size,
90+
paperorientation=orientation,
91+
horizontal_5mm_count=py_horizonzal_5mm_count,
92+
vertical_5mm_count=py_vertical_5mm_count,
93+
horizontal_10mm_count=py_horizonzal_10mm_count,
94+
vertical_10mm_count=py_vertical_10mm_count,
95+
))

0 commit comments

Comments
 (0)