% interface=en output=pdftex
%\environment capcalera.context % Capçalera

% Regime
\enableregime[utf]

% Choose a font
\setupbodyfont [cmr,11pt] % cmr, 11pt

% Be tolerant with paragraph building
\setuptolerance [horizontal,verytolerant,stretch]

% Choose a language, and associated hyphenation rules.
%\language [ca]
\mainlanguage[ca]


% Page number
\setuppagenumbering [location={footer}]

% White space between paragraphs
%\setupwhitespace [big]

% Paper size
\setuppapersize [a4]

% Margins
%\setuplayout  [grid=yes, footer=0.5\footerheight, header=0.5\headerheight]
%\setuplayout[footer=2cm, header=2cm]
%\showlayout
%\showframe
%\showsetups
% Format de marges
%\setuplayout[topspace=1.5cm, % marge d'adalt
%margin=1.5cm, %marges dels costats
%header=1.0cm,%separació entre adalt i primera línia
%footer=1.0cm,%separació entre abaix i darrera línia
%width=fit,height=fit,backspace=2cm]



% Enable colors and activate hyperlinks
\setupcolors [state=start]
\definecolor[lightblue][r=0.5, g=0.5, b=1.0]
%\setupinteraction [state=start, color=lightBlue]
%\setupurl[style=small, space=yes]
\setupurl[space=yes]

% Enumerate the URLs
%\useURL[wiki][http://wiki.contextgarden.net][][\ConTeXt\ wiki]
%\useURL[nagorko-pdf][http://www.math.bgu.ac.il/~barakw/probseminar/nagorko/slides.pdf][][http://www.math.bgu.ac.il/\~{}barakw/\quad\quad\quad\quad probseminar/nagorko/slides.pdf]
%\useURL[govern-me][http://sgtrelinst.caib.es/llibrestil/00index.html][][http://sgtrelinst.caib.es/llibrestil/00index.html]
%\useURL[context-manual-pdf][http://www.pragma-ade.com/general/manuals/cont-eni.pdf][][http://www.pragma-ade.com/general/manuals/ cont-eni.pdf]
%\useURL [contextgarden] [{http://www.contextgarden.net}]

%\useURL [mccammond][{http://www.math.ucsb.edu/~jon.mccammond/geogrouptheory/}][] [{\tf http://www.math.ucsb.edu/\~{}jon.mccammond/geogrouptheory/}]


% Fonts
%% Chapters...
\setupheads[align=flushleft]
\setuphead[chapter][style={\tfd\bf}]
\setuphead[section][style={\bfc}, header=nomarking]
\setuphead[subsection][style={\bfb}]
\setuphead[subsubsection][style={\bfa}]
%\setuphead[section][textstyle=bold]

% Bibliography options
% BIBTEX
\usemodule[bib]
\usemodule[bibltx]
\setupbibtex[database=memoria,sort=author]
\setuppublications [alternative=ams,numbering=yes, sorttype=bbl, criterium=cite]%
\setupheadtext[ca][pubs=Referències]
\setuppublicationlist[authoretallimit=3]
\setuppublicationlist[authoretaltext={\it\  et al.}]
\setuppublicationlist[authoretaldisplay=1]

%Indentation
\setupheads[indentnext=yes] 
\setupindenting[yes,small,first]
%\setupformulae[indentnext=yes]

% Vertical spaces between paragraphs
\setupwhitespace[small]

%Itemize
\setupitemize[each][indentnext=no,margin=2em] % [identnext=yes,margin=2em]
\setupitemize[each][headstyle=bold]
%\setupitemize[a][right=),stopper=]

% Mathematical packets
\usemodule[newmat]
\usemodule[math-ams]

% Heads and footers
\setupfootertexts[][{\tfxx \currentdate}]
%\setupfootertexts[\pagenumber/\lastpage]
%\setupfooter[text][before=\hrule]
%\setupheader[text][after=\hrule]
%\setupheadertexts[{\tfx Màster de Matemàtiques}][{\tfx \jobname.\ConTeXt{}.\currentdate}]
%\setupheadertexts[][{\tfx \currentdate}]


% hyphenating
\hyphenation{do-cu-ment}
\hyphenation{pro-ble-ma}
\hyphenation{es-crip-tu-ra}
\hyphenation{ge-ne-ra-lit-za-ció}
\hyphenation{cor-res-po-nents}
\hyphenation{pa-rells}
\hyphenation{ge-ne-rat}

% Modules
\usemodule[tikz]
\usemodule[pgfmath]
\usetikzlibrary[mindmap,arrows,calc,decorations.pathmorphing,decorations.markings]
%\usetikzlibrary[trees]



% AMSTHM equivalent
%% Exercici
\defineenumeration
  [exercici]
  [text={Problema},headstyle=bold,between=\blank,titledistance=0em,textdistance=1em,
stopper={.\space},location=serried,left={\bgroup\bf},right={\egroup},width=fit,before={\bgroup\startframedtext[background=screen,frame=off,width=broad]},after={\stopframedtext\egroup}]

%% Lema 
\defineenumeration
  [lema]
  [text={Lema}, % Què es mostra
   before={\blank[big]}, % abans de lema, un bigskip
   after={\blank[big]}, % després de lema, un bigskip
   headstyle=bold, % Negreta per la capçaleras
   %between=\blank, % Entre Lemmes una línia en blanc
   titledistance=.5em, % espai entre número i parèntesis.
   textdistance=.5em, % espai entre ) i text
   stopper={.\space}, % Com acaba. Després de parèntesis un '.'
   location=serried,
   width=fit, % que ocupi tot l'espai
   style=italic, % estil del text
   title=yes, % si puc posar o no arguments opcionals
   titlestyle=bf, % estil del títol
   way=bytext, % enumerar en tot el document
   conversion=numbers,indenting=yes] % enumera amb arabic

%% Proposició, corol·laris, teoremes.
%% Comparteix els nombres amb lema
%% Si volem que vagin a part, hem de posar 'number=proposition'
\defineenumeration
  [proposition]
  [lema]
  [text={Proposició}]

\defineenumeration
  [corollary]
  [lema]
  [text={Corol·lari}]

\defineenumeration
  [theorem]
  [lema]
  [text={Teorema}]


%% Definició
\defineenumeration
  [definition]
  [lema]
  [text={Definició},style=tf,titlestyle=bf,indenting=yes]

\defineenumeration
  [notation]
  [definition]
  [text={Notació},style=tf,titlestyle=bf,indenting=yes]

\defineenumeration
  [note]
  [definition]
  [text={Nota},style=tf,titlestyle=bf,indenting=yes]

%% Demostració

\defineenumeration[demo][text={Demostració.\space},number=no,location=serried,width=fit,headstyle=italic,indentnext=yes,between=\blank,textdistance=.5em,closesymbol={\mathematics{\Box}},style=normal,indenting=yes]

% Table of contents
%% dots between... and subsubsubsection are not listed
\setupcombinedlist[content][level=4,alternative=c] 
%% section = bold. % width= 10mm --> less space between num-letter
%% line break after section.
\setuplist[section][style=bold,width=10mm] 
\setuplist[section][before=\blank]
%% margin = 10 mm. Put the subsection just bottom section.
\setuplist[subsection][margin=10mm,width=10mm]
\setuplist[subsubsection][margin=20mm,width=10mm]

%\setuplist[subsection] %[distance=1em] % section = bold. % 
% Això ho trec d'un manual:
%\setuplist[subsection]
%          [margin=1em,
%          numbercommand=\NumCom]
%\def\NumCom#1{\hbox to 2em{\hfill #1}}

% Set "Índex" like "Índex de continguts"
\setupheadtext [ca] [content=Índex]


% Definitions/abbreviations
\define[1]\dist{d(\sigma_g(#1), \sigma_h(#1))}
\define[1]\imp{{\bgroup\startframedtext[background=screen,frame=on,width=broad]#1\stopframedtext\egroup}}
%\define[1]\imp{{\bgroup\startframedtext[background=color,backgroundcolor=lightblue,frame=on,width=broad]#1\stopframedtext\egroup}}


% SPLIT
\def\startsplit
  {\startalign} % no number by default
\def\stopsplit
  {&\doalignNR[+][]\crcr % for a number on last line
   \stopalign}

% Other
\setupunderbar[alternative=b] % Fix underline style
% For putting underline with spaces: \underbar{\dorecurse{40}~}

% Define new register for the Index of Symbols
\defineregister[symbol][symbols]


% Start the text
\starttext
%\version[concept]

a\footnote{A}

\stoptext