% \documentclass[12pt]{article}

% page setup
% \usepackage[a4paper,
%             top=2.5cm,
% 			bottom=2.5cm,
% 			left=2.00cm,
% 			right=2.00cm,
% 			bmargin=2.50cm]{geometry}
\usepackage[a4paper,
			top=2.75cm,
			bottom=2.50cm,
			left=2.25cm,
			right=2.25cm,
			bmargin=2.50cm]{geometry}

\usepackage[spanish]{babel}

\usepackage{float}
\usepackage{titlesec}
\usepackage{fontspec}
\setmainfont{Helvetica}

% right pointing hand
\usepackage{utfsym}

% make pictures caption font bold and small
% \usepackage[font={footnotesize}]{caption}
\usepackage{subcaption}

% inline code (backticks in md)
\linespread{1.10}
\definecolor{bgcolor}{HTML}{e0e0e0}
\let\oldtexttt\texttt

\renewcommand{\texttt}[1]{
	\colorbox{bgcolor}{\oldtexttt{#1}}
}

% change boldfont bold to extrabold
% \setmainfont[
%  BoldFont={Inter-ExtraBold}
% ]{Inter}

% change regular font to light font
% \setmainfont{Inter light}

\newfontfamily\titlefont{Inter}[
UprightFont     =   *-Regular,
BoldFont        =   *-ExtraBold,
Scale           =   0.90
]

\newfontfamily\sectionsfont{Inter}[
UprightFont     =   *-Regular,
BoldFont        =   *-Bold,
]

\setmathfont[Scale=1.00]{Fira Math}

\usepackage{xcolor}
\definecolor{ugrey}{HTML}{333333}

\titleformat{\section}
{\color{black}\titlefont\Large\bfseries}
{\color{black}}
{0em}
{}

\titleformat{\subsection}
{\color{black}\sectionsfont\large\bfseries}
{\color{black}}
{0em}
{}

\titleformat{\subsubsection}
{\color{black}\sectionsfont\bfseries}
{\color{black}}
{0em}
{}

\titleformat{\paragraph}
{\color{black}\sectionsfont\bfseries}
{\color{black}\theparagraph}
{0em}
{}

\titleformat{\subparagraph}
{\color{black}\normalfont\bfseries}
{\color{black}\theparagraph}
{0em}
{}

% spacing: how to read {12pt plus 4pt minus 2pt}
%       12pt is what we would like the spacing to be
%       plus 4pt means that TeX can stretch it by at most 4pt
%       minus 2pt means that TeX can shrink it by at most 2pt
%
% \titlespacing{command}{left spacing}{before spacing}{after spacing}[right]

\titlespacing*{\section}
{0pt}{1.50ex plus 0.25ex minus 0.10ex}{1.25ex plus 0.00ex}

\titlespacing*{\subsection}
{0pt}{1.25ex plus 0.10ex minus 0.10ex}{0.75ex plus 0.00ex}

\titlespacing*{\subsubsection}
{0pt}{1.25ex plus 0.10ex minus 0.10ex}{0.50ex plus 0.00ex}

\titlespacing*{\paragraph}
{0pt}{1.25ex plus 0.10ex minus 0.10ex}{0.50ex plus 0.00ex}

\titlespacing*{\subparagraph}
{0pt}{1.25ex plus 0.10ex minus 0.10ex}{0.50ex plus 0.00ex}

% spacing between formulas and text
% \usepackage[nodisplayskipstretch]{setspace}
% \setstretch{1.20}

% \setlength{\textfloatsep}{2pt plus 1.0pt minus 2.0pt}
% \setlength{\intextsep}{2pt plus 1.0pt minus 2.0pt}

\setlength{\abovecaptionskip}{1.00em}  % above caption
\setlength{\belowcaptionskip}{-0.85em} % below caption

\setlength{\textfloatsep}{0pt}
\setlength{\dblfloatsep}{0pt} % twocolumn float sep
\setlength{\intextsep}{8pt}

\setlength{\abovedisplayskip}{0pt}
\setlength{\belowdisplayskip}{0pt}

\setlength{\abovedisplayshortskip}{0pt}
\setlength{\belowdisplayshortskip}{0pt}

\setlength{\belowdisplayshortskip}{\belowdisplayskip}

\setlength{\baselineskip}{0pt}

\setlength{\parskip}{0.5em}
\linespread{1.00}  % 1.25 = 1.5 líneas aprox

% \usepackage{setspace}
% \setstretch{1.25}

% \captionsetup{font=small, labelfont=bf}
\captionsetup{font=small, labelfont=md}
\captionsetup[sub]{font=footnotesize,labelfont=md}

\renewcommand\thesubfigure{\arabic{subfigure}}

\renewcommand{\figurename}{Figura}
\renewcommand{\tablename}{Tabla}

% \renewcommand{\contentsname}{Índice}
\renewcommand\contentsname{\vspace*{-45pt}}

% TOC dots separation
% \renewcommand{\cftdotsep}{10}

% \setlength{\cftsecindent}{0pt}% Remove indent for \section
% \setlength{\cftsubsecindent}{5pt}% Remove indent for \subsection
% \setlength{\cftsubsubsecindent}{0pt}% Remove indent for \subsubsec

\setcounter{tocdepth}{4}

\usepackage{titling}
\renewcommand{\maketitle}{ 
	\begin{flushleft}
	{\bfseries\Huge\thetitle}
	% \vspace{1mm}
	\end{flushleft}
	% \thispagestyle{empty}
}

% remove the page number from all the pages that the TOC occupies
% \addtocontents{toc}{\protect\thispagestyle{empty}}

% add page break after TOC set it to page number 1
\let\oldtableofcontents\tableofcontents % remember the definition
\renewcommand\tableofcontents{
	\oldtableofcontents % use the standard toc
	\thispagestyle{empty}
	\pagebreak
	\setcounter{page}{1}
}

% Set text color for all document
% \color{ugrey}

\usepackage[titles]{tocloft}
\renewcommand{\cftdotsep}{1.5}
\renewcommand{\cftsetpnumwidth}{1.5}
\renewcommand{\cftsetrmarg}{1.5}

% \usepackage{float}
% \makeatletter
% \def\fps@figure{H}
% \makeatother

% nicer chemical figures
\usepackage{chemfig}

% change style of quote, see also https://tex.stackexchange.com/a/436253/114857
\usepackage[most]{tcolorbox}

\definecolor{linequote}{RGB}{224,215,188}
\definecolor{bordercolor}{RGB}{221,221,221}
% \definecolor{backquote}{RGB}{249,245,233}
\definecolor{backquote}{RGB}{245,245,245}

% change left border: https://tex.stackexchange.com/a/475716/114857
% change left margin: https://tex.stackexchange.com/a/457936/114857
\newtcolorbox{myquote}[1][]{%
	enhanced,
	breakable,
	size=minimal,
	left=0pt,
	top=12pt,
	bottom=12pt,
	right=12pt,
	boxrule=1pt,
	sharp corners=all,
	colback=backquote,
	colframe=black,
	#1}

% redefine quote environment to use the myquote environment, see
% https://tex.stackexchange.com/a/337587/114857
\renewenvironment{quote}{\begin{myquote}}{\end{myquote}}

% better fractions
\usepackage{nicefrac,xfrac}

% surround footnotes number with square brackets and always use numbers (even
% inside quoted text)
% https://www.overleaf.com/learn/latex/Footnotes
\renewcommand*{\thefootnote}{\ [\arabic{footnote}]\ }
\renewcommand*{\thempfootnote}{\ [\arabic{mpfootnote}]\ }

% space between text and footer
\setlength\footskip{36pt}
\setlength{\skip\footins}{2pt}

% align first letter of all the lines in the footnotes
\usepackage[bottomfloats, belowfloats, hang, multiple, ragged]{footmisc}
\setlength{\footnotemargin}{1em}

\newcommand{\unit}[2]{\nicefrac{#1}{#2}}

\usepackage{enumitem}
\usepackage{amsfonts}

\setlist[itemize,1]{label=$\bullet$}
\setlist[itemize,2]{label=$\textopenbullet$}

\usepackage{tabularx}
\usepackage{multirow} % Required for multirows
\usepackage{colortbl}

% Reduce space around displayed equations safely
\makeatletter
\setlength{\jot}{8pt} % valor por defecto es 3pt aproximadamente
\makeatother

\usepackage{multicol}
\setlength{\columnsep}{12pt}

% Delay start of two-column layout
\AtBeginDocument{
    \renewcommand{\figurename}{Figura}
    \renewcommand{\tablename}{Tabla}
}

% Begin multicols after title
% \usepackage{etoolbox}
% \pretocmd{\maketitle}{\clearpage\begin{multicols*}{2}}{}{}
% \AtEndDocument{
%   \end{multicols*}
% }

\binoppenalty=10000 
\relpenalty=10000

\usepackage{listings}
\lstset{
  breaklines=true,
  breakatwhitespace=true,
  basicstyle=\ttfamily\small,
  columns=fullflexible
}

\usepackage{xcolor}

% tango style
\definecolor{bgcolor}{HTML}{F6F6F6}
\definecolor{keywordcolor}{HTML}{204A87}
\definecolor{commentcolor}{HTML}{8F5902}
\definecolor{stringcolor}{HTML}{4E9A06}
\definecolor{numbercolor}{HTML}{0000CF}
\definecolor{operatorcolor}{HTML}{CE5C00}
\definecolor{identifiercolor}{HTML}{000000} % For general text

\lstset{
  backgroundcolor=\color{bgcolor},
  basicstyle=\ttfamily\small,
  keywordstyle=\color{keywordcolor}\bfseries,
  commentstyle=\color{commentcolor}\itshape,
  stringstyle=\color{stringcolor},
  identifierstyle=\color{identifiercolor},
  numberstyle=\color{numbercolor},
  emphstyle=\color{operatorcolor}\bfseries,
  breaklines=true,
  breakatwhitespace=true,
  columns=fullflexible,
  showstringspaces=true,
  frame=single,
  framerule=1pt,
  xleftmargin=0pt,
  moredelim=**[is][\color{operatorcolor}\bfseries]{@}{@}, % allow inline operator styling using @...@
}
