##// END OF EJS Templates
start tex template
Matthias BUSSONNIER -
Show More
@@ -44,6 +44,7 b' from IPython.utils.text import indent'
44 from .utils import remove_ansi
44 from .utils import remove_ansi
45 from markdown import markdown
45 from markdown import markdown
46 from .utils import highlight, ansi2html
46 from .utils import highlight, ansi2html
47 from .utils import markdown2latex
47 #-----------------------------------------------------------------------------
48 #-----------------------------------------------------------------------------
48 # Class declarations
49 # Class declarations
49 #-----------------------------------------------------------------------------
50 #-----------------------------------------------------------------------------
@@ -143,6 +144,8 b" texenv.filters['rm_ansi'] = remove_ansi"
143 texenv.filters['markdown'] = markdown
144 texenv.filters['markdown'] = markdown
144 texenv.filters['highlight'] = highlight
145 texenv.filters['highlight'] = highlight
145 texenv.filters['ansi2html'] = ansi2html
146 texenv.filters['ansi2html'] = ansi2html
147 texenv.filters['markdown2latex'] = markdown2latex
148 markdown2latex
146
149
147
150
148 def haspyout_transformer(nb,_):
151 def haspyout_transformer(nb,_):
@@ -7,7 +7,18 b''
7 ((* block output_prompt *))
7 ((* block output_prompt *))
8 # Out[(((cell.prompt_number)))]:((* endblock output_prompt *))
8 # Out[(((cell.prompt_number)))]:((* endblock output_prompt *))
9
9
10 ((* block input *))((( cell.input )))
10 ((* block codecell *))
11 \begin{codecell}
12 ((( super() )))
13 \end{codecell}
14 ((* endblock *))
15
16 ((* block input *))
17 \begin{codeinput}
18 \begin{lstlisting}
19 ((( cell.input )))
20 \end{lstlisting}
21 \end{codeinput}
11 ((* endblock input *))
22 ((* endblock input *))
12
23
13
24
@@ -40,11 +51,11 b' it introduces a new line'
40 ((* endblock display_data *))
51 ((* endblock display_data *))
41
52
42 ((* block markdowncell scoped *))
53 ((* block markdowncell scoped *))
43 ((( cell.source | pycomment )))
54 ((( cell.source | markdown2latex )))
44 ((* endblock markdowncell *))
55 ((* endblock markdowncell *))
45
56
46 ((* block headingcell scoped *))
57 ((* block headingcell scoped *))
47 ((( '#' * cell.level )))((( cell.source | pycomment)))
58 \section{((( cell.source)))}
48 ((* endblock headingcell *))
59 ((* endblock headingcell *))
49
60
50 ((* block rawcell scoped *))
61 ((* block rawcell scoped *))
@@ -54,3 +65,134 b' it introduces a new line'
54 ((* block unknowncell scoped *))
65 ((* block unknowncell scoped *))
55 unknown type (((cell.type)))
66 unknown type (((cell.type)))
56 ((* endblock unknowncell *))
67 ((* endblock unknowncell *))
68
69
70
71 ((* block body *))
72 \begin{document}
73 ((( super() )))
74 \end{document}
75 ((* endblock*))
76
77 ((* block header *))
78 %% This file was auto-generated by IPython.
79 %% Conversion from the original notebook file:
80 %% tests/ipynbref/Gun_Data.orig.ipynb
81 %%
82 \documentclass[11pt,english]{article}
83
84 %% This is the automatic preamble used by IPython. Note that it does *not*
85 %% include a documentclass declaration, that is added at runtime to the overall
86 %% document.
87
88 \usepackage{amsmath}
89 \usepackage{amssymb}
90 \usepackage{graphicx}
91 \usepackage{ucs}
92 \usepackage[utf8x]{inputenc}
93
94 % needed for markdown enumerations to work
95 \usepackage{enumerate}
96
97 % Slightly bigger margins than the latex defaults
98 \usepackage{geometry}
99 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
100
101 % Define a few colors for use in code, links and cell shading
102 \usepackage{color}
103 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
104 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
105 \definecolor{darkgreen}{rgb}{.12,.54,.11}
106 \definecolor{myteal}{rgb}{.26, .44, .56}
107 \definecolor{gray}{gray}{0.45}
108 \definecolor{lightgray}{gray}{.95}
109 \definecolor{mediumgray}{gray}{.8}
110 \definecolor{inputbackground}{rgb}{.95, .95, .85}
111 \definecolor{outputbackground}{rgb}{.95, .95, .95}
112 \definecolor{traceback}{rgb}{1, .95, .95}
113
114 % Framed environments for code cells (inputs, outputs, errors, ...). The
115 % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't
116 % randomly change them unless you're sure of the effect it will have.
117 \usepackage{framed}
118
119 % remove extraneous vertical space in boxes
120 \setlength\fboxsep{0pt}
121
122 % codecell is the whole input+output set of blocks that a Code cell can
123 % generate.
124
125 % TODO: unfortunately, it seems that using a framed codecell environment breaks
126 % the ability of the frames inside of it to be broken across pages. This
127 % causes at least the problem of having lots of empty space at the bottom of
128 % pages as new frames are moved to the next page, and if a single frame is too
129 % long to fit on a page, will completely stop latex from compiling the
130 % document. So unless we figure out a solution to this, we'll have to instead
131 % leave the codecell env. as empty. I'm keeping the original codecell
132 % definition here (a thin vertical bar) for reference, in case we find a
133 % solution to the page break issue.
134
135 %% \newenvironment{codecell}{%
136 %% \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}%
137 %% \MakeFramed{\vspace{-0.5em}}}
138 %% {\unskip\endMakeFramed}
139
140 % For now, make this a no-op...
141 \newenvironment{codecell}{}
142
143 \newenvironment{codeinput}{%
144 \def\FrameCommand{\colorbox{inputbackground}}%
145 \MakeFramed{\advance\hsize-\width \FrameRestore}}
146 {\unskip\endMakeFramed}
147
148 \newenvironment{codeoutput}{%
149 \def\FrameCommand{\colorbox{outputbackground}}%
150 \vspace{-1.4em}
151 \MakeFramed{\advance\hsize-\width \FrameRestore}}
152 {\unskip\medskip\endMakeFramed}
153
154 \newenvironment{traceback}{%
155 \def\FrameCommand{\colorbox{traceback}}%
156 \MakeFramed{\advance\hsize-\width \FrameRestore}}
157 {\endMakeFramed}
158
159 % Use and configure listings package for nicely formatted code
160 \usepackage{listingsutf8}
161 \lstset{
162 language=python,
163 inputencoding=utf8x,
164 extendedchars=\true,
165 aboveskip=\smallskipamount,
166 belowskip=\smallskipamount,
167 xleftmargin=2mm,
168 breaklines=true,
169 basicstyle=\small \ttfamily,
170 showstringspaces=false,
171 keywordstyle=\color{blue}\bfseries,
172 commentstyle=\color{myteal},
173 stringstyle=\color{darkgreen},
174 identifierstyle=\color{darkorange},
175 columns=fullflexible, % tighter character kerning, like verb
176 }
177
178 % The hyperref package gives us a pdf with properly built
179 % internal navigation ('pdf bookmarks' for the table of contents,
180 % internal cross-reference links, web links for URLs, etc.)
181 \usepackage{hyperref}
182 \hypersetup{
183 breaklinks=true, % so long urls are correctly broken across lines
184 colorlinks=true,
185 urlcolor=blue,
186 linkcolor=darkorange,
187 citecolor=darkgreen,
188 }
189
190 % hardcode size of all verbatim environments to be a bit smaller
191 \makeatletter
192 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
193 \makeatother
194
195 % Prevent overflowing lines due to urls and other hard-to-break entities.
196 \sloppy
197
198 ((* endblock *))
General Comments 0
You need to be logged in to leave comments. Login now