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