##// END OF EJS Templates
Proof of concept
Jonathan Frederic -
Show More
@@ -0,0 +1,5 b''
1 ((= Complex input/output style =))
2
3 ((*- extends 'latex_base.tplx' -*))
4
5 ((*- block input_group scoped -*))+++prompt+++((*- endblock input_group -*))
@@ -0,0 +1,5 b''
1 ((*- if not cell_style is defined -*))
2 ((*- set cell_style = 'complex_style.tplx' -*))
3 ((*- endif -*))
4
5 ((*- extends 'latex_article.tplx' -*))
@@ -0,0 +1,7 b''
1 ((= Complex input/output style =))
2
3 ((*- if not cell_style is defined -*))
4 ((*- set cell_style = 'simple_style.tplx' -*))
5 ((*- endif -*))
6
7 ((*- extends cell_style -*))
@@ -1,179 +1,171 b''
1 ((= Latex base template (must inherit)
1 ((= Latex base template (must inherit)
2 This template builds upon the abstract template, adding common latex output
2 This template builds upon the abstract template, adding common latex output
3 functions. Figures, data_text,
3 functions. Figures, data_text,
4 This template does not define a docclass, the inheriting class must define this.=))
4 This template does not define a docclass, the inheriting class must define this.=))
5
5
6 ((*- extends 'abstract.tplx' -*))
6 ((*- extends 'abstract.tplx' -*))
7
7
8 %===============================================================================
8 %===============================================================================
9 % Abstract overrides
9 % Abstract overrides
10 %===============================================================================
10 %===============================================================================
11
11
12 ((* block packages *))
12 ((* block packages *))
13 \usepackage{graphicx} % Used to insert images
13 \usepackage{graphicx} % Used to insert images
14 \usepackage{adjustbox} % Used to constrain images to a maximum size
14 \usepackage{adjustbox} % Used to constrain images to a maximum size
15 \usepackage{color} % Allow colors to be defined
15 \usepackage{color} % Allow colors to be defined
16 \usepackage{enumerate} % Needed for markdown enumerations to work
16 \usepackage{enumerate} % Needed for markdown enumerations to work
17 \usepackage{fancyvrb} % Needed to support color codes (tex) in verbatim blocks
17 \usepackage{fancyvrb} % Needed to support color codes (tex) in verbatim blocks
18 \usepackage{geometry} % Used to adjust the document margins
18 \usepackage{geometry} % Used to adjust the document margins
19 \usepackage{amsmath} % Equations
19 \usepackage{amsmath} % Equations
20 \usepackage{amssymb} % Equations
20 \usepackage{amssymb} % Equations
21 \usepackage[utf8]{inputenc} % Allow utf-8 characters in the tex document
21 \usepackage[utf8]{inputenc} % Allow utf-8 characters in the tex document
22 \usepackage{ucs} % Extended unicode (utf-8) support
22 \usepackage{ucs} % Extended unicode (utf-8) support
23 \usepackage{grffile} % extends the file name processing of package graphics
23 \usepackage{grffile} % extends the file name processing of package graphics
24 %to support a larger range
24 %to support a larger range
25
25
26 % The hyperref package gives us a pdf with properly built
26 % The hyperref package gives us a pdf with properly built
27 % internal navigation ('pdf bookmarks' for the table of contents,
27 % internal navigation ('pdf bookmarks' for the table of contents,
28 % internal cross-reference links, web links for URLs, etc.)
28 % internal cross-reference links, web links for URLs, etc.)
29 \usepackage{hyperref}
29 \usepackage{hyperref}
30 ((* endblock packages *))
30 ((* endblock packages *))
31
31
32 ((* block definitions *))
32 ((* block definitions *))
33 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
33 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
34 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
34 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
35 \definecolor{darkgreen}{rgb}{.12,.54,.11}
35 \definecolor{darkgreen}{rgb}{.12,.54,.11}
36 \definecolor{myteal}{rgb}{.26, .44, .56}
36 \definecolor{myteal}{rgb}{.26, .44, .56}
37 \definecolor{gray}{gray}{0.45}
37 \definecolor{gray}{gray}{0.45}
38 \definecolor{lightgray}{gray}{.95}
38 \definecolor{lightgray}{gray}{.95}
39 \definecolor{mediumgray}{gray}{.8}
39 \definecolor{mediumgray}{gray}{.8}
40 \definecolor{inputbackground}{rgb}{.95, .95, .85}
40 \definecolor{inputbackground}{rgb}{.95, .95, .85}
41 \definecolor{outputbackground}{rgb}{.95, .95, .95}
41 \definecolor{outputbackground}{rgb}{.95, .95, .95}
42 \definecolor{traceback}{rgb}{1, .95, .95}
42 \definecolor{traceback}{rgb}{1, .95, .95}
43
43
44 % new ansi colors
44 % new ansi colors
45 \definecolor{brown}{rgb}{0.54,0.27,0.07}
45 \definecolor{brown}{rgb}{0.54,0.27,0.07}
46 \definecolor{purple}{rgb}{0.5,0.0,0.5}
46 \definecolor{purple}{rgb}{0.5,0.0,0.5}
47 \definecolor{darkgray}{gray}{0.25}
47 \definecolor{darkgray}{gray}{0.25}
48 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
48 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
49 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
49 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
50 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
50 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
51 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
51 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
52 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
52 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
53
53
54 ((* endblock definitions *))
54 ((* endblock definitions *))
55
55
56 ((* block commands *))
56 ((* block commands *))
57 \sloppy % Prevent overflowing lines due to hard-to-break entities
57 \sloppy % Prevent overflowing lines due to hard-to-break entities
58
58
59 % Setup hyperref package
59 % Setup hyperref package
60 \hypersetup{
60 \hypersetup{
61 breaklinks=true, % so long urls are correctly broken across lines
61 breaklinks=true, % so long urls are correctly broken across lines
62 colorlinks=true,
62 colorlinks=true,
63 urlcolor=blue,
63 urlcolor=blue,
64 linkcolor=darkorange,
64 linkcolor=darkorange,
65 citecolor=darkgreen,
65 citecolor=darkgreen,
66 }
66 }
67
67
68 % Slightly bigger margins than the latex defaults
68 % Slightly bigger margins than the latex defaults
69 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
69 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
70
70
71 % Hardcode size of all verbatim environments to be a bit smaller
71 % Hardcode size of all verbatim environments to be a bit smaller
72 \makeatletter
72 \makeatletter
73 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
73 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
74 \makeatother
74 \makeatother
75 ((* endblock commands *))
75 ((* endblock commands *))
76
76
77 %===============================================================================
77 %===============================================================================
78 % Support blocks
78 % Support blocks
79 %===============================================================================
79 %===============================================================================
80
80
81 % Default output style -code cell style %Use filters ot do cell latex formating
82 ((* block header scoped *))
83 ((( super() )))
84 ((* block output_style scoped *))
85 ((* include 'simple_style.tplx' with context *))
86 ((* endblock output_style *))
87 ((* endblock header *))
88
89 % Displaying simple data text
81 % Displaying simple data text
90 ((* block data_text *))
82 ((* block data_text *))
91 \begin{verbatim}
83 \begin{verbatim}
92 ((( output.text | escape_latex )))
84 ((( output.text | escape_latex )))
93 \end{verbatim}
85 \end{verbatim}
94 ((* endblock data_text *))
86 ((* endblock data_text *))
95
87
96 % Display python error text as-is
88 % Display python error text as-is
97 ((* block pyerr *))
89 ((* block pyerr *))
98 \begin{verbatim}
90 \begin{verbatim}
99 ((( super() )))
91 ((( super() )))
100 \end{verbatim}
92 \end{verbatim}
101 ((* endblock pyerr *))
93 ((* endblock pyerr *))
102 ((* block traceback_line *))
94 ((* block traceback_line *))
103 ((( line | indent | strip_ansi | escape_latex )))
95 ((( line | indent | strip_ansi | escape_latex )))
104 ((* endblock traceback_line *))
96 ((* endblock traceback_line *))
105
97
106 % Display stream ouput with coloring
98 % Display stream ouput with coloring
107 ((* block stream *))
99 ((* block stream *))
108 \begin{Verbatim}[commandchars=\\\{\}]
100 \begin{Verbatim}[commandchars=\\\{\}]
109 ((( output.text | ansi2latex )))
101 ((( output.text | ansi2latex )))
110 \end{Verbatim}
102 \end{Verbatim}
111 ((* endblock stream *))
103 ((* endblock stream *))
112
104
113 % Display latex
105 % Display latex
114 ((* block data_latex -*))
106 ((* block data_latex -*))
115 ((*- if output.latex.startswith('$'): -*))
107 ((*- if output.latex.startswith('$'): -*))
116 ((= Replace $ symbols with more explicit, equation block. =))
108 ((= Replace $ symbols with more explicit, equation block. =))
117 \begin{equation*}
109 \begin{equation*}
118 ((( output.latex | strip_dollars )))
110 ((( output.latex | strip_dollars )))
119 \end{equation*}
111 \end{equation*}
120 ((*- else -*))
112 ((*- else -*))
121 ((( output.latex )))
113 ((( output.latex )))
122 ((*- endif *))
114 ((*- endif *))
123 ((* endblock data_latex *))
115 ((* endblock data_latex *))
124
116
125 % Default mechanism for rendering figures
117 % Default mechanism for rendering figures
126 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
118 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
127 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
119 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
128 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
120 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
129 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
121 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
130
122
131 % Draw a figure using the graphicx package.
123 % Draw a figure using the graphicx package.
132 ((* macro draw_figure(filename) -*))
124 ((* macro draw_figure(filename) -*))
133 ((* set filename = filename | posix_path *))
125 ((* set filename = filename | posix_path *))
134 ((*- block figure scoped -*))
126 ((*- block figure scoped -*))
135 \begin{center}
127 \begin{center}
136 \adjustimage{max size={0.9\linewidth}{..}}{((( filename )))}
128 \adjustimage{max size={0.9\linewidth}{..}}{((( filename )))}
137 \par
129 \par
138 \end{center}
130 \end{center}
139 ((*- endblock figure -*))
131 ((*- endblock figure -*))
140 ((*- endmacro *))
132 ((*- endmacro *))
141
133
142 % Draw heading cell. Explicitly map different cell levels.
134 % Draw heading cell. Explicitly map different cell levels.
143 ((* block headingcell scoped -*))
135 ((* block headingcell scoped -*))
144 ((*- if cell.level == 1 -*))
136 ((*- if cell.level == 1 -*))
145 ((* block h1 -*))\section((* endblock h1 -*))
137 ((* block h1 -*))\section((* endblock h1 -*))
146 ((*- elif cell.level == 2 -*))
138 ((*- elif cell.level == 2 -*))
147 ((* block h2 -*))\subsection((* endblock h2 -*))
139 ((* block h2 -*))\subsection((* endblock h2 -*))
148 ((*- elif cell.level == 3 -*))
140 ((*- elif cell.level == 3 -*))
149 ((* block h3 -*))\subsubsection((* endblock h3 -*))
141 ((* block h3 -*))\subsubsection((* endblock h3 -*))
150 ((*- elif cell.level == 4 -*))
142 ((*- elif cell.level == 4 -*))
151 ((* block h4 -*))\paragraph((* endblock h4 -*))
143 ((* block h4 -*))\paragraph((* endblock h4 -*))
152 ((*- elif cell.level == 5 -*))
144 ((*- elif cell.level == 5 -*))
153 ((* block h5 -*))\subparagraph((* endblock h5 -*))
145 ((* block h5 -*))\subparagraph((* endblock h5 -*))
154 ((*- elif cell.level == 6 -*))
146 ((*- elif cell.level == 6 -*))
155 ((* block h6 -*))\\*\textit((* endblock h6 -*))
147 ((* block h6 -*))\\*\textit((* endblock h6 -*))
156 ((*- endif -*))
148 ((*- endif -*))
157 {((( cell.source | escape_latex )))}
149 {((( cell.source | escape_latex )))}
158 ((*- endblock headingcell *))
150 ((*- endblock headingcell *))
159
151
160 % Redirect pyout to display data priority.
152 % Redirect pyout to display data priority.
161 ((* block pyout scoped *))
153 ((* block pyout scoped *))
162 ((* block data_priority scoped *))
154 ((* block data_priority scoped *))
163 ((( super() )))
155 ((( super() )))
164 ((* endblock *))
156 ((* endblock *))
165 ((* endblock pyout *))
157 ((* endblock pyout *))
166
158
167 % Render markdown
159 % Render markdown
168 ((* block markdowncell scoped *))
160 ((* block markdowncell scoped *))
169 ((( cell.source | markdown2latex )))
161 ((( cell.source | markdown2latex )))
170 ((* endblock markdowncell *))
162 ((* endblock markdowncell *))
171
163
172 % Spit out the contents of raw cells unmodified
164 % Spit out the contents of raw cells unmodified
173 ((* block rawcell scoped *))
165 ((* block rawcell scoped *))
174 ((( cell.source )))
166 ((( cell.source )))
175 ((* endblock rawcell *))
167 ((* endblock rawcell *))
176
168
177 % Don't display unknown types
169 % Don't display unknown types
178 ((* block unknowncell scoped *))
170 ((* block unknowncell scoped *))
179 ((* endblock unknowncell *))
171 ((* endblock unknowncell *))
@@ -1,4 +1,5 b''
1 ((= Simple input/output style =))
1 ((= Simple input/output style =))
2
2
3 !!!outputstyle!!!
3 ((*- extends 'latex_base.tplx' -*))
4 ((*- block in_prompt scoped -*))!!!prompt!!!((*- endblock in_prompt -*))
4
5 ((*- block input_group scoped -*))!!!prompt!!!((*- endblock input_group -*))
General Comments 0
You need to be logged in to leave comments. Login now