##// END OF EJS Templates
Handle case where prompt number is not defined in latex templates
Jessica B. Hamrick -
Show More
@@ -1,41 +1,45 b''
1 ((= Black&white ipython input/output style =))
1 ((= Black&white ipython input/output style =))
2
2
3 ((*- extends 'base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 %===============================================================================
5 %===============================================================================
6 % Input
6 % Input
7 %===============================================================================
7 %===============================================================================
8
8
9 ((* block input scoped *))
9 ((* block input scoped *))
10 ((( add_prompt(cell.input, cell, 'In ') )))
10 ((( add_prompt(cell.input, cell, 'In ') )))
11 ((* endblock input *))
11 ((* endblock input *))
12
12
13
13
14 %===============================================================================
14 %===============================================================================
15 % Output
15 % Output
16 %===============================================================================
16 %===============================================================================
17
17
18 ((* block pyout scoped *))
18 ((* block pyout scoped *))
19 ((*- for type in output | filter_data_type -*))
19 ((*- for type in output | filter_data_type -*))
20 ((*- if type in ['text']*))
20 ((*- if type in ['text']*))
21 ((( add_prompt(output.text, cell, 'Out') )))
21 ((( add_prompt(output.text, cell, 'Out') )))
22 ((*- else -*))
22 ((*- else -*))
23 \verb+Out[((( cell.prompt_number )))]:+((( super() )))
23 \verb+Out[((( cell.prompt_number )))]:+((( super() )))
24 ((*- endif -*))
24 ((*- endif -*))
25 ((*- endfor -*))
25 ((*- endfor -*))
26 ((* endblock pyout *))
26 ((* endblock pyout *))
27
27
28
28
29 %==============================================================================
29 %==============================================================================
30 % Support Macros
30 % Support Macros
31 %==============================================================================
31 %==============================================================================
32
32
33 % Name: draw_prompt
33 % Name: draw_prompt
34 % Purpose: Renders an output/input prompt
34 % Purpose: Renders an output/input prompt
35 ((* macro add_prompt(text, cell, prompt) -*))
35 ((* macro add_prompt(text, cell, prompt) -*))
36 ((*- if cell.prompt_number is defined -*))
36 ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*))
37 ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*))
38 ((*- else -*))
39 ((*- set prompt_number = " " -*))
40 ((*- endif -*))
37 ((*- set indentation = " " * (prompt_number | length + 7) -*))
41 ((*- set indentation = " " * (prompt_number | length + 7) -*))
38 \begin{verbatim}
42 \begin{verbatim}
39 (((- text | add_prompts(first=prompt ~ '[' ~ prompt_number ~ ']: ', cont=indentation) -)))
43 (((- text | add_prompts(first=prompt ~ '[' ~ prompt_number ~ ']: ', cont=indentation) -)))
40 \end{verbatim}
44 \end{verbatim}
41 ((*- endmacro *))
45 ((*- endmacro *))
@@ -1,54 +1,58 b''
1 ((= IPython input/output style =))
1 ((= IPython input/output style =))
2
2
3 ((*- extends 'base.tplx' -*))
3 ((*- extends 'base.tplx' -*))
4
4
5 % Custom definitions
5 % Custom definitions
6 ((* block definitions *))
6 ((* block definitions *))
7 ((( super() )))
7 ((( super() )))
8
8
9 % Pygments definitions
9 % Pygments definitions
10 ((( resources.latex.pygments_definitions )))
10 ((( resources.latex.pygments_definitions )))
11
11
12 % Exact colors from NB
12 % Exact colors from NB
13 \definecolor{incolor}{rgb}{0.0, 0.0, 0.5}
13 \definecolor{incolor}{rgb}{0.0, 0.0, 0.5}
14 \definecolor{outcolor}{rgb}{0.545, 0.0, 0.0}
14 \definecolor{outcolor}{rgb}{0.545, 0.0, 0.0}
15
15
16 ((* endblock definitions *))
16 ((* endblock definitions *))
17
17
18 %===============================================================================
18 %===============================================================================
19 % Input
19 % Input
20 %===============================================================================
20 %===============================================================================
21
21
22 ((* block input scoped *))
22 ((* block input scoped *))
23 ((( add_prompt(cell.input | highlight2latex(strip_verbatim=True), cell, 'In ', 'incolor') )))
23 ((( add_prompt(cell.input | highlight2latex(strip_verbatim=True), cell, 'In ', 'incolor') )))
24 ((* endblock input *))
24 ((* endblock input *))
25
25
26
26
27 %===============================================================================
27 %===============================================================================
28 % Output
28 % Output
29 %===============================================================================
29 %===============================================================================
30
30
31 ((* block pyout scoped *))
31 ((* block pyout scoped *))
32 ((*- for type in output | filter_data_type -*))
32 ((*- for type in output | filter_data_type -*))
33 ((*- if type in ['text']*))
33 ((*- if type in ['text']*))
34 ((( add_prompt(output.text | escape_latex, cell, 'Out', 'outcolor') )))
34 ((( add_prompt(output.text | escape_latex, cell, 'Out', 'outcolor') )))
35 ((* else -*))
35 ((* else -*))
36 \texttt{\color{outcolor}Out[{\color{outcolor}((( cell.prompt_number )))}]:}((( super() )))
36 \texttt{\color{outcolor}Out[{\color{outcolor}((( cell.prompt_number )))}]:}((( super() )))
37 ((*- endif -*))
37 ((*- endif -*))
38 ((*- endfor -*))
38 ((*- endfor -*))
39 ((* endblock pyout *))
39 ((* endblock pyout *))
40
40
41
41
42 %==============================================================================
42 %==============================================================================
43 % Support Macros
43 % Support Macros
44 %==============================================================================
44 %==============================================================================
45
45
46 % Name: draw_prompt
46 % Name: draw_prompt
47 % Purpose: Renders an output/input prompt
47 % Purpose: Renders an output/input prompt
48 ((* macro add_prompt(text, cell, prompt, prompt_color) -*))
48 ((* macro add_prompt(text, cell, prompt, prompt_color) -*))
49 ((*- if cell.prompt_number is defined -*))
49 ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*))
50 ((*- set prompt_number = "" ~ (cell.prompt_number | replace(None, " ")) -*))
51 ((*- else -*))
52 ((*- set prompt_number = " " -*))
53 ((*- endif -*))
50 ((*- set indention = " " * (prompt_number | length + 7) -*))
54 ((*- set indention = " " * (prompt_number | length + 7) -*))
51 \begin{Verbatim}[commandchars=\\\{\}]
55 \begin{Verbatim}[commandchars=\\\{\}]
52 ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ prompt_number ~ '}]:} ', cont=indention) )))
56 ((( text | add_prompts(first='{\color{' ~ prompt_color ~ '}' ~ prompt ~ '[{\\color{' ~ prompt_color ~ '}' ~ prompt_number ~ '}]:} ', cont=indention) )))
53 \end{Verbatim}
57 \end{Verbatim}
54 ((*- endmacro *))
58 ((*- endmacro *))
General Comments 0
You need to be logged in to leave comments. Login now