##// END OF EJS Templates
Small fixes to latex_base
Jonathan Frederic -
Show More
@@ -1,174 +1,184 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{alltt} % Verbatim replacement that allows latex
24
23 \usepackage{grffile} % extends the file name processing of package graphics
25 \usepackage{grffile} % extends the file name processing of package graphics
24 %to support a larger range
26 %to support a larger range
25
27
26 % The hyperref package gives us a pdf with properly built
28 % The hyperref package gives us a pdf with properly built
27 % internal navigation ('pdf bookmarks' for the table of contents,
29 % internal navigation ('pdf bookmarks' for the table of contents,
28 % internal cross-reference links, web links for URLs, etc.)
30 % internal cross-reference links, web links for URLs, etc.)
29 \usepackage{hyperref}
31 \usepackage{hyperref}
30
32
31 % Pygments definitions
33 % Pygments definitions
32 ((( resources.latex.pygment_definitions )))
34 ((( resources.latex.pygment_definitions )))
33 ((* endblock packages *))
35 ((* endblock packages *))
34
36
35 ((* block definitions *))
37 ((* block definitions *))
36 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
38 \definecolor{orange}{cmyk}{0,0.4,0.8,0.2}
37 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
39 \definecolor{darkorange}{rgb}{.71,0.21,0.01}
38 \definecolor{darkgreen}{rgb}{.12,.54,.11}
40 \definecolor{darkgreen}{rgb}{.12,.54,.11}
39 \definecolor{myteal}{rgb}{.26, .44, .56}
41 \definecolor{myteal}{rgb}{.26, .44, .56}
40 \definecolor{gray}{gray}{0.45}
42 \definecolor{gray}{gray}{0.45}
41 \definecolor{lightgray}{gray}{.95}
43 \definecolor{lightgray}{gray}{.95}
42 \definecolor{mediumgray}{gray}{.8}
44 \definecolor{mediumgray}{gray}{.8}
43 \definecolor{inputbackground}{rgb}{.95, .95, .85}
45 \definecolor{inputbackground}{rgb}{.95, .95, .85}
44 \definecolor{outputbackground}{rgb}{.95, .95, .95}
46 \definecolor{outputbackground}{rgb}{.95, .95, .95}
45 \definecolor{traceback}{rgb}{1, .95, .95}
47 \definecolor{traceback}{rgb}{1, .95, .95}
46
48
47 % new ansi colors
49 % new ansi colors
48 \definecolor{brown}{rgb}{0.54,0.27,0.07}
50 \definecolor{brown}{rgb}{0.54,0.27,0.07}
49 \definecolor{purple}{rgb}{0.5,0.0,0.5}
51 \definecolor{purple}{rgb}{0.5,0.0,0.5}
50 \definecolor{darkgray}{gray}{0.25}
52 \definecolor{darkgray}{gray}{0.25}
51 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
53 \definecolor{lightred}{rgb}{1.0,0.39,0.28}
52 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
54 \definecolor{lightgreen}{rgb}{0.48,0.99,0.0}
53 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
55 \definecolor{lightblue}{rgb}{0.53,0.81,0.92}
54 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
56 \definecolor{lightpurple}{rgb}{0.87,0.63,0.87}
55 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
57 \definecolor{lightcyan}{rgb}{0.5,1.0,0.83}
56
58
59 % Define a nice break command that doesn't care if a line doesn't already
60 % exist.
61 \def\br{\hspace*{\fill} \\* }
62
63 % Define a custom verbatim that allows latex
64 \renewenvironment{Verbatim}[1][\unskip]
65 {\begin{alltt}\smaller\noindent}
66 {\end{alltt}}
57 ((* endblock definitions *))
67 ((* endblock definitions *))
58
68
59 ((* block commands *))
69 ((* block commands *))
60 \sloppy % Prevent overflowing lines due to hard-to-break entities
70 \sloppy % Prevent overflowing lines due to hard-to-break entities
61
71
62 % Setup hyperref package
72 % Setup hyperref package
63 \hypersetup{
73 \hypersetup{
64 breaklinks=true, % so long urls are correctly broken across lines
74 breaklinks=true, % so long urls are correctly broken across lines
65 colorlinks=true,
75 colorlinks=true,
66 urlcolor=blue,
76 urlcolor=blue,
67 linkcolor=darkorange,
77 linkcolor=darkorange,
68 citecolor=darkgreen,
78 citecolor=darkgreen,
69 }
79 }
70
80
71 % Slightly bigger margins than the latex defaults
81 % Slightly bigger margins than the latex defaults
72 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
82 \geometry{verbose,tmargin=3cm,bmargin=3cm,lmargin=2.5cm,rmargin=2.5cm}
73
83
74 % Hardcode size of all verbatim environments to be a bit smaller
84 % Hardcode size of all verbatim environments to be a bit smaller
75 \makeatletter
85 \makeatletter
76 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
86 \g@addto@macro\@verbatim\small\topsep=0.5em\partopsep=0pt
77 \makeatother
87 \makeatother
78 ((* endblock commands *))
88 ((* endblock commands *))
79
89
80 %===============================================================================
90 %===============================================================================
81 % Support blocks
91 % Support blocks
82 %===============================================================================
92 %===============================================================================
83
93
84 % Displaying simple data text
94 % Displaying simple data text
85 ((* block data_text *))
95 ((* block data_text *))
86 \begin{verbatim}
96 \begin{Verbatim}
87 ((( output.text | escape_latex )))
97 ((( output.text | escape_latex )))
88 \end{verbatim}
98 \end{Verbatim}
89 ((* endblock data_text *))
99 ((* endblock data_text *))
90
100
91 % Display python error text as-is
101 % Display python error text as-is
92 ((* block pyerr *))
102 ((* block pyerr *))
93 \begin{verbatim}
103 \begin{Verbatim}
94 ((( super() )))
104 ((( super() )))
95 \end{verbatim}
105 \end{Verbatim}
96 ((* endblock pyerr *))
106 ((* endblock pyerr *))
97 ((* block traceback_line *))
107 ((* block traceback_line *))
98 ((( line | indent | strip_ansi | escape_latex )))
108 ((( line | indent | strip_ansi | escape_latex )))
99 ((* endblock traceback_line *))
109 ((* endblock traceback_line *))
100
110
101 % Display stream ouput with coloring
111 % Display stream ouput with coloring
102 ((* block stream *))
112 ((* block stream *))
103 \begin{Verbatim}[commandchars=\\\{\}]
113 \begin{Verbatim}[commandchars=\\\{\}]
104 ((( output.text | ansi2latex )))
114 ((( output.text | ansi2latex )))
105 \end{Verbatim}
115 \end{Verbatim}
106 ((* endblock stream *))
116 ((* endblock stream *))
107
117
108 % Display latex
118 % Display latex
109 ((* block data_latex -*))
119 ((* block data_latex -*))
110 ((*- if output.latex.startswith('$'): -*))
120 ((*- if output.latex.startswith('$'): -*))
111 ((= Replace $ symbols with more explicit, equation block. =))
121 ((= Replace $ symbols with more explicit, equation block. =))
112 \begin{equation*}
122 \begin{equation*}
113 ((( output.latex | strip_dollars )))
123 ((( output.latex | strip_dollars )))
114 \end{equation*}
124 \end{equation*}
115 ((*- else -*))
125 ((*- else -*))
116 ((( output.latex )))
126 ((( output.latex )))
117 ((*- endif *))
127 ((*- endif *))
118 ((* endblock data_latex *))
128 ((* endblock data_latex *))
119
129
120 % Default mechanism for rendering figures
130 % Default mechanism for rendering figures
121 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
131 ((*- block data_png -*))((( draw_figure(output.png_filename) )))((*- endblock -*))
122 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
132 ((*- block data_jpg -*))((( draw_figure(output.jpeg_filename) )))((*- endblock -*))
123 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
133 ((*- block data_svg -*))((( draw_figure(output.svg_filename) )))((*- endblock -*))
124 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
134 ((*- block data_pdf -*))((( draw_figure(output.pdf_filename) )))((*- endblock -*))
125
135
126 % Draw a figure using the graphicx package.
136 % Draw a figure using the graphicx package.
127 ((* macro draw_figure(filename) -*))
137 ((* macro draw_figure(filename) -*))
128 ((* set filename = filename | posix_path *))
138 ((* set filename = filename | posix_path *))
129 ((*- block figure scoped -*))
139 ((*- block figure scoped -*))
130 \begin{center}
140 \begin{center}
131 \adjustimage{max size={0.9\linewidth}{..}}{((( filename )))}
141 \adjustimage{max size={0.9\linewidth}{0.9\paperheight}}{((( filename )))}
132 \par
133 \end{center}
142 \end{center}
143 { \hspace*{\fill} \\}
134 ((*- endblock figure -*))
144 ((*- endblock figure -*))
135 ((*- endmacro *))
145 ((*- endmacro *))
136
146
137 % Draw heading cell. Explicitly map different cell levels.
147 % Draw heading cell. Explicitly map different cell levels.
138 ((* block headingcell scoped -*))
148 ((* block headingcell scoped -*))
139 ((*- if cell.level == 1 -*))
149 ((*- if cell.level == 1 -*))
140 ((* block h1 -*))\section((* endblock h1 -*))
150 ((* block h1 -*))\section((* endblock h1 -*))
141 ((*- elif cell.level == 2 -*))
151 ((*- elif cell.level == 2 -*))
142 ((* block h2 -*))\subsection((* endblock h2 -*))
152 ((* block h2 -*))\subsection((* endblock h2 -*))
143 ((*- elif cell.level == 3 -*))
153 ((*- elif cell.level == 3 -*))
144 ((* block h3 -*))\subsubsection((* endblock h3 -*))
154 ((* block h3 -*))\subsubsection((* endblock h3 -*))
145 ((*- elif cell.level == 4 -*))
155 ((*- elif cell.level == 4 -*))
146 ((* block h4 -*))\paragraph((* endblock h4 -*))
156 ((* block h4 -*))\paragraph((* endblock h4 -*))
147 ((*- elif cell.level == 5 -*))
157 ((*- elif cell.level == 5 -*))
148 ((* block h5 -*))\subparagraph((* endblock h5 -*))
158 ((* block h5 -*))\subparagraph((* endblock h5 -*))
149 ((*- elif cell.level == 6 -*))
159 ((*- elif cell.level == 6 -*))
150 ((* block h6 -*))\\*\textit((* endblock h6 -*))
160 ((* block h6 -*))\\*\textit((* endblock h6 -*))
151 ((*- endif -*))
161 ((*- endif -*))
152 {((( cell.source | escape_latex )))}
162 {((( cell.source | escape_latex )))}
153 ((*- endblock headingcell *))
163 ((*- endblock headingcell *))
154
164
155 % Redirect pyout to display data priority.
165 % Redirect pyout to display data priority.
156 ((* block pyout scoped *))
166 ((* block pyout scoped *))
157 ((* block data_priority scoped *))
167 ((* block data_priority scoped *))
158 ((( super() )))
168 ((( super() )))
159 ((* endblock *))
169 ((* endblock *))
160 ((* endblock pyout *))
170 ((* endblock pyout *))
161
171
162 % Render markdown
172 % Render markdown
163 ((* block markdowncell scoped *))
173 ((* block markdowncell scoped *))
164 ((( cell.source | markdown2latex )))
174 ((( cell.source | markdown2latex )))
165 ((* endblock markdowncell *))
175 ((* endblock markdowncell *))
166
176
167 % Spit out the contents of raw cells unmodified
177 % Spit out the contents of raw cells unmodified
168 ((* block rawcell scoped *))
178 ((* block rawcell scoped *))
169 ((( cell.source )))
179 ((( cell.source )))
170 ((* endblock rawcell *))
180 ((* endblock rawcell *))
171
181
172 % Don't display unknown types
182 % Don't display unknown types
173 ((* block unknowncell scoped *))
183 ((* block unknowncell scoped *))
174 ((* endblock unknowncell *))
184 ((* endblock unknowncell *))
General Comments 0
You need to be logged in to leave comments. Login now