|
%%% important comment keywords %%% |
|
% CAVEAT: -> a warning concerning some compilation issues that may break your system in some situation |
|
% ADJUST: -> manual tweaks that you may want to change |
|
% TODO: -> to-do list |
|
% HACK: -> Savy macros to easily use a given packages |
|
|
|
%%%%%%%%% Document language %%%%%%%%% |
|
% \usepackage[utf8]{inputenc} % ADJUST: descomente esta linha para mudar o idioma do texto para Português |
|
% \usepackage[portuguese]{babel} |
|
% \usepackage{cmap} % must be loaded before fontenc; embeds a proper ToUnicode CMap so copy-pasted text from the PDF isn't garbled |
|
% \usepackage[T1]{fontenc} % single-glyph accented characters (instead of OT1's composite accents), required together with cmap for correct copy-paste |
|
|
|
%%%%%%%%% bibliography %%%%%%%%% |
|
\usepackage[style=numeric-comp,backend=biber]{biblatex} % tells LaTeX to use the biber tool instead of the traditional bibtex tool for sorting and formatting your bibliography. Biber is a more advanced and powerful tool than bibtex and it provides more features, such as advanced sorting, Unicode support and support for various data sources. |
|
\addbibresource{refs.bib} % add reference file, in the document, add \printbibliography to print bibliography |
|
|
|
%%%%%%%%% references (cite and glossary) %%%%%%%%% |
|
\makeatletter |
|
% some classes (e.g., beamer) loads hyperref by default. So it is sensible to check whether it wasn't already loaded to avoind clashes |
|
\@ifpackageloaded{hyperref}{ |
|
% The package is already loaded |
|
}{ |
|
% The package is not loaded, so load it now |
|
\usepackage[colorlinks=true,hyperindex=false]{hyperref} % make references blue and clickable |
|
} |
|
\makeatother |
|
\hypersetup{ % you can use allcolors=blue in hyperref options instead this setup |
|
linkcolor=black, % For \gls{} entries |
|
citecolor=blue, % For \cite{} entries |
|
} |
|
\usepackage{glossaries} % \newglossaryentry{} entries. ADJUST: If you want to make the glossary entries nonclickable, load this package before hyperref |
|
% CAVEAT: don't use `glossaries-extra`, otherwise the conditional glossary entry will not work! % SEE: https://tex.stackexchange.com/questions/98494/glossaries-dont-print-single-occurences/230664#230664 |
|
\glsenableentrycount % enable \cgls, \cglspl, \cGls, \cGlspl |
|
% NOTE: use \cgls-based instead of \gls-based macros as the former puts the initials iff. it was used more than once. |
|
% HACK: |
|
% \glsentrylong{pll} -> long form |
|
|
|
% add hyphened entries |
|
% SEE: https://tex.stackexchange.com/a/311882/211183 |
|
\glsaddkey |
|
{hyphenated} % new key |
|
{\relax} % default value if "hyphenated" isn't used in \newglossaryentry |
|
{\cglsentryhyph} % analogous to \cglsentrytext |
|
{\cGlsentryhyph} % analogous to \cGlsentrytext |
|
{\cglshyph} % analogous to \cglstext |
|
{\cGlshyph} % analogous to \cGlstext |
|
{\cGLShyph} % analogous to \cGLStext |
|
|
|
\let\origcglshyph\cglshyph |
|
\renewcommand{\cglshyph}[1]{% |
|
\glsadd{#1}% mark used for glossary inclusion |
|
\origcglshyph{#1}% original hyphenated display |
|
% mark a flag macro for this label |
|
\expandafter\gdef\csname glsHyphUsed@#1\endcsname{1}% |
|
} |
|
% preserve original \cgls and override to consult the hyphen flag |
|
\let\origcgls\cgls |
|
\renewcommand{\cgls}[1]{% |
|
\ifcsname glsHyphUsed@#1\endcsname |
|
\glsentryshort{#1}% print short form if hyphenated use occurred |
|
\else |
|
\origcgls{#1}% otherwise use original behaviour |
|
\fi |
|
} |
|
|
|
%%%%%%%%% list of authors %%%%%%%%% |
|
\makeatletter |
|
\@ifclassloaded{beamer}{}{% |
|
\usepackage{authblk} % CAVEAT: this pkg will lead to compilation errors if you use it along with `\IEEEauthorblockN`, which is a command from the `IEEEtran` document class |
|
} |
|
\makeatother |
|
|
|
%%%%%%%%% items, tables and figs %%%%%%%%% |
|
\makeatletter |
|
% only load enumitem if not already present (sbrt.cls provides \labelindent) |
|
\@ifpackageloaded{enumitem}{}{\@ifundefined{labelindent}{\usepackage{enumitem}}{}} |
|
\makeatother |
|
\usepackage{xltabular} |
|
\usepackage{float} % use the [H] option |
|
\usepackage{tikz} |
|
\usepackage{graphicx} % extends the basic LaTeX graphic capabilities: placement, scaling, rotation, file formats |
|
\usepackage{svg} % \includesvg{}; % NOTE: requires inkscape and compilation with --shell-escape |
|
\usepackage{subcaption} % provides a means of using the subfigures environment, allowing a figure to be subdivided into smaller parts |
|
\usepackage{standalone} % place tikz environments or other material in own source files |
|
|
|
%%%%%%%%% new features %%%%%%%%% |
|
\usepackage{xparse} % create commands with optional arguments or complex argument structures |
|
\usepackage{xstring} % testing a string's contents, extracting substrings, substitution of substrings |
|
|
|
%%%%%%%%% math %%%%%%%%% |
|
\newcommand\bmmax{0} \newcommand\hmmax{0} % fix the "Too many math alphabets used in version normal" error (see https://tex.stackexchange.com/a/243541/211183) |
|
\usepackage{amsmath} |
|
\usepackage{mathtools} % is an extension package to amsmath to use \DeclarePairedDelimiter |
|
\usepackage{amsfonts} |
|
\usepackage{amssymb} |
|
\usepackage{esint} % provides extended integral symbols, giving you access to a wider variety of integral signs, such as double, triple, quadruple integrals |
|
% HACK: |
|
% \oiint -> contour integral |
|
\usepackage{newtxmath} % for Greek variants (bold, nonitalic, etc...). E.g., `\boldsymbol{\betaup}` |
|
\usepackage{stmaryrd} % provides new symbols, such as \llbracket \rrbracket |
|
\usepackage{bm} % for writing tensor, e.g., $\bm{\mathcal{A}}$ |
|
% only load IEEEtrantools if the class did not already provide IEEEeqnarray |
|
\makeatletter |
|
\@ifpackageloaded{IEEEtrantools}{}{\@ifundefined{IEEEeqnarray}{\usepackage{IEEEtrantools}}{}} |
|
\makeatother |
|
\usepackage{siunitx} % typesetting units and unitless numbers SI (Système International d’Unités) units |
|
% CAVEAT: you cannot use siunitx for nonnumerical values, e.g. \qty{\pi}{\meter\per\second} |
|
% HACK: |
|
% \qty -> number and unit, e.g., \qty{10}{\meter\per\second} |
|
% \unit{} -> unit only, e.g., \unit{\meter\per\second} |
|
% Examples: |
|
% 1. \qtyrange[exponent-to-prefix=true, range-independent-prefix=true]{138e6}{2.9e9}{\hertz} -> 138 MHz to 2.9 GHz |
|
% use, possible options: |
|
% 1. "range-phrase=-" -> change the word "to" to "--" |
|
% 2. range-units=single -> chage "1m to 10m" to "1 to 10m" |
|
% 3. mode=text % writes the unit in full |
|
% 4. quantity-product={-} to create a compound adjective with quantities, e.g. "the 50-Hz signal..." |
|
% use the [per-mode=symbol] option in the \unit or \qty command to change the writing of \per, or change the line below to set it globally |
|
\sisetup{per-mode=symbol} % print the symbol "/" in "25/100" |
|
\sisetup{tight-spacing=true} % makes the spacing in "5 x 10²" closer |
|
% \squared -> ^2 |
|
|
|
\usepackage{physics} % several math macros, such as |
|
\AtBeginDocument{\RenewCommandCopy\qty\SI} % CAVEAT: avoid incompatibilities between physics and siunitx packages when using the \qty{}{} command. The conflict happens because it is defined in both packages. Although physics has \SI{}{} as an alternative, it is deprecated and therefore you should use \unit{} and \qty{}{} instead of \si{} and \SI{}{}, respectively. See here (https://tex.stackexchange.com/questions/628183/how-to-avoid-qty-conflict-with-physics-and-siunitx) for more info. |
|
% HACK: |
|
% \tr -> trace |
|
% \rank -> rank |
|
% \expval -> angle brackets to inner product,〈a,b〉, or ensemble average〈s(t)〉 |
|
% \abs -> |x| |
|
% \norm -> ||x|| |
|
% \eval -> evaluated bar x|_y=a |
|
% \order -> Big-O notation |
|
% \Re -> real |
|
% \Im -> imaginary |
|
% \dd[]{} -> differential |
|
% \dv -> derivative |
|
% \pdv -> partial derivative |
|
|
|
%%%%%%%%% operators %%%%%%%%% |
|
\let\oldemptyset\emptyset % change empty set |
|
\let\emptyset\varnothing |
|
% circular convolution a lá Oppenheim (if possible, prefer \circledast) |
|
\newcommand*\circconv[1]{% |
|
\begin{tikzpicture} |
|
\node[draw,circle,inner sep=1pt] {#1}; |
|
\end{tikzpicture}} |
|
\newcommand{\intersection}{\bigcap\limits} % intersection operator |
|
|
|
%%%%%%%%% delimiters %%%%%%%%% |
|
\makeatletter % changes the catcode of @ to 11 |
|
\DeclarePairedDelimiter\ceil{\lceil}{\rceil} % ⌈x⌉ |
|
\let\oldceil\ceil |
|
\def\ceil{\@ifstar{\oldceil}{\oldceil*}} % swap the asterisk and the nonasterisk behaviors |
|
|
|
\DeclarePairedDelimiter\floor{\lfloor}{\rfloor} % ⌊x⌋ |
|
\let\oldfloor\floor |
|
\def\floor{\@ifstar{\oldfloor}{\oldfloor*}} |
|
\makeatother % changes the catcode of @ back to 12 |
|
|
|
%%%%%%%%% basic functions %%%%%%%%% |
|
\newcommand{\adj}[1]{\ensuremath{\operatorname{adj}\left(#1\right)}} % adjugate matrix |
|
\newcommand{\cof}[1]{\ensuremath{\operatorname{cof}\left(#1\right)}} % cofactor matrix |
|
\newcommand{\eig}[1]{\ensuremath{\operatorname{eig}\left(#1\right)}} % eigenvalues |
|
\newcommand{\nullspace}[1]{\ensuremath{\operatorname{N}\left(#1\right)}} % nullspace or kernel of the matrix |
|
\newcommand{\nullity}[1]{\ensuremath{\operatorname{nullity}\left(#1\right)}} % nullity=dim(N(A)) |
|
\newcommand{\spn}[1]{\ensuremath{\operatorname{span}\left\{#1\right\}}} % span of a set of vectors, \span is a reserved word |
|
\newcommand{\range}[1]{\ensuremath{\operatorname{C}\left(#1\right)}} % range or columnspace of a matrix=span(a1,a2, ..., an), where ai is the ith column vector of the matrix A |
|
\newcommand{\unvec}[1]{\ensuremath{\operatorname{unvec}\left(#1\right)}} % unvectorize operator |
|
\newcommand{\diag}[1]{\ensuremath{\operatorname{diag}\left(#1\right)}} % diagonal operator |
|
\newcommand{\blkdiag}[1]{\ensuremath{\operatorname{blkdiag}\left(#1\right)}} % block diagonal operator |
|
\newcommand{\dom}[1]{\ensuremath{\operatorname{dom}\left(#1\right)}} % domain of the function |
|
\newcommand{\frob}[1]{\ensuremath{\norm{#1}_\textrm{F}}} % Frobenius norm |
|
\renewcommand{\dim}[1]{\ensuremath{\operatorname{dim}\left(#1\right)}} % dimension of a set |
|
|
|
%%%%%%%%% customizable functions %%%%%%%%% |
|
% arg min |
|
\NewDocumentCommand{\argmin}{ e{_} m }{% \argmin_{x ∈ A}{f(x)} or \argmin{f(x)} |
|
\ensuremath{% |
|
\IfValueTF{#1}{% |
|
\mathop{\operatorname{arg\,min}}\limits_{#1}\;#2 |
|
}{% else |
|
\operatorname{arg\,min}\;#2 |
|
} |
|
} |
|
} |
|
% arg max |
|
\NewDocumentCommand{\argmax}{ e{_} m }{% \argmax_{x ∈ A}{f(x)} or \argmax{f(x)} |
|
\ensuremath{% |
|
\IfValueTF{#1}{% |
|
\mathop{\operatorname{arg\,max}}\limits_{#1}\;#2 |
|
}{% else |
|
\operatorname{arg\,max}\;#2 |
|
} |
|
} |
|
} |
|
% limit in the mean (see Van Tress, chapter 6) |
|
\NewDocumentCommand{\limean}{ E{_}{{}} m }{ % \limean_{x ∈ A}{f(x)} or \limean{f(x)} |
|
\ensuremath{ |
|
\IfValueTF{#1}{% |
|
\underset{#1}{\operatorname{l.i.m.}\;#2} |
|
}{% else |
|
\operatorname{l.i.m.}\;#2 |
|
} |
|
} |
|
} |
|
% mean |
|
\NewDocumentCommand{\E}{ E{_}{{}} o m }{% \E{A}, \E_{u}{A}. If you want only the left or right part of \E (useful for breaking line) you can use \E_{u}[left-only]{A} or \E_{u}[right-only]{A}, respectively |
|
\ensuremath{% |
|
\IfValueTF{#2}{% |
|
\IfStrEq{#2}{left-only}{% |
|
\operatorname{E}_{#1}\left[#3\right.% |
|
}{% right-only |
|
\left.#3\right]% |
|
}% |
|
}{% |
|
\operatorname{E}_{#1}\left[#3\right]% |
|
}% |
|
} |
|
} |
|
% covariance |
|
\NewDocumentCommand{\cov}{O{} m}{\ensuremath{\operatorname{cov}_{#1}\left[#2\right]}} % \cov[u]{x} or \cov{x} |
|
% variance |
|
\let\var\undefined\NewDocumentCommand{\var}{O{} m}{\ensuremath{\operatorname{var}_{#1}\left[#2\right]}} % \var[u]{x} or \var{x} |
|
% vectorize operator |
|
\let\vec\undefined\NewDocumentCommand{\vec}{O{} m}{\ensuremath{\operatorname{vec}_{#1}\left(#2\right)}} % \vec[u]{\mathbf{A}}, [u] is optional |
|
% arg |
|
\RenewDocumentCommand{\arg}{ s m }{% \arg{f(x)} -> arg(f(x)) \arg*{f(x)} -> arg f(x) |
|
\ensuremath{% |
|
\IfBooleanTF{#1}{\operatorname{arg} #2}{\operatorname{arg}\left(#2\right)}% |
|
} |
|
} |
|
% normalize all trigonometry functions (new and predefined) to put a parenthesis around the input argument |
|
\RenewDocumentCommand{\sin}{s m}{% \sin{x} -> sin(x) \sin*{x} -> sin x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{sin} #2}{\operatorname{sin}\left(#2\right)}% |
|
} |
|
} |
|
\RenewDocumentCommand{\cos}{s m}{% \cos{x} -> cos(x) \cos*{x} -> cos x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{cos} #2}{\operatorname{cos}\left(#2\right)}% |
|
} |
|
} |
|
\RenewDocumentCommand{\tan}{s m}{% \tan{x} -> tan(x) \tan*{x} -> tan x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{tan} #2}{\operatorname{tan}\left(#2\right)}% |
|
} |
|
} |
|
\NewDocumentCommand{\sinc}{s m}{% \sinc{x} -> sinc(x) \sinc*{x} -> sinc x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{sinc} #2}{\operatorname{sinc}\left(#2\right)}% |
|
} |
|
} |
|
\NewDocumentCommand{\sgn}{s m}{% \sgn{x} -> sgn(x) \sng*{x} -> sgn x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{sng} #2}{\operatorname{sgn}\left(#2\right)}% |
|
} |
|
} |
|
\RenewDocumentCommand{\sec}{s m}{% \sec{x} -> sec(x) \sec*{x} -> sec x |
|
\ensuremath{ |
|
\IfBooleanTF{#1}{\operatorname{sec} #2}{\operatorname{sec}\left(#2\right)}% |
|
} |
|
} |
|
|
|
%%%%%%%%% minor adjusts in some mathematical symbols %%%%%%%%% |
|
\DeclareMathAlphabet{\mathcal}{OMS}{cmsy}{m}{n} % newtxmath changes the font style of \mathcal. It prevents \mathcal from being changed |
|
|
|
\let\oldforall\forall % put some spaces between the \forall command |
|
\renewcommand{\forall}{\;\oldforall\;} |
|
|
|
% fix the problem in putting integral limits above and below the int symbol |
|
% SEE: https://tex.stackexchange.com/questions/148520/to-have-two-limits-in-double-integral |
|
% HACK: \iint \limits_{-\infty}^{+\infty} |
|
\makeatletter |
|
%% make esint definition in line with amsmath |
|
\@for\next:={int,iint,iiint,iiiint,dotsint,oint,oiint,sqint,sqiint, |
|
ointctrclockwise,ointclockwise,varointclockwise,varointctrclockwise, |
|
fint,varoiint,landupint,landdownint}\do{% |
|
\expandafter\edef\csname\next\endcsname{% |
|
\noexpand\DOTSI |
|
\expandafter\noexpand\csname\next op\endcsname |
|
\noexpand\ilimits@ |
|
}% |
|
} |
|
\makeatother |
|
|
|
%%%%%%%%% comments, corrections, or revisions %%%%%%%%% |
|
\usepackage{ifluatex} % handle lualatex-specific packages |
|
\ifluatex |
|
\usepackage{luacolor} % colour support based on LuaTEX’s |
|
\usepackage[soul]{lua-ul} % provide underlining, strikethrough, and highlighting using features in LuaLATEX which avoid the restrictions imposed by other methods |
|
\fi |
|
\newcommand{\obs}[1]{\textcolor{red}{(#1)}} % observation |
|
\newcommand{\secret}[1]{\makebox[0cm]{}} % inline comment |
|
\newcommand{\sizecorr}[1]{\makebox[0cm]{\phantom{$\displaystyle #1$}}} % Used to seize the height of equation |
|
\interfootnotelinepenalty=10000 % restrict the footnote to one page |