-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathCommandsAndStyle.sty
169 lines (143 loc) · 5.39 KB
/
CommandsAndStyle.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
\ProvidesPackage{CommandsAndStyle}
\usepackage[utf8]{inputenc}
\usepackage[italian]{babel}
\usepackage[a4paper,twoside,top=1in, bottom=1.1in, left=1in, right=1in]{geometry} %top,bottom,left,right are margins
\usepackage{graphicx}
\usepackage{hyperref} %References become hyperlinks.
\hypersetup{
colorlinks = true,
linkcolor = {blue},
urlcolor = {red}
}
% In short documents, to remove page numbers.
% \pagenumbering{gobble}
% \hypersetup{
% pageanchor=false
% }
\usepackage{amsmath}
\usepackage{amsthm}
\usepackage{amssymb}
\usepackage{esint} %For the average integral
\usepackage{mathrsfs} %Just for cool sigma-algebra
\usepackage{color}
\usepackage{array}
\usepackage{hhline}
\usepackage{enumitem} %Customize enumerate and itemize
\usepackage{imakeidx} %Analytical index
\usepackage{xparse} %In order to use ExplSyntax (in older latex versions)
\usepackage{mathtools}
\usepackage{fancyhdr} %Header and footer of pages
\usepackage{ifthen} %Ifthen construct
\usepackage{forloop} %forloop construct
\usepackage{xstring}
\usepackage{blindtext} %lorem ipsum generator (doesn't support italian and therefore gives some warnings
%Possible customization of header and footer
% \setlength{\headheight}{16pt}
% \pagestyle{fancy}
% \fancyhead{}
% \fancyhead[LE,RO]{\slshape\nouppercase{\leftmark}}
\usepackage[nameinlink]{cleveref} %References show what kind of thing is being referenced (theorem, lemma, proposition...)
\newcommand{\crefpairconjunction}{ e }
\newcommand{\crefrangepreconjunction}{da }
\newcommand{\crefrangeconjunction}{ a }
\newcommand{\creflastconjunction}{ e }
\newcounter{Results}[section] %Uniform counters for lemmas, theorems, propositions etc
\renewcommand{\theResults}{\thesection.\arabic{Results}}
%Definition of theorem-like environments
\newtheorem{theorem}[Results]{Teorema}
\newtheorem{lemma}[Results]{Lemma}
\newtheorem{proposition}[Results]{Proposizione}
\newtheorem{corollary}[Results]{Corollario}
\newtheorem{exercise}[Results]{Esercizio}
\theoremstyle{remark}
\newtheorem{remark}[Results]{Nota}
\theoremstyle{definition}
\newtheorem{definition}[Results]{Definizione}
\newtheorem*{example}{Esempio}
\numberwithin{equation}{section}
%Names used in references
\crefname{equation}{Equazione}{Equazioni}
\crefname{theorem}{Teorema}{Teoremi}
\crefname{lemma}{Lemma}{Lemmi}
\crefname{proposition}{Proposizione}{Proposizioni}
\crefname{corollary}{Corollario}{Corollari}
\crefname{exercise}{Esercizio}{Esercizi}
\crefname{remark}{Nota}{Note}
\crefname{definition}{Definizione}{Definizioni}
\crefname{section}{Sezione}{Sezioni}
\newcommand{\ImplicationProof}[2]{$\text{\ref{#1}}\implies\text{\ref{#2}}$} %Special reference for implication of propositions
%Redefinition of cref, in order to have the name of the theorem in case it has one.
%It's hardcoded and not exactly clean and easy.
\makeatletter
\ExplSyntaxOn
\let\@tempcref\cref
\newcommand{\myref}[1]{
\IfSubStr{#1}{,}{
\@tempcref{#1}%
}
{
\ifcsname r@#1\endcsname%La reference è definita?
\edef\@RefInfo{\csname r@#1\endcsname}%Contiene tutte le informazioni sulla reference
\edef\@CompleteCounter{\expandafter\@fourthoffive\@RefInfo}%Contiene il nome espanso del contatore
\expandafter\IfBeginWith{\@CompleteCounter}{equation}{%La reference è un'equazione?
\@tempcref{#1}%
}
{
\edef\@RefName{\expandafter\@thirdoffive\@RefInfo}%Contiene, se definito, il nome della reference
\StrLen{\@RefName}[\@RefNameLen]
\ifthenelse{\@RefNameLen<2}{%Il nome è vuoto o di un solo carattere? (tocca lasciare la possibilità che sia di un solo carattere sennò al carducci non va)
\@tempcref{#1}%
}
{
\@tempcref{#1}~(\nameref*{#1})%
}
}
% \begin{itemize}
% \item \expandafter\@firstoffive\@mytxt
% \item \expandafter\@secondoffive\@mytxt
% \item \expandafter\@thirdoffive\@mytxt
% \item \expandafter\@fourthoffive\@mytxt
% \item \expandafter\@fifthoffive\@mytxt
% \end{itemize}
\else
\@tempcref{#1}
\fi
}
}
\renewcommand{\cref}{\myref}
\ExplSyntaxOff
\makeatother
%Short commands for frequently used number sets.
\newcommand{\N}{\ensuremath{\mathbb N}}%Natural numbers
\newcommand{\Z}{\ensuremath{\mathbb Z}}%Integers
\newcommand{\Q}{\ensuremath{\mathbb Q}}%Rationals
\newcommand{\R}{\ensuremath{\mathbb R}}%Real numbers
\newcommand{\C}{\ensuremath{\mathbb C}}%Complex numbers
\DeclarePairedDelimiter\abs{\lvert}{\rvert} %Absolute value
\newcommand{\de}{\ensuremath{\,\mathrm d}}%Il de degli integrali
\newcommand{\Diff}{\ensuremath{\mathrm D}}%Simbolo del differenziale
\newcommand \eps{\ensuremath{\epsilon}}
%Divergence
\let\divsymb\div
\let\div\undefined
\DeclareMathOperator{\div}{div}
\DeclareMathOperator{\tr}{tr}
\newcommand{\grad}{\ensuremath{\nabla}}
\DeclareMathOperator{\graf}{graf}
\DeclareMathOperator{\supp}{supp}
\newcommand \lapl{\ensuremath{\grad^2}}
\newcommand{\bigO}{\ensuremath{\mathcal{O}}}
\newcommand{\smallO}{\ensuremath{\mathrm{o}}}
%Definiamo gli intervalli semiaperti, aperti, chiusi.
\newcommand{\co}[2]{\ensuremath{\left[\,#1,\,#2\,\right)}}
\newcommand{\oo}[2]{\ensuremath{\left(\,#1,\,#2\,\right)}}
\newcommand{\cc}[2]{\ensuremath{\left[\,#1,\,#2\,\right]}}
\newcommand{\oc}[2]{\ensuremath{\left(\,#1,\,#2\,\right]}}
%Punteggiatura nelle formule
\ifdefined\virgola
\renewcommand{\virgola}{\ensuremath{\, \text{, }}}
\else
\newcommand{\virgola}{\ensuremath{\, \text{, }}}
\fi
\newcommand{\puntovirgola}{\ensuremath{\, \text{; }}}
\newcommand{\punto}{\ensuremath{\, \text{. }}}