-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathapuntes-MNII-book.sty
397 lines (351 loc) · 10.9 KB
/
apuntes-MNII-book.sty
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
\usepackage{common}
\usepackage{palatino}
\usepackage[sc]{mathpazo}
\linespread{1.05} % Palatino needs more leading (space between lines)
\usepackage[T1]{fontenc}
% ------- Formato del documento ----
\setlength{\headheight}{0cm}
\setlength{\headsep}{1.4cm}
\setlength{\footskip}{0.9cm}
\RequirePackage{marginnote}
\usepackage[
%% Configuración en a4 on márgenes anchos
hmargin={2.9cm,3.9cm}, vmargin={3.9cm,3.4cm},
marginparwidth=3.5cm
% %% Configuración de 'geometry' para servicio de publicaciones
% \RequirePackage[
% paperwidth=16.5cm,
% paperheight=23.5cm,
% inner=1.65cm,
% outer=2.25cm,
% top=1.8cm,
% bottom=1cm, % P. Cervera decía 1.8, pero le resto \footskip
% includehead,
% includefoot
]{geometry}
% Environmet "extension" as margin notes
\RequirePackage{environ} % To send environment to a \macro
\NewEnviron{extension}{\marginnote{%
\tiny%
\setlength{\belowdisplayskip}{0.33em}\setlength{\belowdisplayshortskip}{0pt}%
\setlength{\abovedisplayskip}{0.33em}\setlength{\abovedisplayshortskip}{0pt}%
\textit{\BODY}}}
\RequirePackage{fancyhdr}
\setlength{\headheight}{15pt} %Required by fancyhdr
\renewcommand{\headrulewidth}{0.05pt} % Top horizontal line
\renewcommand{\footrulewidth}{0pt} % Bottom horizontal line
\newcommand{\fancyHDRextendedwidth}{1.5cm}
\fancyheadoffset[RO,LE]{\fancyHDRextendedwidth} % Make header wider than body text
\pagestyle{fancy}
\renewcommand{\chaptermark}[1]{%
\markboth{\textit{\thetitle}.\quad \chaptername\ \thechapter.\ #1}{}}
% \markright{\chaptername\ \thechapter.\ #1}{}}
\renewcommand{\sectionmark}[1]{%
\markright{\thesection.\ #1}{}}
\fancyhf{}
\fancyhead[LE,RO]{\sffamily\thepage}
\fancyhead[LO]{\sffamily\rightmark}
\fancyhead[RE]{\sffamily\leftmark}
% Tables, etc
\RequirePackage{booktabs} % Pretty tables
\RequirePackage{ctable} % \toprule, \bottomrule, etc.
\RequirePackage{colortbl} % Color in tables
\RequirePackage{multirow} % Multirow/multicolumn in tables
\RequirePackage{graphicx}
\RequirePackage{fancybox}
\RequirePackage{enumitem}
\RequirePackage{marginnote}
\RequirePackage{subfig} % subfloat in figures
% % ------------------------------------------------------------
% \RequirePackage{xcolor}
% \RequirePackage{framed}
\RequirePackage{mdframed}
\mdfdefinestyle{theoremstyle}{%
linecolor=blue!40!black,
backgroundcolor = blue!30!green!3!white,
roundcorner = 10}
\mdfdefinestyle{propositionstyle}{%
linecolor=gray,
backgroundcolor = blue!2!white}
\RequirePackage{amsthm}
\theoremstyle{plain} % italic, extra space above and below
\newmdtheoremenv[style=theoremstyle]{theorem}{Teorema}[chapter]
\newmdtheoremenv[style=propositionstyle]{proposition}[theorem]{Proposición}
\newmdtheoremenv[style=propositionstyle]{lemma}[theorem]{Lema}
\newmdtheoremenv[style=propositionstyle]{corollary}[theorem]{Corolario}
% \newtheorem{proposition}[theorem]{Proposición}
% \newtheorem{lemma}[theorem]{Lema}
% \newtheorem{corollary}[theorem]{Corolario}
% \theoremstyle{definition} % roman, extra space above and below
\newtheoremstyle{mytheorem}% <name>
{3pt}% <Space above>
{3pt}% <Space below>
{}% <Body font>
{}% <Indent amount>
{\itshape\bfseries}% <Theorem head font>
{.}% <Punctuation after theorem head>
{.5em}% <Space after theorem heading>
{}
\newtheorem{definition}[theorem]{Definición}
\newtheorem{test}[theorem]{Test}
% \theoremstyle{remark} % roman, no extra space above and below
\newtheorem{RemarkWithQed}[theorem]{Observación}
\newenvironment{remark}
{\RemarkWithQed}
{\qed\endRemarkWithQed}
% And also examples
\newtheorem{ExampleWithQed}[theorem]{Ejemplo} % Default: append \qed
\newenvironment{example}
{\ExampleWithQed}
{\qed\endExampleWithQed}
\newcommand{\resaltar}[1]{\textbf{#1}}
% \hypersetup{colorlinks,linkcolor=,urlcolor=links}
\usepackage[
%pdftex,
plainpages=false % To avoid bug with \frontmatter et al
]
{hyperref}
\definecolor{gray75}{gray}{0.75}
\definecolor{darkblue}{rgb}{0.05,0.1,0.32}
% \definecolor{darkgreen}{rgb}{0.0,0.32,0.15}
\definecolor{darkgreen}{rgb}{0.0,0.27,0.1}
\definecolor{darkred}{rgb}{0.3,0.1,0.0}
\def\refColor{darkgreen}
% \def\refColor{black}
\hypersetup{%
colorlinks,
linkcolor=\refColor,
urlcolor=\refColor,
anchorcolor=\refColor,
citecolor=\refColor
}
% ----------------------------------------------------------------------
\newcounter{problem}
\newenvironment{EjerciciosResueltos}
{\subsection{Ejercicios Resueltos}%
\newcommand{\problema}{%
\stepcounter{problem}%
\paragraph{Ejercicio \theproblem.}}%
\newcommand{\solucion}{\paragraph{Solución.}\em}%
}
{}
\newenvironment{EjerciciosPropuestos}
{\subsection{Ejercicios Propuestos}\newcommand{\problema}{\item}\begin{enumerate}}
{\end{enumerate}}
% Captions: changing the font size
\usepackage[font=small,labelfont=bf]{caption}
% ----------------------------------------------------------------------
\RequirePackage{lmodern} % Font with bold tt
\RequirePackage{listings}
\lstset{ %To handle UTF-8 en español
inputencoding=utf8,
extendedchars=true,
literate=%
{á}{{\'{a}}}1
{é}{{\'{e}}}1
{í}{{\'{i}}}1
{ó}{{\'{o}}}1
{ú}{{\'{u}}}1
{ü}{{\"{u}}}1
{ñ}{{\~{n}}}1
{Á}{{\'{A}}}1
{É}{{\'{E}}}1
{Í}{{\'{I}}}1
{Ó}{{\'{O}}}1
{Ú}{{\'{U}}}1
{Ü}{{\"{U}}}1
{Ñ}{{\~{N}}}1
}
% \lstset{
% % frame=Ltb,
% % framerule=0pt,
% aboveskip=0.5cm,
% framextopmargin=3pt,
% framexbottommargin=3pt,
% framexleftmargin=0.5em,
% framesep=0pt,
% rulesep=.4pt,
% }
% backgroundcolor=\color{red!10!gray!40!yellow!10!white},
% rulesepcolor=\color{black},
% %
% % stringstyle=\ttfamily,
% showstringspaces = false,
% basicstyle=\ttfamily\small,
% % commentstyle=\color{gray40},
% % keywordstyle=\bfseries,%\color{gray!150},
% % identifierstyle=\itshape\bfseries%\color{gray25},
% %
% % numbers=left,
% % numbersep=15pt,
% % numberstyle=\tiny,
% % numberfirstline = false,
% % breaklines=true,
% }
\lstdefinelanguage{Maxima}{
keywords={addrow,addcol,zeromatrix,ident,augcoefmatrix,ratsubst,diff,ev,tex,%
with_stdout,nouns,express,depends,load,submatrix,div,grad,curl,%
rootscontract,solve,part,assume,sqrt,integrate,abs,inf,exp},
sensitive=true
comment=[n][\itshape]{/*}{*/}
}
\lstdefinelanguage{pseudocodigo}{
keywords={Para, para, fin_para, sumatorio, funcion, fin_funcion, devolver},
sensitive=false,
comment=[n][\itshape]{\%}{},
basicstyle=\ttfamily
}
\lstnewenvironment{algoritmo}[1][]
{\lstset{language=pseudocodigo,#1}}
{}
\lstnewenvironment{octave}[1][]
{\lstset{language=Octave,#1}}
{}
\lstnewenvironment{mathematica}[1][]
{\lstset{language=Mathematica,#1}}
{}
% \lstnewenvironment{c}[1][]
% {\lstset{language=c,#1}}
% {}
\lstnewenvironment{C++}[1][]
{\lstset{language=c++,#1}}
{}
% % Python style for highlighting...
% % Default fixed font does not support bold face
% \DeclareFixedFont{\ttb}{T1}{txtt}{bx}{n}{12} % for bold
% \DeclareFixedFont{\ttm}{T1}{txtt}{m}{n}{12} % for normal
% % Custom colors
% \usepackage{color}
% \definecolor{deepblue}{rgb}{0,0,0.5}
% \definecolor{deepred}{rgb}{0.6,0,0}
% \definecolor{deepgreen}{rgb}{0,0.5,0}
% \newcommand\pythonstyle{\lstset{
% language=Python,
% % basicstyle=\ttm,
% otherkeywords={self}, % Add keywords here
% % keywordstyle=\ttb\color{deepblue},
% keywordstyle=\bfseries\color{deepblue},
% emph={MyClass,__init__}, % Custom highlighting
% % emphstyle=\ttb\color{deepred}, % Custom highlighting style
% emphstyle=\color{deepred}, % Custom highlighting style
% commentstyle=\color{deepred},
% stringstyle=\color{deepgreen},
% % identifierstyle=\color{deepred},
% frame=tb, % Any extra options here
% showstringspaces=false %
% }}
% % \lstnewenvironment{python}[1][]
% % {\pythonstyle\lstset{language=Python,#1}}
% % {}
% % Python environment
% \lstnewenvironment{python}[1][]
% {
% \pythonstyle
% \lstset{#1}
% }
% {}
\lstset{
basicstyle=\ttfamily
}
\usepackage{setspace}
\definecolor{Code}{rgb}{0,0,0}
\definecolor{Decorators}{rgb}{0.5,0.5,0.5}
\definecolor{Numbers}{rgb}{0.5,0,0}
\definecolor{MatchingBrackets}{rgb}{0.25,0.5,0.5}
\definecolor{Keywords}{rgb}{0,0.45,0.05}
\definecolor{self}{rgb}{0,0,0}
\definecolor{Strings}{rgb}{0.8,0.05,0.1}
\definecolor{Comments}{rgb}{0,0.2,0.45}
\definecolor{Backquotes}{rgb}{0,0,0}
\definecolor{Classname}{rgb}{0,0,0}
\definecolor{FunctionName}{rgb}{1,0,0}
\definecolor{Operators}{rgb}{0,0,0}
% \definecolor{Background}{rgb}{0.99,0.987,0.966}
\definecolor{Background}{rgb}{0.99,0.99,0.93}
\definecolor{Numbers}{gray}{0.7}
\newcommand{\pythonstyle}{\lstset{
% numbers=left,
numberstyle=\color{Numbers}\footnotesize\sffamily,
numbersep=1em,
xleftmargin=1em,
framextopmargin=2em,
framexbottommargin=2em,
showspaces=false,
showtabs=false,
showstringspaces=false,
frame=l,
tabsize=4,
% Basic
basicstyle=\ttfamily\small\setstretch{1},
backgroundcolor=\color{Background},
language=Python,
% Comments
commentstyle=\color{Comments}\slshape,
% Strings
stringstyle=\color{Strings},
morecomment=[s][\color{Strings}]{"""}{"""},
morecomment=[s][\color{Strings}]{'''}{'''},
% keywords
morekeywords={import,from,class,def,for,while,if,is,in,elif,else,not,and,or,print,break,continue,return,True,False,None,access,as,,del,except,exec,finally,global,import,lambda,pass,print,raise,try,assert},
keywordstyle={\color{Keywords}\bfseries},
% additional keywords
morekeywords={[2]@invariant},
keywordstyle={[2]\color{Decorators}\slshape},
emph={self},
emphstyle={\color{self}\slshape},
%
}}
% Python environment
\lstnewenvironment{python}[1][]
{
\pythonstyle
\lstset{#1}
}
{}
% Python for inline
\newcommand\pythoninline[1]{{\pythonstyle\lstinline!#1!}}
%% ,--------------------------------
%% | Python for input external files
%% `--------------------------------
% Test if material (even floas) is odd page. Needs two compiler runs
\RequirePackage{ifoddpage}
% 1. To extend text width (including marings)
\newcommand{\widelstinputlisting}[2][]{%
\checkoddpage
\ifoddpage
\lstset{xleftmargin=0pt,xrightmargin=-\fancyHDRextendedwidth}
\lstinputlisting[#1]{#2}
\else
\lstset{xleftmargin=-\fancyHDRextendedwidth,xrightmargin=0pt}
\lstinputlisting[#1]{#2}
\fi}
% 2. Define command for including external files
\newcommand\widepythonexternal[2][]{{
\pythonstyle
\widelstinputlisting[#1]{#2}}}
% 2. Define command for including external files
\newcommand\pythonexternal[2][]{{
\pythonstyle
\lstinputlisting[#1]{#2}}}
% program (new figure-like environment)...
\RequirePackage{float}
\newfloat{Programa}{p}{lop}[chapter]
\newenvironment{program}{%
\begin{Programa}\lstset{numbers=left}}{%
\end{Programa}}
% Python input
\newenvironment{pythoninput}{%
\begin{python}
}{\end{python}}
\newenvironment{pythonoutput}{%
\definecolor{Background}{rgb}{0.99,0.987,1}
}{}
% Algoritmo
\newfloat{Algoritmo}{h}{loa}[chapter]
\newenvironment{algorithm}{%
\begin{Algoritmo}}{%
\end{Algoritmo}}
%%% Local Variables:
%%% mode: latex
%%% TeX-master: "./apuntes-MNII.tex"
%%% End: