##// END OF EJS Templates
Make codecell a no-op environment to allow page breaks in cells.
Fernando Perez -
Show More
@@ -1,98 +1,112 b''
1 %% This is the automatic preamble used by IPython. Note that it does *not*
1 %% This is the automatic preamble used by IPython. Note that it does *not*
2 %% include a documentclass declaration, that is added at runtime to the overall
2 %% include a documentclass declaration, that is added at runtime to the overall
3 %% document.
3 %% document.
4
4
5 \usepackage{amsmath}
5 \usepackage{amsmath}
6 \usepackage{amssymb}
6 \usepackage{amssymb}
7 \usepackage{graphicx}
7 \usepackage{graphicx}
8 \usepackage{ucs}
8 \usepackage{ucs}
9 \usepackage[utf8x]{inputenc}
9 \usepackage[utf8x]{inputenc}
10
10
11 % needed for markdown enumerations to work
11 % needed for markdown enumerations to work
12 \usepackage{enumerate}
12 \usepackage{enumerate}
13
13
14 % Slightly bigger margins than the latex defaults
14 % Slightly bigger margins than the latex defaults
15 \usepackage{geometry}
15 \usepackage{geometry}
16 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
16 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
17
17
18 % Define a few colors for use in code, links and cell shading
18 % Define a few colors for use in code, links and cell shading
19 \usepackage{color}
19 \usepackage{color}
20 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
20 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
21 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
21 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
22 \definecolor{darkgreen}{rgb}{.12,.54,.11}
22 \definecolor{darkgreen}{rgb}{.12,.54,.11}
23 \definecolor{myteal}{rgb}{.26, .44, .56}
23 \definecolor{myteal}{rgb}{.26, .44, .56}
24 \definecolor{gray}{gray}{0.45}
24 \definecolor{gray}{gray}{0.45}
25 \definecolor{lightgray}{gray}{.95}
25 \definecolor{lightgray}{gray}{.95}
26 \definecolor{mediumgray}{gray}{.8}
26 \definecolor{mediumgray}{gray}{.8}
27 \definecolor{inputbackground}{rgb}{.95, .95, .85}
27 \definecolor{inputbackground}{rgb}{.95, .95, .85}
28 \definecolor{outputbackground}{rgb}{.95, .95, .95}
28 \definecolor{outputbackground}{rgb}{.95, .95, .95}
29 \definecolor{traceback}{rgb}{1, .95, .95}
29 \definecolor{traceback}{rgb}{1, .95, .95}
30
30
31 % Framed environments for code cells (inputs, outputs, errors, ...). The
31 % Framed environments for code cells (inputs, outputs, errors, ...). The
32 % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't
32 % various uses of \unskip (or not) at the end were fine-tuned by hand, so don't
33 % randomly change them unless you're sure of the effect it will have.
33 % randomly change them unless you're sure of the effect it will have.
34 \usepackage{framed}
34 \usepackage{framed}
35
35
36 % remove extraneous vertical space in boxes
36 % remove extraneous vertical space in boxes
37 \setlength\fboxsep{0pt}
37 \setlength\fboxsep{0pt}
38
38
39 % codecell is the whole input+output set of blocks that a Code cell can
39 % codecell is the whole input+output set of blocks that a Code cell can
40 % generate.
40 % generate.
41 \newenvironment{codecell}{%
41
42 \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}%
42 % TODO: unfortunately, it seems that using a framed codecell environment breaks
43 \MakeFramed{\vspace{-0.5em}\FrameRestore}}
43 % the ability of the frames inside of it to be broken across pages. This
44 {\unskip\endMakeFramed}
44 % causes at least the problem of having lots of empty space at the bottom of
45 % pages as new frames are moved to the next page, and if a single frame is too
46 % long to fit on a page, will completely stop latex from compiling the
47 % document. So unless we figure out a solution to this, we'll have to instead
48 % leave the codecell env. as empty. I'm keeping the original codecell
49 % definition here (a thin vertical bar) for reference, in case we find a
50 % solution to the page break issue.
51
52 %% \newenvironment{codecell}{%
53 %% \def\FrameCommand{\color{mediumgray} \vrule width 1pt \hspace{5pt}}%
54 %% \MakeFramed{\vspace{-0.5em}}}
55 %% {\unskip\endMakeFramed}
56
57 % For now, make this a no-op...
58 \newenvironment{codecell}{}
45
59
46 \newenvironment{codeinput}{%
60 \newenvironment{codeinput}{%
47 \def\FrameCommand{\colorbox{inputbackground}}%
61 \def\FrameCommand{\colorbox{inputbackground}}%
48 \MakeFramed{\advance\hsize-\width \FrameRestore}}
62 \MakeFramed{\advance\hsize-\width \FrameRestore}}
49 {\unskip\endMakeFramed}
63 {\unskip\endMakeFramed}
50
64
51 \newenvironment{codeoutput}{%
65 \newenvironment{codeoutput}{%
52 \def\FrameCommand{\colorbox{outputbackground}}%
66 \def\FrameCommand{\colorbox{outputbackground}}%
53 \vspace{-1.4em}
67 \vspace{-1.4em}
54 \MakeFramed{\advance\hsize-\width \FrameRestore}}
68 \MakeFramed{\advance\hsize-\width \FrameRestore}}
55 {\unskip\medskip\endMakeFramed}
69 {\unskip\medskip\endMakeFramed}
56
70
57 \newenvironment{traceback}{%
71 \newenvironment{traceback}{%
58 \def\FrameCommand{\colorbox{traceback}}%
72 \def\FrameCommand{\colorbox{traceback}}%
59 \MakeFramed{\advance\hsize-\width \FrameRestore}}
73 \MakeFramed{\advance\hsize-\width \FrameRestore}}
60 {\endMakeFramed}
74 {\endMakeFramed}
61
75
62 % Use and configure listings package for nicely formatted code
76 % Use and configure listings package for nicely formatted code
63 \usepackage{listingsutf8}
77 \usepackage{listingsutf8}
64 \lstset{
78 \lstset{
65 language=python,
79 language=python,
66 inputencoding=utf8x,
80 inputencoding=utf8x,
67 extendedchars=\true,
81 extendedchars=\true,
68 aboveskip=\smallskipamount,
82 aboveskip=\smallskipamount,
69 belowskip=\smallskipamount,
83 belowskip=\smallskipamount,
70 %xleftmargin=3mm,
84 %xleftmargin=3mm,
71 breaklines=true,
85 breaklines=true,
72 basicstyle=\small \ttfamily,
86 basicstyle=\small \ttfamily,
73 showstringspaces=false,
87 showstringspaces=false,
74 keywordstyle=\color{blue}\bfseries,
88 keywordstyle=\color{blue}\bfseries,
75 commentstyle=\color{myteal},
89 commentstyle=\color{myteal},
76 stringstyle=\color{darkgreen},
90 stringstyle=\color{darkgreen},
77 identifierstyle=\color{darkorange},
91 identifierstyle=\color{darkorange},
78 }
92 }
79
93
80 % The hyperref package gives us a pdf with properly built
94 % The hyperref package gives us a pdf with properly built
81 % internal navigation ('pdf bookmarks' for the table of contents,
95 % internal navigation ('pdf bookmarks' for the table of contents,
82 % internal cross-reference links, web links for URLs, etc.)
96 % internal cross-reference links, web links for URLs, etc.)
83 \usepackage{hyperref}
97 \usepackage{hyperref}
84 \hypersetup{
98 \hypersetup{
85 breaklinks=true, % so long urls are correctly broken across lines
99 breaklinks=true, % so long urls are correctly broken across lines
86 colorlinks=true,
100 colorlinks=true,
87 urlcolor=blue,
101 urlcolor=blue,
88 linkcolor=darkorange,
102 linkcolor=darkorange,
89 citecolor=darkgreen,
103 citecolor=darkgreen,
90 }
104 }
91
105
92 % hardcode size of all verbatim environments to be a bit smaller
106 % hardcode size of all verbatim environments to be a bit smaller
93 \makeatletter
107 \makeatletter
94 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
108 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
95 \makeatother
109 \makeatother
96
110
97 % Prevent overflowing lines due to urls and other hard-to-break entities.
111 % Prevent overflowing lines due to urls and other hard-to-break entities.
98 \sloppy
112 \sloppy
General Comments 0
You need to be logged in to leave comments. Login now