%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% make the index link to the correct part of the page               %
% http://tex.stackexchange.com/q/74493/5645                         %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{indexanchor}
\newcommand*{\xindex}[1]{%
  \stepcounter{indexanchor}% make anchor unique
  \def\theindexterm{#1}%
  \edef\doindexentry{\noexpand\index
    {\expandonce\theindexterm|indexanchor{index-\theindexanchor}}}%
  \raisebox{\baselineskip}{\hypertarget{index-\theindexanchor}%
    {\doindexentry}}%
}
\newcommand*{\indexanchor}[2]{\hyperlink{#1}{#2}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Aufgaben-Environment                                              %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcounter{aufgabe}
\newenvironment{aufgabe}[1][]{\refstepcounter{aufgabe}%
  \ifthenelse{\isempty{#1}}%
    {\subsection*{Aufgabe~\theaufgabe}}% if #1 is empty
    {\subsection*{Aufgabe~\theaufgabe~(#1)}}% if #1 is not empty
    \begin{adjustwidth}{1cm}{}}%
    {\end{adjustwidth}}

\newenvironment{solution}[1][]{%
    \subsection*{Lösung zu Aufgabe~#1}%
    \begin{adjustwidth}{1cm}{}}%
    {\end{adjustwidth}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% Define theorems                                                   %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand{\thmfoot}{}
\theoremstyle{break}
\setlength\theoremindent{0.7cm}
\theoremheaderfont{\kern-0.7cm\normalfont\bfseries} 
\theorembodyfont{\normalfont} % nicht mehr kursiv
\theoremseparator{\thmfoot}

\newframedtheorem{satz}{Satz}[chapter]
\newframedtheorem{lemma}[satz]{Lemma}
\newframedtheorem{proposition}[satz]{Proposition}
\newtheorem{korollar}[satz]{Korollar}
\newtheorem{folgerung}[satz]{Folgerung}
\newtheorem{definition}{Definition}
\newtheorem{beispiel}{Beispiel}
\newtheorem{bemerkung}{Bemerkung}
\theoremstyle{nonumberplain}
\newtheorem{beweis}{Beweis:}
\newtheorem{behauptung}{Beh.:}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\def\fB{\mathfrak{B}}%Für Basis
\def\fT{\mathfrak{T}}%Für Topologie
\renewcommand{\qed}{\hfill\blacksquare}
\newcommand{\qedwhite}{\hfill \ensuremath{\Box}}
\newcommand{\powerset}[1]{\mathcal{P}(#1)}
\def\praum{\ensuremath{\mathcal{P}}}
\def\mdp{\ensuremath{\mathbb{P}}}
\def\mdc{\ensuremath{\mathbb{C}}}
\def\mdr{\ensuremath{\mathbb{R}}}
\def\mdq{\ensuremath{\mathbb{Q}}}
\def\mdz{\ensuremath{\mathbb{Z}}}
\def\mdn{\ensuremath{\mathbb{N}}}
\def\mdh{\ensuremath{\mathbb{H}}}
\def\gdw{\ensuremath{\Leftrightarrow}}

\def\atlas{\ensuremath{\mathcal{A}}}
\DeclareMathOperator{\rang}{rg}

\def\GL{\ensuremath{\mathrm{GL}}}
\def\SL{\ensuremath{\mathrm{SL}}}
\def\PSL{\ensuremath{\mathrm{PSL}}}
\newcommand\mapsfrom{\mathrel{\reflectbox{\ensuremath{\mapsto}}}}
\newcommand\dcup{\mathbin{\dot{\cup}}}
\newcommand{\id}{\textnormal{id}}
\DeclareMathOperator{\Deck}{Deck}
\DeclareMathOperator{\Fix}{Fix}
\DeclareMathOperator{\Iso}{Iso}
\DeclareMathOperator{\grad}{grad}
\DeclareMathOperator{\Perm}{Perm}
\DeclareMathOperator{\Sym}{Sym}
\DeclareMathOperator{\Homoo}{\textnormal{Homöo}}
\DeclareMathOperator{\Diffeo}{Diffeo}
\DeclareMathOperator{\conv}{conv}
\DeclareMathOperator{\IWS}{IWS}
\DeclareMathOperator{\DV}{DV}
\DeclareMathOperator{\Rg}{Rg}
\DeclareMathOperator{\Bild}{Bild}
\newcommand{\iu}{{i\mkern1mu}} % imaginary unit
%\DeclareMathOperator{\Re}{Re}
%\DeclareMathOperator{\Im}{Im}

%%%Text %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newcommand\obda{o.~B.~d.~A.\xspace}
\newcommand\Obda{O.~B.~d.~A.\xspace}
\newcommand{\ts}[1]{\textnormal{#1}} % textual subscript
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% http://tex.stackexchange.com/a/101138/5645
\newcommand\rtilde[1]{\widetilde{\mathit{#1}}}
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\crefname{satz}{\textup{Satz}}{\textup{Sätze}}
\crefname{proposition}{\textup{Proposition}}{\textup{Propositionen}}
\crefname{lemma}{\textup{Lemma}}{\textup{Lemmata}}
\crefname{korollar}{\textup{Korollar}}{\textup{Korollare}}
\crefname{folgerung}{\textup{Folgerung}}{\textup{Folgerungen}}
\crefname{definition}{\textup{Definition}}{\textup{Definitionen}}
\crefname{behauptung}{\textup{Behauptung}}{\textup{Behauptungen}}
\crefname{beispiel}{\textup{Beispiel}}{\textup{Beispiele}}
\crefname{aufgabe}{\textup{Aufgabe}}{\textup{Aufgaben}}
\crefname{bemerkung}{\textup{Bemerkung}}{\textup{Bemerkungen}}
%\let\OldAngle\angle
%\let\angle\sphericalangle

\newlist{defenum}{enumerate}{1}
\setlist[defenum]{label=\alph*),ref=\textup{\thedefinition.\alph*}}
\crefalias{defenumi}{definition}

\newlist{bemenum}{enumerate}{1}
\setlist[bemenum]{label=\alph*),ref=\textup{\thebemerkung.\alph*}}
\crefalias{bemenumi}{bemerkung}

\newlist{bspenum}{enumerate}{1}
\setlist[bspenum]{label=\arabic*),ref=\textup{\thebeispiel.\arabic*}}
\crefalias{bspenumi}{beispiel} 

\newlist{propenum}{enumerate}{1}
\setlist[propenum]{label=\alph*), ref=\textup{\theproposition~(\alph*)}}
\crefalias{propenumi}{proposition} 

\newlist{aufgabeenum}{enumerate}{1}
\setlist[aufgabeenum]{label=(\alph*),ref=\textup{\theaufgabe~(\alph*)}}
\crefalias{aufgabeenumi}{aufgabe}

% Commands for local abbreviations
\newcommand\crefabbr[1]{%
\begingroup
  \crefname{bemerkung}{\textup{Bem.}}{\textup{Bem.}}%
  \crefname{definition}{\textup{Def.}}{\textup{Def.}}\cref{#1}
\endgroup%
}
\newcommand\Crefabbr[1]{%
\begingroup
  \Crefname{bemerkung}{\textup{Bem.}}{\textup{Bem.}}%
  \Crefname{definition}{\textup{Def.}}{\textup{Def.}}\Cref{#1}
\endgroup%
}
