-
Notifications
You must be signed in to change notification settings - Fork 22
/
mystyle.tplx
83 lines (65 loc) · 2.81 KB
/
mystyle.tplx
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
71
72
73
74
75
76
77
78
79
80
81
82
((= IPython input/output style =))
((*- extends 'report.tplx' -*))
((* block h1 -*))\chapter((* endblock h1 -*))
((* block h2 -*))\section((* endblock h2 -*))
((* block h3 -*))\subsection((* endblock h3 -*))
((* block h4 -*))\subsubsection((* endblock h4 -*))
((* block h5 -*))\paragraph((* endblock h5 -*))
% Custom definitions
((* block definitions *))
((( super() )))
% Pygments definitions
((( resources.latex.pygments_definitions )))
% Exact colors from NB
\definecolor{incolor}{rgb}{0.0, 0.0, 0.5}
\definecolor{outcolor}{rgb}{0.545, 0.0, 0.0}
((* endblock definitions *))
%===============================================================================
% Input
%===============================================================================
((* block input scoped *))
((*- if resources.global_content_filter.include_input_prompt *))
((( add_prompt(cell.source | highlight_code(strip_verbatim=True, metadata=cell.metadata), cell, 'In ', 'incolor') )))
((* endif *))
((* endblock input *))
%===============================================================================
% Output
%===============================================================================
((* block execute_result scoped *))
((*- for type in output.data | filter_data_type -*))
((*- if resources.global_content_filter.include_output_prompt -*))
((*- if type in ['text/plain'] *))
((( add_prompt(output.data['text/plain'] | escape_latex, cell, 'Out', 'outcolor') )))
((* else -*))
\texttt{\color{outcolor}Out[{\color{outcolor}((( cell.execution_count )))}]:}((( super() )))
((*- endif -*))
((*- endif -*))
((*- endfor -*))
((* endblock execute_result *))
%==============================================================================
% Support Macros
%==============================================================================
% Name: draw_prompt
% Purpose: Renders an output/input prompt
((* macro add_prompt(text, cell, prompt, prompt_color) -*))
((*- if cell.execution_count is defined -*))
((*- set execution_count = "" ~ (cell.execution_count | replace(None, " ")) -*))
((*- else -*))
((*- set execution_count = " " -*))
((*- endif -*))
((*- set indention = " " * (execution_count | length + 7) -*))
\begin{Verbatim}[commandchars=\\\{\}]
((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ execution_count ~ '}]:} ', cont=indention) )))
\end{Verbatim}
((*- endmacro *))
% Draw a figure using the graphicx package.
((* macro draw_figure(filename) -*))
((* set filename = filename | posix_path *))
((*- block figure scoped -*))
\begin{center}
\maxsizebox{0.95\textwidth}{0.25\paperheight}{
\includegraphics{((( filename )))}
}
\end{center}
((*- endblock figure -*))
((*- endmacro *))