blob: 6682409ee982c33d38423bc157241567f5c7c60f [file] [log] [blame]
oscarbenedito6bc418b2019-09-20 13:28:57 +02001% \iffalse meta-comment
2%
3%% apuntsfme.dtx
4%% Copyright 2019 ApuntsFME
5%
6% This work may be distributed and/or modified under the
7% conditions of the LaTeX Project Public License, either version 1.3
8% of this license or (at your option) any later version.
9% The latest version of this license is in
10% http://www.latex-project.org/lppl.txt
11% and version 1.3 or later is part of all distributions of LaTeX
12% version 2005/12/01 or later.
13%
14% This work has the LPPL maintenance status `maintained'.
15%
16% The Current Maintainer of this work is the ApuntsFME organization.
17%
18% This work consists of the files apuntsfme.dtx and apuntsfme.ins
19% and the derived file apuntsfme.sty.
20%
21% \fi
22%
23% \iffalse
24%<*driver>
25\ProvidesFile{apuntsfme.dtx}
26%</driver>
27%
28%<package>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
29%<package>\ProvidesPackage{apuntsfme}[2019/07/08 v1.o .dtx apuntsfme file]
30%
31%<class>\NeedsTeXFormat{LaTeX2e}[2005/12/01]
32%<class>\ProvidesClass{notes}[2019/10/12 v1.0 class for taking notes in class]
33%
34%<*driver>
35\documentclass{ltxdoc}
36\usepackage{apuntsfme}
37\usepackage{hyperref}
38\usepackage{csquotes}
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +020039\usepackage{booktabs}
40\usepackage{longtable}
oscarbenedito6bc418b2019-09-20 13:28:57 +020041\EnableCrossrefs
42\CodelineIndex
43\RecordChanges
44\begin{document}
45 \DocInput{apuntsfme.dtx}
46\end{document}
47%</driver>
48% \fi
49%
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +020050% \CheckSum{0}
oscarbenedito6bc418b2019-09-20 13:28:57 +020051%
52% \CharacterTable
53% {Upper-case \A\B\C\D\E\F\G\H\I\J\K\L\M\N\O\P\Q\R\S\T\U\V\W\X\Y\Z
54% Lower-case \a\b\c\d\e\f\g\h\i\j\k\l\m\n\o\p\q\r\s\t\u\v\w\x\y\z
55% Digits \0\1\2\3\4\5\6\7\8\9
56% Exclamation \! Double quote \" Hash (number) \#
57% Dollar \$ Percent \% Ampersand \&
58% Acute accent \' Left paren \( Right paren \)
59% Asterisk \* Plus \+ Comma \,
60% Minus \- Point \. Solidus \/
61% Colon \: Semicolon \; Less than \<
62% Equals \= Greater than \> Question mark \?
63% Commercial at \@ Left bracket \[ Backslash \\
64% Right bracket \] Circumflex \^ Underscore \_
65% Grave accent \` Left brace \{ Vertical bar \|
66% Right brace \} Tilde \~}
67%
68% \changes{v1.0}{2019/07/14}{Initial version}
69%
70% \GetFileInfo{apuntsfme.sty}
oscarbenedito6bc418b2019-09-20 13:28:57 +020071%
72%
73% \title{The \textsf{ApuntsFME} package\thanks{This document
74% corresponds to \textsf{apuntsfme}~\fileversion,
75% dated~\filedate.}}
oscarbenedito491ae192020-03-22 12:33:36 +010076% \author{Ernesto Lanchares\\ \href{mailto:e.lancha98@gmail.com}{e.lancha98@gmail.com} \and Oscar Benedito \\ \href{mailto:oscar@oscarbenedito.com}{oscar@oscarbenedito.com}}
oscarbenedito6bc418b2019-09-20 13:28:57 +020077%
78% \maketitle
79%
80% \begin{abstract}
81% A package that aims to make taking notes in math class in \LaTeX\ easy.
82% \end{abstract}
83%
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +020084% The goal of this package is make taking notes on class easy. It includes a lot of packages and shortcuts
85% that aim to make it easy to remember and easy to type. Note that this package is not meant to set a
86% reference in how \LaTeX\ should be writter nor it's meant to be a guideline of any kind.
87%
88% \section{The ApuntsFME package}
89% The ApuntsFME package has the purpose of providing the shortcuts and
90% environments used for short typing.
91%
92% \subsection{Packages imported}
93% As mentioned, this package collects a lot of other packages all very common to math typing. Here's a
94% table with all of them and the use that they provide.
95%
96% \begin{longtable}{p{.2\textwidth}p{.6\textwidth}}
97% Package & Usage \\ \toprule \toprule
98% \endhead
99% \bottomrule \multicolumn{2}{c}{{Continued on next page}} \\
100% \endfoot
101% \bottomrule
102% \endlastfoot
103% inputenc & loaded with the \texttt{utf-8} option, used so the characters
104% are interpreted as unicode text \\ \midrule
105% fontenc & loaded with the \texttt{T1} option. It's used so, in the output
106% PDF, you can search for accented words \\ \midrule
107% lmodern & To have the fonts have high quality \\ \midrule
108% hyperref & To have clickable links and urls \\ \midrule
109% enumitem & loaded with \texttt{shortlabels}. Used to control enumerates \\
110% \midrule
111% amsmath & The American Mathematical Society \LaTeX\ package. Loads common
112% math utilities \\ \midrule
113% amsthm & The American Mathematical Society package used to typeset
114% theorems, propositions, \dots \\ \midrule
115% amssymb & The American Mathematical Society pacakgae that defines a lot of
116% ``common'' symbols \\ \midrule
117% graphicx & A lot of support for graphics inside the document \\ \midrule
118% mathtools & A set of mathematical tools. \\ \midrule
119% tikz & A package to create graphics inside \LaTeX. \\ \midrule
120% makeidx & This is what creates the glossary with the definitions. \\
121% \midrule
122% cancel & This package allows to cancel things in equations by marking them
123% with a line (just as you would do in a paper) \\ \midrule
124% pgf & Is the backend of \texttt{pgfplots} \\ \midrule
125% pgfplots & This is used with \texttt{tikz} to make axis plots \\ \midrule
126% mathrsfs & Support for using RSFS fonts in maths \\ \midrule
127% thmtools & This is used to furder customize the \texttt{amsthm}
128% environments \\ \midrule
129% tikz-cd & An extension of \texttt{tikz} to create commutative diagrams \\
130% \midrule
131% faktor & Used to typeset quotient structures \\ \midrule
132% physics & More macros for maths \\ \midrule
133% float & Let's you controll the figures position \\ \midrule
134% \end{longtable}
135%
136% It's interesting to note that we load TiKz and PGF because we bet for making
137% the figures inside \LaTeX\ and not with another external tool. However, this
138% has a drawback and is that it reduces compilation times by quite a lot. To
139% mitigate that effect we also use \texttt{external} with TiKz. This library,
140% makes the first computation very very slow and creates a directory with all
141% the figures generated from the code. Then, the rest of the compilations just
142% need to import that precomputed figure so they are a lot faster. This
143% behaviour can be turned off by the \texttt{noexternal} option.
144%
145% You also can controll the output folder of these figures with the option
146% \texttt{externalfolder}. Here's an example in how to put the figures in the
147% folder myfigures. But remember that this option will be ignored if you use
148% \texttt{noexternal}.
149%
150% \begin{verbatim}
151% \usepackage[externalfolder=myfigures]{apuntsfme}
152% \end{verbatim}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200153%
154% \StopEventually{}
155%
156% \section{Package implementation}
157% \iffalse
158%<*package>
159% \fi
160% \subsection{Includes}
161%
162% In the first place, we need to import some other packages (in fact, a lot of them). We
163% considered that there's no need in reinventing the wheel so our work is based on this packages
164%
165% \begin{macrocode}
166\RequirePackage[utf8]{inputenc}
167\RequirePackage[T1]{fontenc}
oscarbeneditoef77d902019-09-30 19:44:52 +0200168\RequirePackage{lmodern}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200169\RequirePackage[shortlabels]{enumitem}
170\RequirePackage{amsmath,amsthm,amssymb,graphicx,mathtools,tikz,makeidx}
171\RequirePackage{cancel,pgf,pgfplots,mathrsfs,thmtools,tikz-cd,faktor}
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +0200172\RequirePackage{physics,float}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200173% \end{macrocode}
174%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200175% Then we have lots of packages that we want to remove but have some documents that use them
176% so we don't remove them because laziness.
177% \begin{macrocode}
178\RequirePackage{xfrac} % Fa els sfrac, per cert un a multi esta malamanet??
179\RequirePackage{siunitx} %Crec que cal canviar codi
180\RequirePackage{centernot} % Aixo es exclusiu d'estructures per fer un \not concret als mid?
181\RequirePackage{multicol} % Exclusiu dels formularis?
182\RequirePackage{xcolor} % Aixo potser es d'un document concret
183\RequirePackage{needspace} %No se si es gaire util, compila sense incloure'l
184\RequirePackage{commath} % Aquest implement els \dif, cal canviar tot el codi per ferho amb physics
oscarbenedito6bc418b2019-09-20 13:28:57 +0200185\RequirePackage{dsfont} % No se que fa, compila si el trec
MiquelOrtega9872c512020-04-22 00:40:41 +0200186\RequirePackage{mdframed,stackengine,stmaryrd,multirow}
187\RequirePackage{hyperref, cleveref}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200188% \end{macrocode}
189%
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +0200190%
191% And some style definitions, just because we can.
192% \begin{macrocode}
193\let\emptyset\varnothing
194\setcounter{secnumdepth}{4}
195\def\mydate{\today}
196\hypersetup{
197 colorlinks,
198 linkcolor=blue
199}
200% \end{macrocode}
201%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200202% \subsection{Useful commands}
203% In this section we provide some useful commands.
204%
205% We start with some commands that need to be removed but again, laziness
206% \begin{macrocode}
207%\newcommand{\ap}[1]{\ensuremath\overline{#1}}
208%\newcommand{\Sup}[1]{\ensuremath\underset{#1}{\sup}}
209%\newcommand{\Max}[1]{\ensuremath\underset{#1}{\max}}
210%\newcommand{\Min}[1]{\ensuremath\underset{#1}{\min}}
211%\newcommand{\scin}[1]{\ensuremath\SI{#1}{}}
212\newcommand\comp[1]{\overline{#1}} % Treure? #SouUnsVagos
213\newcommand\inv[1]{#1^{-1}} % Habra que sacarlo de algun documento?
214\newcommand{\ita}[1]{\textit{#1}} % Habra que sacarlo de algun documento?
215\newmdenv[leftline=false,topline=false]{topright}
216% \end{macrocode}
217%
218% Now we can proceed into the part that we are proud of. First some commands
219% \begin{macrocode}
220%\newcommand\mapsfrom{\mathrel{\reflectbox{\ensuremath{\mapsto}}}} %Already defined?
221\newcommand*{\bimplies}{\boxed{\implies}}
222\newcommand*{\bimpliedby}{\boxed{\impliedby}}
223% \end{macrocode}
224%
225% \subsubsection{Mathbb commands}
226% Again, with some parts that needs removing/refactoring
227% \begin{macrocode}
228\newcommand{\n}{\mathbb{N}}
229\newcommand{\z}{\mathbb{Z}}
230\newcommand{\q}{\mathbb{Q}}
231\newcommand{\cx}{\mathbb{C}}
232\renewcommand{\real}{\mathbb{R}}
233\newcommand{\E}{\mathbb{E}}
234\newcommand{\F}{\mathbb{F}}
235\newcommand{\A}{\mathbb{A}}
236\newcommand{\bb}[1]{\mathbb{#1}}
237\newcommand{\Po}{\mathbb{P}}
238\newcommand{\esp}{\mathbb{E}}
239\DeclareMathOperator{\cov}{\mathbb{C}ov} % TODO esto que?
240\let\var\relax
241\DeclareMathOperator{\var}{\mathbb{V}ar} % TODO esto que?
242% \end{macrocode}
243%
244% \subsubsection{Mathcal commands}
245%
246% \begin{macrocode}
247\newcommand{\R}{\mathcal{R}}
248\newcommand{\Pa}{\mathcal{P}}
249\newcommand{\Es}{\mathcal{E}}
250\newcommand{\V}{\mathcal{V}}
251\newcommand{\T}{\mathcal{T}}
252\newcommand{\B}{\mathcal{B}}
253\let\O\relax
254\newcommand{\O}{\mathcal{O}}
255\newcommand{\Sim}{\mathcal{S}}
256\newcommand{\Asim}{\mathcal{A}} % TODO aquest i el dabaix son el mateix
257\newcommand{\Asuc}{\mathcal{A}} % Conjunt de successos
258\newcommand{\matspace}{\mathcal{M}} %Espai de matrius
259% \end{macrocode}
260%
261% \subsubsection{Mathscr and others}
262% \begin{macrocode}
263\newcommand{\C}{\mathscr{C}}
264\let\k\relax
265\newcommand{\k}{\Bbbk}
266% \end{macrocode}
267%
268% \subsubsection{Math utilities}
269% \begin{macrocode}
270\newcommand{\trir}{\triangleright}
271\newcommand{\tril}{\triangleleft}
272\newcommand{\limvar}[2]{\lim\limits_{#1 \rightarrow #2}} % Para escribir limites más rapido
273\newcommand{\notimplies}{\mathrel{{\ooalign{\hidewidth$\not\phantom{=}$%
274 \hidewidth\cr$\implies$}}}}
275\newcommand{\defeq}{\stackrel{\text{\tiny def}}{=}} % Símbol 'definit com'
276\def\upint{\mathchoice%
277 {\mkern13mu\overline{\vphantom{\intop}\mkern7mu}\mkern-20mu}%
278 {\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
279 {\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
280 {\mkern7mu\overline{\vphantom{\intop}\mkern7mu}\mkern-14mu}%
281 \int}
282\def\lowint{\mkern3mu\underline{\vphantom{\intop}\mkern7mu}\mkern-10mu\int}
283% \end{macrocode}
284%
285% \subsubsection{Left-right thing}
286% For good practice this ones should be removed but hey using an IDE with macro insertion
287% is aparently very difficult...
288% \begin{macrocode}
289\newcommand\setb[1]{\left\{#1\right\}} % Deberia irse?
290\newcommand{\vbrack}[1]{\langle #1\rangle}
291\newcommand{\spr}[1]{\langle #1 \rangle} % TODO aquest i lanterior son el mateix
292\newcommand{\lp}{\left(}
293\newcommand{\rp}{\right)}
294\newcommand{\lc}{\left\{}
295\newcommand{\rc}{\right\}}
296\newcommand{\lb}{\left[}
297\newcommand{\rb}{\right]}
298% \end{macrocode}
299%
300% \subsubsection{Math operators}
301% \begin{macrocode}
302\DeclareMathOperator{\Ec}{Ec}
303\DeclareMathOperator{\Ep}{Ep}
304\DeclareMathOperator{\orden}{o}
305\DeclareMathOperator{\ord}{ord}
306\DeclareMathOperator{\card}{card}
307\DeclareMathOperator{\mcm}{mcm}
308\DeclareMathOperator{\mcd}{mcd}
oscarbeneditoef77d902019-09-30 19:44:52 +0200309\DeclareMathOperator{\lcm}{lcm}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200310\DeclareMathOperator{\Em}{Em}
311\DeclareMathOperator*{\argmax}{arg\,max}
312\DeclareMathOperator*{\argmin}{arg\,min}
313\DeclareMathOperator{\fr}{Fr}
314\DeclareMathOperator{\Id}{Id}
315\DeclareMathOperator{\ext}{Ext}
316\DeclareMathOperator{\inte}{Int}
317\DeclareMathOperator{\rie}{Rie}
318\DeclareMathOperator{\rg}{rg}
319\DeclareMathOperator{\gr}{gr}
320\DeclareMathOperator{\nuc}{Nuc}
321\DeclareMathOperator{\car}{car}
322\DeclareMathOperator{\im}{Im}
oscarbeneditoaa0fe752019-10-01 13:13:01 +0200323\DeclareMathOperator{\re}{Re}
oscarbeneditoef77d902019-09-30 19:44:52 +0200324\DeclareMathOperator{\spec}{Spec}
325\DeclareMathOperator{\Log}{Log}
oscarbeneditoaa0fe752019-10-01 13:13:01 +0200326\DeclareMathOperator{\Arg}{Arg}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200327%\DeclareMathOperator{\tr}{tr} % Already in physics
328\DeclareMathOperator{\vol}{vol}
329%\DeclareMathOperator{\grad}{grad} % Already in physics
330\DeclareMathOperator{\rot}{rot}
331\DeclareMathOperator{\diver}{div}
332\DeclareMathOperator{\sinc}{sinc}
333\DeclareMathOperator{\graf}{graf}
oscarbeneditoef77d902019-09-30 19:44:52 +0200334\DeclareMathOperator{\TQ}{\text{ tal que }}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200335\DeclareMathOperator{\tq}{\;t.q.\;}
336\DeclareMathOperator{\disc}{disc}
337\DeclareMathOperator{\fl}{fl} % Representación en coma flotante
338\DeclareMathOperator{\sgn}{sgn} % Función signo (sgn) de una permutación
339\DeclareMathOperator{\diag}{diag} % Notación corta para matriz diagonal: diag(d_1,...,d_n)
340\DeclareMathOperator{\vspan}{span}
341% \end{macrocode}
342%
343% \subsubsection{Index}
344% \begin{macrocode}
345\newcounter{apuntsfme@index}
346\setcounter{apuntsfme@index}{1}
347\def\consume#1{}%
348\def\printcmd{\expandafter\consume\string}
349\def\idx#1{%
Ernesto Lanchares5a818342019-10-16 16:22:34 +0200350 \edef\apuntsfme@tmp{apuntsfme@index:\Roman{apuntsfme@index}}%
351 \expandafter\label\expandafter{\apuntsfme@tmp}%
352 \expandafter\xdef\csname indice\Roman{apuntsfme@index}\endcsname%
Ernesto Lanchares09dc48e2019-10-16 16:32:05 +0200353 ##1{\noexpand\hyperref[apuntsfme@index:\Roman{apuntsfme@index}]{##1}}%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200354 \index{#1|\expandafter\printcmd\csname indice\Roman{apuntsfme@index}\endcsname}%
Ernesto Lanchares5a818342019-10-16 16:22:34 +0200355 \stepcounter{apuntsfme@index}%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200356}
357
358\makeindex
359\RequirePackage[totoc]{idxlayout} % Glossari a l'índex
360% \end{macrocode}
361%
362% \subsection{Environments}
363% Here we define the environments in which the notes we take are based on.
364%
365% TODO add an option to the package to select the position of the number (before/after)
366% \begin{macrocode}
367\newtheoremstyle{break}% name
368{}% Space above, empty = `usual value'
369{}% Space below
370{}% Body font
371{}% Indent amount (empty = no indent, \parindent = para indent)
372{\bfseries}% Thm head font
373{}% Punctuation after thm head
374{5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
375{\thmname{#1}\thmnumber{ #2}.\thmnote{ {\it #3.}\newline}}% Thm head spec
376
377\newtheoremstyle{demo}% name
378{}% Space above, empty = `usual value'
379{}% Space below
380{}% Body font
381{}% Indent amount (empty = no indent, \parindent = para indent)
382{\it}% Thm head font
383{}% Punctuation after thm head
384{5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
385{#1\thmnote{ #3}.}% Thm head spec
386
387\newtheoremstyle{breakthm}% name
388{}% Space above, empty = `usual value'
389{}% Space below
390{}% Body font
391{}% Indent amount (empty = no indent, \parindent = para indent)
392{\bfseries}% Thm head font
393{}% Punctuation after thm head
394{\newline}% Space after thm head: \newline = linebreak
395{\thmname{#1}\thmnumber{ #2}.\thmnote{ {\it #3.}}\addcontentsline{toc}{subsection}{#3}}% Thm head spec
396
397\newtheoremstyle{normal}% name
398{}% Space above, empty = `usual value'
399{}% Space below
400{}% Body font
401{}% Indent amount (empty = no indent, \parindent = para indent)
402{\bfseries}% Thm head font
403{}% Punctuation after thm head
404{5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
405{\thmname{#1}\thmnumber{ #2}.\thmnote{ {\it #3.}}}% Thm head spec
406
407\newtheoremstyle{autodefi}% name
408{}% Space above, empty = `usual value'
409{}% Space below
410{}% Body font
411{}% Indent amount (empty = no indent, \parindent = para indent)
412{\bfseries}% Thm head font
413{}% Punctuation after thm head
414{5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
Ernesto Lanchares1c675712019-10-16 16:24:43 +0200415{\idx{#3}\thmname{#1}\thmnumber{ #2}.}% Thm head specko
oscarbenedito6bc418b2019-09-20 13:28:57 +0200416% \end{macrocode}
417%
418% \subsection{Options}
419% Here we have some options for the package
420%
421% \subsubsection{Babel}
422% TODO add english support and make it the default
423% \begin{macrocode}
oscarbeneditoaa0fe752019-10-01 13:13:01 +0200424\DeclareOption{numbersbefore}{
425 \newtheoremstyle{break}% name
426 {}% Space above, empty = `usual value'
427 {}% Space below
428 {}% Body font
429 {}% Indent amount (empty = no indent, \parindent = para indent)
430 {\bfseries}% Thm head font
431 {}% Punctuation after thm head
432 {5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
433 {\thmnumber{#2}. \thmname{#1.}\thmnote{ {\it #3.}\newline}}% Thm head spec
434
435 \newtheoremstyle{demo}% name
436 {}% Space above, empty = `usual value'
437 {}% Space below
438 {}% Body font
439 {}% Indent amount (empty = no indent, \parindent = para indent)
440 {\it}% Thm head font
441 {}% Punctuation after thm head
442 {5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
443 {#1\thmnote{ #3}.}% Thm head spec
444
445 \newtheoremstyle{breakthm}% name
446 {}% Space above, empty = `usual value'
447 {}% Space below
448 {}% Body font
449 {}% Indent amount (empty = no indent, \parindent = para indent)
450 {\bfseries}% Thm head font
451 {}% Punctuation after thm head
452 {\newline}% Space after thm head: \newline = linebreak
453 {\thmnumber{#2}. \thmname{#1.}\thmnote{ {\it #3.}}\addcontentsline{toc}{subsection}{#3}}% Thm head spec
454
455 \newtheoremstyle{normal}% name
456 {}% Space above, empty = `usual value'
457 {}% Space below
458 {}% Body font
459 {}% Indent amount (empty = no indent, \parindent = para indent)
460 {\bfseries}% Thm head font
461 {}% Punctuation after thm head
462 {5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
463 {\thmnumber{#2}. \thmname{#1.}\thmnote{ {\it #3.}}}% Thm head spec
464
465 \newtheoremstyle{autodefi}% name
466 {}% Space above, empty = `usual value'
467 {}% Space below
468 {}% Body font
469 {}% Indent amount (empty = no indent, \parindent = para indent)
470 {\bfseries}% Thm head font
471 {}% Punctuation after thm head
472 {5pt plus 1pt minus 1pt}% Space after thm head: \newline = linebreak
System Userd832fce2019-11-18 11:49:30 +0100473 {\idx{#3}\label{defi:#2}\thmnumber{#2}. \thmname{#1.}}% Thm head specko
oscarbeneditoaa0fe752019-10-01 13:13:01 +0200474}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200475\newif\if@babel\@babeltrue
oscarbeneditoef77d902019-09-30 19:44:52 +0200476\newcount\@babellang
477\@babellang=0
478\def\@babelopt{english}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200479\DeclareOption{nobabel}{
480 \@babelfalse
481}
oscarbeneditoef77d902019-09-30 19:44:52 +0200482\DeclareOption{catalan}{
483 \gdef\@babelopt{catalan}
484 \@babellang=1
485}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200486\DeclareOption{spanish}{
oscarbeneditoef77d902019-09-30 19:44:52 +0200487 \gdef\@babelopt{spanish,es-lcroman,es-nolists}
488 \@babellang=2
489}
Ernesto Lanchares29b298b2019-10-01 19:41:04 +0200490% \end{macrocode}
491%
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +0200492% Then, we need to configure TiKz and PGF
493% \begin{macrocode}
494\usetikzlibrary{positioning,arrows, calc, babel}
495
496\newif\if@external\@externaltrue
497\DeclareOption{noexternal}{
498 \@externalfalse
499}
500\def\apunts@folder{figures/}
501
502\pgfplotsset{compat=1.11}
503% \end{macrocode}
Ernesto Lanchares29b298b2019-10-01 19:41:04 +0200504%
505% Lastly, we procces the options.
506% \begin{macrocode}
oscarbeneditoef77d902019-09-30 19:44:52 +0200507\ProcessOptions\relax
Ernesto Lanchares0641d3d2019-10-01 19:39:23 +0200508
509\if@external
510 \usetikzlibrary{external}
511 \tikzexternalize[prefix=\apunts@folder]
512\fi
513
oscarbeneditoef77d902019-09-30 19:44:52 +0200514\if@babel
515 \PassOptionsToPackage{\@babelopt}{babel}
516 \RequirePackage{babel}
517\fi
518\ifnum\@babellang=1
519 % Normal
520 \declaretheorem[style=normal,name=Lema,numberwithin=section]{lema}
521 \declaretheorem[style=normal,name=Lema,numbered=no]{lema*}
522 \declaretheorem[style=normal,name=Observació,sibling=lema]{obs}
523 \declaretheorem[style=normal,name=Observació,numbered=no]{obs*}
524 \declaretheorem[style=normal,name=Proposició,sibling=lema]{prop}
525 \declaretheorem[style=normal,name=Proposició,numbered=no]{prop*}
526 \declaretheorem[style=normal,name=Definició,sibling=lema]{defi*}
527 \declaretheorem[style=normal,name=Coro{\lgem}ari,sibling=lema]{col}
528 \declaretheorem[style=normal,name=Coro{\lgem}ari,numbered=no]{col*}
529 \declaretheorem[style=normal,name=Exercici,sibling=lema]{ej}
530 \declaretheorem[style=normal,name=Exercici,numbered=no]{ej*}
531 \declaretheorem[style=normal,name=Exemple,sibling=lema]{example}
532 \declaretheorem[style=normal,name=Exemple,numbered=no]{example*}
533 \declaretheorem[style=normal,name=Problema,sibling=lema]{problema}
534 \declaretheorem[style=normal,name=Problema,numbered=no]{problema*}
535
536 % Autodefi
537 \declaretheorem[style=autodefi,name=Definició,sibling=lema]{defi}
538
539 % Demo
540 \let\proof\relax
541 \declaretheorem[style=demo,name=Demostració,qed=$\square$,numbered=no]{proof}
542 \declaretheorem[style=demo,name=Solució,numbered=no]{sol}
543
544 % Break
545 \declaretheorem[style=break,name=Teorema,sibling=lema]{teo*}
546
547 % Breakthm
548 \declaretheorem[style=breakthm,name=Teorema,sibling=lema]{teo}
549
550 \@ifclassloaded{book}{%
551 \AtBeginDocument{\renewcommand{\chaptername}{Tema}}
552 }{}
553\fi
554\ifnum\@babellang=2
oscarbenedito6bc418b2019-09-20 13:28:57 +0200555 % Normal
556 \declaretheorem[style=normal,name=Lema,numberwithin=section]{lema}
557 \declaretheorem[style=normal,name=Lema,numbered=no]{lema*}
558 \declaretheorem[style=normal,name=Observación,sibling=lema]{obs}
559 \declaretheorem[style=normal,name=Observación,numbered=no]{obs*}
560 \declaretheorem[style=normal,name=Proposición,sibling=lema]{prop}
561 \declaretheorem[style=normal,name=Proposición,numbered=no]{prop*}
562 \declaretheorem[style=normal,name=Definición,sibling=lema]{defi*}
563 \declaretheorem[style=normal,name=Corolario,sibling=lema]{col}
564 \declaretheorem[style=normal,name=Corolario,numbered=no]{col*}
565 \declaretheorem[style=normal,name=Ejercicio,sibling=lema]{ej}
566 \declaretheorem[style=normal,name=Ejercicio,numbered=no]{ej*}
567 \declaretheorem[style=normal,name=Ejemplo,sibling=lema]{example}
568 \declaretheorem[style=normal,name=Ejemplo,numbered=no]{example*}
569 \declaretheorem[style=normal,name=Problema,sibling=lema]{problema}
570 \declaretheorem[style=normal,name=Problema,numbered=no]{problema*}
571
572 % Autodefi
573 \declaretheorem[style=autodefi,name=Definición,sibling=lema]{defi}
574
575 % Demo
576 \let\proof\relax
577 \declaretheorem[style=demo,name=Demostración,qed=$\square$,numbered=no]{proof}
578 \declaretheorem[style=demo,name=Solución,numbered=no]{sol}
579
580 % Break
581 \declaretheorem[style=break,name=Teorema,sibling=lema]{teo*}
582
583 % Breakthm
584 \declaretheorem[style=breakthm,name=Teorema,sibling=lema]{teo}
oscarbeneditoef77d902019-09-30 19:44:52 +0200585
oscarbenedito6bc418b2019-09-20 13:28:57 +0200586 \@ifclassloaded{book}{%
587 \AtBeginDocument{\renewcommand{\contentsname}{Contenidos}}
588 \AtBeginDocument{\renewcommand{\chaptername}{Tema}}
589 }{}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200590\fi
591% \end{macrocode}
592%
593% \iffalse
594%</package>
595% \fi
596% \section{Class implementation}
597% \iffalse
598%<*class>
599% \fi
600% \subsection{Imports}
601% \begin{macrocode}
602\RequirePackage[utf8]{inputenc}
603\RequirePackage[T1]{fontenc}
oscarbeneditoef77d902019-09-30 19:44:52 +0200604\RequirePackage{lmodern}
MiquelOrtega9872c512020-04-22 00:40:41 +0200605\RequirePackage{graphicx}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200606% \end{macrocode}
607%
608% \subsection{Language}
609% The default language is english
610% \begin{macrocode}
611\newcommand*{\@authortext}{Author}
612\newcommand*{\@authorstext}{Authors}
oscarbeneditoef77d902019-09-30 19:44:52 +0200613\newcommand*{\@prauthortext}{Principal author}
614\newcommand*{\@prauthorstext}{Principal authors}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200615\newcommand*{\@otherauthortext}{Other authors}
oscarbeneditoef77d902019-09-30 19:44:52 +0200616\newcommand*{\@reviewertext}{Reviewers}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200617\newcommand*{\@lastupdatetext}{Last update}
618\newcommand*{\@titlemonth}{\ifcase \the\month \or January\or February\or March\or April\or May \or June\or July\or August\or September\or October\or November\or December\fi \: \number \year}
619\newcommand*{\titlemonth}[1]{\gdef\@titlemonth{#1}}
620
621\DeclareOption{spanish}{
622 \renewcommand*{\languagename}{spanish}
oscarbeneditoef77d902019-09-30 19:44:52 +0200623 \renewcommand*{\@authortext}{Autor}
624 \renewcommand*{\@authorstext}{Autores}
625 \renewcommand*{\@prauthortext}{Autor principal}
626 \renewcommand*{\@prauthorstext}{Autores principales}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200627 \renewcommand*{\@otherauthortext}{Otros autores}
oscarbeneditoef77d902019-09-30 19:44:52 +0200628 \renewcommand*{\@reviewertext}{Revisores}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200629 \renewcommand*{\@lastupdatetext}{\'Ultima modificaci\'on}
630 \renewcommand*{\@titlemonth}{\ifcase \the\month \or Enero\or Febrero\or Marzo\or Abril\or Mayo \or Junio\or Julio\or Agosto\or Septiembre\or Octubre\or Noviembre\or Diciembre\fi \: \number \year}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200631}
632
MiquelOrtega9872c512020-04-22 00:40:41 +0200633\newif\if@puntvolat\@puntvolatfalse
oscarbenedito6bc418b2019-09-20 13:28:57 +0200634\DeclareOption{catalan}{
635 \renewcommand*{\languagename}{catalan}
oscarbeneditoef77d902019-09-30 19:44:52 +0200636 \renewcommand*{\@authortext}{Autor}
637 \renewcommand*{\@authorstext}{Autors}
638 \renewcommand*{\@prauthortext}{Autor principal}
639 \renewcommand*{\@prauthorstext}{Autors principals}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200640 \renewcommand*{\@otherauthortext}{Altres autors}
oscarbeneditoef77d902019-09-30 19:44:52 +0200641 \renewcommand*{\@reviewertext}{Revisors}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200642 \renewcommand*{\@lastupdatetext}{\'Ultima modificaci\'o}
643 \renewcommand*{\@titlemonth}{\ifcase \the\month \or Gener\or Febrer\or Mar\c{c}\or Abril\or Maig \or Juny\or Juliol\or Agost\or Setembre\or Octubre\or Novembre\or Desembre\fi \: \number \year}
MiquelOrtega9872c512020-04-22 00:40:41 +0200644 \@puntvolattrue
oscarbenedito6bc418b2019-09-20 13:28:57 +0200645}
646% \end{macrocode}
647%
648% \subsection{Metatadata}
649% TODO creo que no funciona o algo así...
650% \begin{macrocode}
651\newcommand*{\generatemetadata}{%
652 \renewcommand*{\and}{ and }
653 \hypersetup{
654 pdfauthor={\@author}
655 }
656 \renewcommand*{\and}{ }
657 \hypersetup{
658 pdftitle={{\@title} -- ApuntsFME},
659 pdfsubject={\@title},
660 pdfkeywords={ApuntsFME},
661 }
662}
663% \end{macrocode}
664%
665% \subsection{Process options}
666% \begin{macrocode}
667\ProcessOptions\relax
668% \end{macrocode}
669%
670% \subsection{Import class}
671% Again we don't think making the whole thing from scratch was viable.
672% \begin{macrocode}
673\LoadClass[12pt]{book}
674% \end{macrocode}
675%
676% \subsection{Title page}
677% Here we create the title page, one of the strengths of this class
678%
679% \subsubsection{Last update}
680% \begin{macrocode}
681\newif\if@lastupdate\@lastupdatetrue
682\newcommand*{\nolastupdate}{\@lastupdatefalse}
683% \end{macrocode}
684%
685% \subsubsection{Authors}
686% \begin{macrocode}
687\newcommand*{\@metaauthor}{}
688
oscarbenedito6bc418b2019-09-20 13:28:57 +0200689\newcount\apuntsfme@numberauthor
690\apuntsfme@numberauthor=0
691
692\def\@author{}
693\renewcommand*{\author}[1]{%
694 \expandafter\gdef\csname apuntsfme@author\the\apuntsfme@numberauthor\endcsname{#1}%
695 \advance\apuntsfme@numberauthor by1 %
696}
697% \end{macrocode}
698%
699% \subsubsection{Other Authors}
700% \begin{macrocode}
oscarbeneditoef77d902019-09-30 19:44:52 +0200701\def\@otherauthor{}
702\newcommand*{\otherauthor}[1]{%
703 \ifx\@otherauthor\empty %
704 \gdef\@otherauthor{#1}%
705 \else%
706 \expandafter\gdef\expandafter\@otherauthor\expandafter{\@otherauthor, #1}%
707 \fi%
708}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200709% \end{macrocode}
710%
711% \subsubsection{Reviewers}
712% \begin{macrocode}
oscarbeneditoef77d902019-09-30 19:44:52 +0200713\def\@reviewer{}
714\newcommand*{\reviewer}[1]{%
715 \ifx\@reviewer\empty %
716 \gdef\@reviewer{#1}%
717 \else%
718 \expandafter\gdef\expandafter\@reviewer\expandafter{\@reviewer, #1}%
719 \fi%
720}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200721% \end{macrocode}
722%
723% \subsubsection{Subtitle}
724% \begin{macrocode}
725\newcommand*{\subtitle}[1]{\gdef\@subtitle{#1}}
726\newcommand*{\@subtitle}{}
727% \end{macrocode}
728%
729% \subsubsection{Thanks comment}
730% \begin{macrocode}
731\newcommand*{\thankscomment}[1]{\gdef\@thankscomment{#1}}
732\newcommand*{\@thankscomment}{}
733% \end{macrocode}
734%
735% \subsubsection{Title page}
736% All of the previous sections are combined here were we actually make the title page.
737% TODO remove doclicense
738% \begin{macrocode}
739\renewcommand*{\maketitle}{%
740\generatemetadata
741\begin{titlepage}
oscarbeneditoef77d902019-09-30 19:44:52 +0200742 \centering\scshape%
743 \vspace*{\fill}%
744 \rule{\textwidth}{1.6pt}\vspace*{-\baselineskip}\vspace*{2pt} %
745 \rule{\textwidth}{0.4pt} %
746
oscarbenedito6bc418b2019-09-20 13:28:57 +0200747 \vspace{0.75\baselineskip}
oscarbeneditoef77d902019-09-30 19:44:52 +0200748
749 \renewcommand*{\and}{\protect\\}%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200750 {\LARGE \expandafter\MakeUppercase\expandafter{\@title}\\}
751
752 \vspace{0.75\baselineskip}
753
oscarbeneditoef77d902019-09-30 19:44:52 +0200754 \rule{\textwidth}{0.4pt}\vspace*{-\baselineskip}\vspace{3.2pt} %
755 \rule{\textwidth}{1.6pt} %
oscarbenedito6bc418b2019-09-20 13:28:57 +0200756
757 \vspace{1.5\baselineskip}
758
759 \@subtitle
760
761 \vspace*{\fill}
762 \vspace*{\fill}
763 \vspace*{\fill}
764 \vspace*{\fill}
765 \vspace*{\fill}
766 \vspace*{\fill}
767
768 \includegraphics[width=5cm]{../logo.pdf}
769
770 \vspace{0.3\baselineskip}
771
772 Barcelona, \@titlemonth
773\end{titlepage}
774
775\vspace*{\fill}
776
oscarbeneditoef77d902019-09-30 19:44:52 +0200777\ifnum\apuntsfme@numberauthor=0%
778\else%
779 \ifx\@otherauthor\empty %
780 \ifnum\apuntsfme@numberauthor=1%
781 \noindent \@authortext: %
782 \else%
783 \noindent \@authorstext: %
784 \fi%
785 \else%
786 \ifnum\apuntsfme@numberauthor=1%
787 \noindent \@prauthortext: %
788 \else%
789 \noindent \@prauthorstext: %
790 \fi%
791 \fi
792 \newcount\apuntsfme@tempauthor%
793 \loop%
794 \ifnum\apuntsfme@tempauthor=0 %
795 \else%
796 , %
797 \fi%
798 \csname apuntsfme@author\the\apuntsfme@tempauthor\endcsname%
799 \advance\apuntsfme@tempauthor by 1 %
800 \ifnum\apuntsfme@tempauthor < \apuntsfme@numberauthor%
801 \repeat%
802 .%
oscarbenedito6bc418b2019-09-20 13:28:57 +0200803\fi
804\ifx\@otherauthor\empty
805\else
806
807 \quad
808
809 \noindent \@otherauthortext: \@otherauthor.
810\fi
811\ifx\@reviewer\empty
812\else
813
814 \quad
815
oscarbenedito6bc418b2019-09-20 13:28:57 +0200816 \noindent \@reviewertext: \@reviewer.
817\fi
818\ifx\@thankscomment\empty
819\else
820
821 \quad
822
823 \noindent \@thankscomment
824\fi
825\if@lastupdate
826
827 \quad
828
829 \noindent \@lastupdatetext: \@date.
830\fi
831
832\doclicenseThis
833}
834% \end{macrocode}
835%
836% \subsection{Other commands}
837%
838% \begin{macro}{\makecover}
839% \begin{macrocode}
840\newcommand*{\makecover}{
841 \frontmatter
842 \maketitle
843 \tableofcontents
844 \mainmatter
845}
846% \end{macrocode}
847% \end{macro}
848%
849% \subsection{Other includes}
MiquelOrtega9872c512020-04-22 00:40:41 +0200850% These packages need to be included last, so we place them here. The hyperref
851% package is included as late as possible. TODO remove doclicense
oscarbenedito6bc418b2019-09-20 13:28:57 +0200852% \begin{macrocode}
853\RequirePackage[a4paper,margin=1in]{geometry}
MiquelOrtega9872c512020-04-22 00:40:41 +0200854\AtBeginDocument{\RequirePackage{hyperref}}
oscarbenedito6bc418b2019-09-20 13:28:57 +0200855\RequirePackage[
856 type={CC},
857 modifier={by-nc-sa},
858 version={4.0},
859]{doclicense}
860% \end{macrocode}
861%
flopguic1a33f52020-02-11 19:16:46 +0100862% \subsection{Parche punt volat}
863
864%Definició de la ela geminada per tal que accepti el punt volat del teclat
MiquelOrtega9872c512020-04-22 00:40:41 +0200865\if@puntvolat
866 \def·#1{%
867 \ifmmode
868 \cdot #1
flopguic1a33f52020-02-11 19:16:46 +0100869 %\csname normal@char\string"\endcsname l%
MiquelOrtega9872c512020-04-22 00:40:41 +0200870 \else%
871 \def\argument{#1}%
872 \if\argument l%
873 \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
874 \setbox0\hbox{l}\setbox1\hbox{l\/}\setbox2\hbox{.}%
875 \advance\raiselldim by \the\fontdimen5\the\font
876 \advance\raiselldim by -\ht2%
877 \leftllkern=-.5\wd0%
878 \advance\leftllkern by \wd1%
879 \advance\leftllkern by -\wd0%
880 \rightllkern=-.5\wd0%
881 \advance\rightllkern by -\wd1%
882 \advance\rightllkern by \wd0%
883 \allowhyphens\discretionary{-}{l}%
884 {\hbox{}\kern\leftllkern\raise\raiselldim\hbox{.}%
885 \kern\rightllkern\hbox{l}}\allowhyphens%
886 \else
887 \if\argument L%
888 \leftllkern=0pt\rightllkern=0pt\raiselldim=0pt%
889 \setbox0\hbox{L}\setbox1\hbox{L\/}\setbox2\hbox{.}%
890 \advance\raiselldim by .5\ht0%
891 \advance\raiselldim by -.5\ht2%
892 \leftllkern=-.5\wd0%
893 \advance\leftllkern by \wd1%
894 \advance\leftllkern by -\wd0%
895 \rightllkern=.375\wd0%
896 \divide\rightllkern by 6%
897 \advance\rightllkern by -\wd1%
898 \advance\rightllkern by \wd0%
899 \allowhyphens\discretionary{-}{L}%
900 {\hbox{}\kern\leftllkern\raise\raiselldim\hbox{.}%
901 \kern\rightllkern\hbox{L}}\allowhyphens%
902 \else
903 #1
904 \fi
905 \fi
906 \fi
907 }
908\fi
flopguic1a33f52020-02-11 19:16:46 +0100909
oscarbenedito6bc418b2019-09-20 13:28:57 +0200910% \iffalse
911%</class>
912% \fi