Show More
@@ -1,21 +1,17 b'' | |||
|
1 | 1 | |
|
2 | %=============================================================================== | |
|
3 | % Cell style | |
|
4 | %=============================================================================== | |
|
5 | ||
|
6 | 2 | % Default to the simple output style |
|
7 | 3 | ((* if not cell_style is defined *)) |
|
8 | 4 | ((* set cell_style = 'notebook_style.tplx' *)) |
|
9 | 5 | ((* endif *)) |
|
10 | 6 | |
|
11 | 7 | % Inherit from the specified cell style. |
|
12 | 8 | ((* extends cell_style *)) |
|
13 | 9 | |
|
14 | 10 | |
|
15 | 11 | %=============================================================================== |
|
16 | 12 | % Latex Article |
|
17 | 13 | %=============================================================================== |
|
18 | 14 | |
|
19 | 15 | ((* block docclass *)) |
|
20 | 16 | \documentclass{article} |
|
21 | 17 | ((* endblock docclass *)) No newline at end of file |
@@ -1,33 +1,29 b'' | |||
|
1 | 1 | |
|
2 | %=============================================================================== | |
|
3 | % Cell style | |
|
4 | %=============================================================================== | |
|
5 | ||
|
6 | 2 | % Default to the simple output style |
|
7 | 3 | ((* if not cell_style is defined *)) |
|
8 | 4 | ((* set cell_style = 'simple_style.tplx' *)) |
|
9 | 5 | ((* endif *)) |
|
10 | 6 | |
|
11 | 7 | % Inherit from the specified cell style. |
|
12 | 8 | ((* extends cell_style *)) |
|
13 | 9 | |
|
14 | 10 | |
|
15 | 11 | %=============================================================================== |
|
16 | 12 | % Latex Book |
|
17 | 13 | %=============================================================================== |
|
18 | 14 | |
|
19 | 15 | ((* block predoc *)) |
|
20 | 16 | ((( super() ))) |
|
21 | 17 | ((* block tableofcontents *))\tableofcontents((* endblock tableofcontents *)) |
|
22 | 18 | ((* endblock predoc *)) |
|
23 | 19 | |
|
24 | 20 | ((* block docclass *)) |
|
25 | 21 | \documentclass{book} |
|
26 | 22 | ((* endblock docclass *)) |
|
27 | 23 | |
|
28 | 24 | ((* block h1 -*))\part((* endblock h1 -*)) |
|
29 | 25 | ((* block h2 -*))\chapter((* endblock h2 -*)) |
|
30 | 26 | ((* block h3 -*))\section((* endblock h3 -*)) |
|
31 | 27 | ((* block h4 -*))\subsection((* endblock h4 -*)) |
|
32 | 28 | ((* block h5 -*))\subsubsection((* endblock h5 -*)) |
|
33 | 29 | ((* block h6 -*))\paragraph((* endblock h6 -*)) No newline at end of file |
@@ -1,40 +1,34 b'' | |||
|
1 | ||
|
2 | %=============================================================================== | |
|
3 | % Cell style | |
|
4 | %=============================================================================== | |
|
5 | ||
|
6 | % Inherit from the specified cell style. | |
|
7 | 1 | ((* extends 'latex_article.tplx' *)) |
|
8 | 2 | |
|
9 | 3 | %=============================================================================== |
|
10 | 4 | % Latex Sphinx Article |
|
11 | 5 | %=============================================================================== |
|
12 | 6 | |
|
13 | 7 | ((* block docclass *)) |
|
14 | 8 | % Make sure that the sphinx doc style knows who it inherits from. |
|
15 | 9 | \def\sphinxdocclass{article} |
|
16 | 10 | |
|
17 | 11 | % Declare the document class |
|
18 | 12 | \documentclass[letterpaper,10pt,english]{((( resources.sphinx.texinputs | posix_path )))/sphinxhowto} |
|
19 | 13 | ((* endblock docclass *)) |
|
20 | 14 | |
|
21 | 15 | ((* block packages *)) |
|
22 | 16 | ((* block chstyle *)) |
|
23 | 17 | \usepackage[Bjarne]{((( resources.sphinx.texinputs | posix_path )))/fncychap} |
|
24 | 18 | ((* endblock chstyle *)) |
|
25 | 19 | |
|
26 | 20 | \usepackage{((( resources.sphinx.texinputs | posix_path )))/sphinx} |
|
27 | 21 | |
|
28 | 22 | ((( super() ))) |
|
29 | 23 | ((* endblock packages *)) |
|
30 | 24 | |
|
31 | 25 | ((* block commands *)) |
|
32 | 26 | ((( super() ))) |
|
33 | 27 | |
|
34 | 28 | % Override to specify your own logo |
|
35 | 29 | ((* block logo *))\newcommand{\sphinxlogo}{}((* endblock logo *)) |
|
36 | 30 | |
|
37 | 31 | % Make the index page of the document. |
|
38 | 32 | \makeindex |
|
39 | 33 | |
|
40 | 34 | ((* endblock commands *)) |
@@ -1,191 +1,190 b'' | |||
|
1 | 1 | ((= Notebook input/output style =)) |
|
2 | 2 | |
|
3 | 3 | ((* extends 'latex_base.tplx' *)) |
|
4 | 4 | |
|
5 | 5 | % Custom packages |
|
6 | 6 | ((* block packages *)) |
|
7 | 7 | ((( super() ))) |
|
8 | 8 | |
|
9 | 9 | \usepackage{tikz} % Needed to box output/input |
|
10 | 10 | \usepackage{scrextend} % Used to indent output |
|
11 | 11 | \usepackage{needspace} % Make prompts follow contents |
|
12 | 12 | \usepackage{framed} % Used to draw output that spans multiple pages |
|
13 | 13 | ((* endblock packages *)) |
|
14 | 14 | |
|
15 | 15 | % Custom definitions |
|
16 | 16 | ((* block definitions *)) |
|
17 | 17 | ((( super() ))) |
|
18 | 18 | |
|
19 | 19 | % Pygments definitions |
|
20 | 20 | ((( resources.latex.pygment_definitions ))) |
|
21 | 21 | |
|
22 | 22 | % NB prompt colors |
|
23 | 23 | \definecolor{nbframe-border}{rgb}{0.867,0.867,0.867} |
|
24 | 24 | \definecolor{nbframe-bg}{rgb}{0.969,0.969,0.969} |
|
25 | 25 | \definecolor{nbframe-in-prompt}{rgb}{0.0,0.0,0.502} |
|
26 | 26 | \definecolor{nbframe-out-prompt}{rgb}{0.545,0.0,0.0} |
|
27 | 27 | |
|
28 | 28 | % NB prompt lengths |
|
29 | 29 | \newlength{\inputpadding} |
|
30 | 30 | \setlength{\inputpadding}{0.5em} |
|
31 | 31 | \newlength{\cellleftmargin} |
|
32 | 32 | \setlength{\cellleftmargin}{0.15\linewidth} |
|
33 | 33 | \newlength{\borderthickness} |
|
34 | 34 | \setlength{\borderthickness}{0.4pt} |
|
35 | 35 | \newlength{\smallerfontscale} |
|
36 | 36 | \setlength{\smallerfontscale}{9.5pt} |
|
37 | 37 | |
|
38 | 38 | % NB prompt font size |
|
39 | 39 | \def\smaller{\fontsize{\smallerfontscale}{\smallerfontscale}\selectfont} |
|
40 | 40 | |
|
41 | 41 | % Define a background layer, in which the nb prompt shape is drawn |
|
42 | 42 | \pgfdeclarelayer{background} |
|
43 | 43 | \pgfsetlayers{background,main} |
|
44 | 44 | \usetikzlibrary{calc} |
|
45 | 45 | |
|
46 | 46 | % define styles for the normal border and the torn border |
|
47 | 47 | \tikzset{ |
|
48 | 48 | normal border/.style={draw=nbframe-border, fill=nbframe-bg, |
|
49 | 49 | rectangle, rounded corners=2.5pt, line width=\borderthickness}, |
|
50 | 50 | torn border/.style={draw=white, fill=white, line width=\borderthickness}} |
|
51 | 51 | |
|
52 | 52 | % Macro to draw the shape behind the text, when it fits completly in the |
|
53 | 53 | % page |
|
54 | 54 | \def\notebookcellframe#1{% |
|
55 | 55 | \tikz{% |
|
56 | 56 | \node[inner sep=\inputpadding] (A) {#1};% Draw the text of the node |
|
57 | 57 | \begin{pgfonlayer}{background}% Draw the shape behind |
|
58 | 58 | \fill[normal border]% |
|
59 | 59 | (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- |
|
60 | 60 | ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; |
|
61 | 61 | \end{pgfonlayer}}}% |
|
62 | 62 | |
|
63 | 63 | % Macro to draw the shape, when the text will continue in next page |
|
64 | 64 | \def\notebookcellframetop#1{% |
|
65 | 65 | \tikz{% |
|
66 | 66 | \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node |
|
67 | 67 | \begin{pgfonlayer}{background} |
|
68 | 68 | \fill[normal border] % Draw the ``complete shape'' behind |
|
69 | 69 | (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- |
|
70 | 70 | ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; |
|
71 | 71 | \fill[torn border] % Add the torn lower border |
|
72 | 72 | ($(A.south east)-(0,.1)$) -- ($(A.south west)+(\cellleftmargin,-.1)$) -- |
|
73 | 73 | ($(A.south west)+(\cellleftmargin,.1)$) -- ($(A.south east)+(0,.1)$) -- cycle; |
|
74 | 74 | \end{pgfonlayer}}} |
|
75 | 75 | |
|
76 | 76 | % Macro to draw the shape, when the text continues from previous page |
|
77 | 77 | \def\notebookcellframebottom#1{% |
|
78 | 78 | \tikz{% |
|
79 | 79 | \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node |
|
80 | 80 | \begin{pgfonlayer}{background} |
|
81 | 81 | \fill[normal border] % Draw the ``complete shape'' behind |
|
82 | 82 | (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- |
|
83 | 83 | ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; |
|
84 | 84 | \fill[torn border] % Add the torn upper border |
|
85 | 85 | ($(A.north east)-(0,.1)$) -- ($(A.north west)+(\cellleftmargin,-.1)$) -- |
|
86 | 86 | ($(A.north west)+(\cellleftmargin,.1)$) -- ($(A.north east)+(0,.1)$) -- cycle; |
|
87 | 87 | \end{pgfonlayer}}} |
|
88 | 88 | |
|
89 | 89 | % Macro to draw the shape, when both the text continues from previous page |
|
90 | 90 | % and it will continue in next page |
|
91 | 91 | \def\notebookcellframemiddle#1{% |
|
92 | 92 | \tikz{% |
|
93 | 93 | \node[inner sep=\inputpadding] (A) {#1}; % Draw the text of the node |
|
94 | 94 | \begin{pgfonlayer}{background} |
|
95 | 95 | \fill[normal border] % Draw the ``complete shape'' behind |
|
96 | 96 | (A.south east) -- ($(A.south west)+(\cellleftmargin,0)$) -- |
|
97 | 97 | ($(A.north west)+(\cellleftmargin,0)$) -- (A.north east) -- cycle; |
|
98 | 98 | \fill[torn border] % Add the torn lower border |
|
99 | 99 | ($(A.south east)-(0,.1)$) -- ($(A.south west)+(\cellleftmargin,-.1)$) -- |
|
100 | 100 | ($(A.south west)+(\cellleftmargin,.1)$) -- ($(A.south east)+(0,.1)$) -- cycle; |
|
101 | 101 | \fill[torn border] % Add the torn upper border |
|
102 | 102 | ($(A.north east)-(0,.1)$) -- ($(A.north west)+(\cellleftmargin,-.1)$) -- |
|
103 | 103 | ($(A.north west)+(\cellleftmargin,.1)$) -- ($(A.north east)+(0,.1)$) -- cycle; |
|
104 | 104 | \end{pgfonlayer}}} |
|
105 | 105 | |
|
106 | 106 | % Define the environment which puts the frame |
|
107 | 107 | % In this case, the environment also accepts an argument with an optional |
|
108 | 108 | % title (which defaults to ``Example'', which is typeset in a box overlaid |
|
109 | 109 | % on the top border |
|
110 | 110 | \newenvironment{notebookcell}[1][0]{% |
|
111 | 111 | \def\FrameCommand{\notebookcellframe}% |
|
112 | 112 | \def\FirstFrameCommand{\notebookcellframetop}% |
|
113 | 113 | \def\LastFrameCommand{\notebookcellframebottom}% |
|
114 | 114 | \def\MidFrameCommand{\notebookcellframemiddle}% |
|
115 | 115 | \par\vspace{1\baselineskip}% |
|
116 | 116 | \MakeFramed {\FrameRestore}% |
|
117 | 117 | \noindent\tikz\node[inner sep=0em] at ($(A.north west)-(0,0)$) {% |
|
118 | 118 | ((( draw_prompt("In", "#1", "nbframe-in-prompt", "2pt") )))% |
|
119 | 119 | }; \par}% |
|
120 | 120 | {\endMakeFramed} |
|
121 | 121 | |
|
122 | 122 | ((* endblock definitions *)) |
|
123 | 123 | |
|
124 | ||
|
125 | 124 | %=============================================================================== |
|
126 | 125 | % Input |
|
127 | 126 | %=============================================================================== |
|
128 | 127 | |
|
129 | 128 | ((* block input scoped *)) |
|
130 | 129 | % Add contents below. |
|
131 | 130 | |
|
132 | 131 | {\par% |
|
133 | 132 | \vspace{-1\baselineskip}% |
|
134 | 133 | \needspace{4\baselineskip}}% |
|
135 | 134 | \begin{notebookcell}[((( cell.prompt_number )))]% |
|
136 | 135 | \begin{addmargin}[\cellleftmargin]{0em}% left, right |
|
137 | 136 | {\smaller% |
|
138 | 137 | \par% |
|
139 | 138 | ((* block extra_input_spacing *))((* endblock extra_input_spacing *))% |
|
140 | 139 | \vspace{-1\smallerfontscale}% |
|
141 | 140 | ((( cell.input | highlight2latex )))% |
|
142 | 141 | \par% |
|
143 | 142 | \vspace{-1\smallerfontscale}}% |
|
144 | 143 | \end{addmargin} |
|
145 | 144 | \end{notebookcell} |
|
146 | 145 | |
|
147 | 146 | ((* endblock input *)) |
|
148 | 147 | |
|
149 | 148 | %=============================================================================== |
|
150 | 149 | % Output |
|
151 | 150 | %=============================================================================== |
|
152 | 151 | |
|
153 | 152 | ((* block output -*)) |
|
154 | 153 | \par\vspace{1\smallerfontscale}% |
|
155 | 154 | % Only render the prompt if the cell is pyout. Note, the outputs prompt |
|
156 | 155 | % block isn't used since we need to check each indiviual output and only |
|
157 | 156 | % add prompts to the pyout ones. |
|
158 | 157 | ((* if output.output_type in ['pyout'] *)) |
|
159 | 158 | {\par% |
|
160 | 159 | \vspace{-1\smallerfontscale}% |
|
161 | 160 | \noindent% |
|
162 | 161 | ((( draw_prompt("Out", cell.prompt_number, "nbframe-out-prompt", "0em") )))% |
|
163 | 162 | ((* block extra_output_spacing *))((* endblock extra_output_spacing *))}% |
|
164 | 163 | ((* endif *))% |
|
165 | 164 | % |
|
166 | 165 | \begin{addmargin}[\cellleftmargin]{0em}% left, right |
|
167 | 166 | {\smaller% |
|
168 | 167 | \vspace{-1\smallerfontscale}% |
|
169 | 168 | ((( super() )))}% |
|
170 | 169 | \end{addmargin}% |
|
171 | 170 | ((*- endblock output *)) |
|
172 | 171 | |
|
173 | 172 | %============================================================================== |
|
174 | 173 | % Support Macros |
|
175 | 174 | %============================================================================== |
|
176 | 175 | |
|
177 | 176 | % Name: draw_prompt |
|
178 | 177 | % Purpose: Renders an output/input prompt for notebook style pdfs |
|
179 | 178 | ((* macro draw_prompt(prompt, number, color, space) -*)) |
|
180 | 179 | \begin{minipage}{\cellleftmargin}% |
|
181 | 180 | \hfill% |
|
182 | 181 | {\smaller% |
|
183 | 182 | \tt% |
|
184 | 183 | \color{(((color)))}% |
|
185 | 184 | (((prompt)))[(((number)))]:}% |
|
186 | 185 | \hspace{\inputpadding}% |
|
187 | 186 | \hspace{(((space)))}% |
|
188 | 187 | \hspace{3pt}% |
|
189 | 188 | \end{minipage}% |
|
190 | 189 | ((*- endmacro *)) |
|
191 | 190 |
@@ -1,68 +1,67 b'' | |||
|
1 | 1 | ((= Simple input/output style =)) |
|
2 | 2 | |
|
3 | 3 | ((*- extends 'latex_base.tplx' -*)) |
|
4 | 4 | |
|
5 | ||
|
6 | 5 | % Custom packages |
|
7 | 6 | ((* block packages *)) |
|
8 | 7 | ((( super() ))) |
|
9 | 8 | |
|
10 | 9 | \usepackage{needspace} % Make prompts follow contents |
|
11 | 10 | ((* endblock packages *)) |
|
12 | 11 | |
|
13 | 12 | % Custom definitions |
|
14 | 13 | ((* block definitions *)) |
|
15 | 14 | ((( super() ))) |
|
16 | 15 | |
|
17 | 16 | % Pygments definitions |
|
18 | 17 | ((( resources.latex.pygment_definitions ))) |
|
19 | 18 | |
|
20 | 19 | \newlength{\promptspace} |
|
21 | 20 | \setlength{\promptspace}{4\baselineskip} % Space needed to start a new |
|
22 | 21 | % input/output |
|
23 | 22 | ((* endblock definitions *)) |
|
24 | 23 | %=============================================================================== |
|
25 | 24 | % Input |
|
26 | 25 | %=============================================================================== |
|
27 | 26 | |
|
28 | 27 | ((*- block in_prompt scoped -*)) |
|
29 | 28 | ((( draw_prompt('Input') ))) |
|
30 | 29 | ((*- endblock in_prompt -*)) |
|
31 | 30 | |
|
32 | 31 | ((*- block input_group scoped -*)) |
|
33 | 32 | (((- super() ))) |
|
34 | 33 | \vspace{-2em} |
|
35 | 34 | ((* endblock input_group -*)) |
|
36 | 35 | |
|
37 | 36 | ((* block input scoped *)) |
|
38 | 37 | ((( cell.input | highlight2latex ))) |
|
39 | 38 | ((* endblock input *)) |
|
40 | 39 | |
|
41 | 40 | %=============================================================================== |
|
42 | 41 | % Output |
|
43 | 42 | %=============================================================================== |
|
44 | 43 | |
|
45 | 44 | ((*- block output_prompt scoped -*)) |
|
46 | 45 | ((( draw_prompt('Output') ))) |
|
47 | 46 | ((*- endblock output_prompt -*)) |
|
48 | 47 | |
|
49 | 48 | ((*- block output_group scoped -*)) |
|
50 | 49 | (((- super() ))) |
|
51 | 50 | \vspace{-2em} |
|
52 | 51 | ((* endblock output_group -*)) |
|
53 | 52 | |
|
54 | 53 | %============================================================================== |
|
55 | 54 | % Support Macros |
|
56 | 55 | %============================================================================== |
|
57 | 56 | |
|
58 | 57 | % Name: draw_prompt |
|
59 | 58 | % Purpose: Renders an output/input prompt for notebook style pdfs |
|
60 | 59 | ((* macro draw_prompt(prompt) *)) |
|
61 | 60 | % Add a horizantal break, along with break title. |
|
62 | 61 | \needspace{\promptspace} |
|
63 | 62 | \br\br |
|
64 | 63 | {\scriptsize ((( prompt )))} |
|
65 | 64 | \br |
|
66 | 65 | \rule[10pt]{\linewidth}{0.5pt} |
|
67 | 66 | \vspace{-2.5em} |
|
68 | 67 | ((* endmacro *)) |
General Comments 0
You need to be logged in to leave comments.
Login now