\usepackage[paperheight=240mm,paperwidth=170mm,left=2.1cm,right=1.9cm,top=20mm,bottom=20mm,heightrounded]{geometry}

\usepackage{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

\usepackage{caption}



\usepackage{tikz}
\usetikzlibrary {arrows.meta,bending,positioning}
\usepackage{circuitikz}
\usetikzlibrary{circuits.ee.IEC.relay}
%\usepackage{sanitize-umlaut}


% fuer Stichwortverzeichnis
\usepackage{makeidx}

% Stichwortverzeichnis erstellen
\makeindex


\usepackage{graphicx}
%\usepackage{fancyhdr}
%\usepackage{makecell}

%\reversemarginpar

% ref packages
%\usepackage{nameref}
% folowing  must be in this order
%\usepackage{varioref}
\usepackage[colorlinks=true,urlcolor=blue,linkcolor=blue]{hyperref}
%\usepackage{cleveref}

\usepackage[parfill]{parskip}
%\newcommand{\anf}[1]{"`#1"'}

\newcommand{\anf}[1]{\glqq#1\grqq}

%\usepackage{showframe}
\usepackage[most]{tcolorbox}
\usepackage{amsmath,amssymb}


\usepackage{scrlayer-scrpage}
\pagestyle{scrheadings} 	

%https://www.grund-wissen.de/informatik/latex/seitenlayout.html
\automark[section]{chapter}
\clearscrheadfoot
\ohead{\pagemark}
\ihead{\headmark}

\newcommand{\einrueckungm}[2]{\begin{addmargin}[#1pt]{0pt}
		#2\end{addmargin}
}

\newcommand{\einrueckung}[1]{\begin{addmargin}[45pt]{0pt}
		#1\end{addmargin}
}

%%%%Leerseite
\usepackage{afterpage}
\newcommand\myemptypage{
	\null
	\thispagestyle{empty}
	\addtocounter{page}{-1}
	\newpage
}	

%%%%Zahl linker Rand

\newcommand{\liRa}[1]{\marginpar[\raggedleft\Huge{\textbf{#1}}]{\textbf{\Huge{#1}}}}

%%%%Farbbox
\newtcolorbox{mybox}[1][]{%
	%enhanced,
	%boxed title style={colback=red, sharp corners},
	colframe = orange!20,
	colback = orange!20,  
	%	overlay = {\node[text=white, fill=red] at (frame.east) 
		%		{$\clubsuit$};},
	#1}

%\usepackage{enumitem,calc}
%\SetLabelAlign{myparleft}{\parbox[t]\textwidth{#1\par\mbox{}}}

\usepackage{calc}
\usepackage{enumitem} % für liste mit Klammern siehe 3.4
%\setlist[description]{leftmargin=\parindent,labelindent=\parindent}\usepackage{enumitem}
%\setlist[description]{leftmargin=\parindent,labelindent=\parindent}

\newlength{\mylength}

\newcommand{\ausrichtung}[1]{ % Befehl zur Berechnung der Wortlänge
	\settowidth{\mylength}{#1} % Breite des Wortes berechnen und in Längenvariable speichern
	\hspace{\mylength}} % wird die Klammer eine Zeile tiefer gesetzt, dann rutscht das nachfolgende um ? nach rechts


%%%%%%%%%%%%%%%%%%%%%
\usepackage{amsthm}
\newtheorem{thm}{Theorem}[chapter]
\newtheorem{defn}[thm]{Definition}

\newtheoremstyle{theorem}
{10pt}
{0pt}
{}
{}
{\bfseries}
{}
{\newline}
{}
\theoremstyle{theorem}


%%%%%%%%%%%%%%%%%%%%%%%%%%
%1. Beispiel
%\newtheoremstyle{break}
%{\topsep}{\topsep}%
%{\itshape}{}%
%{\bfseries}{}%
%{\newline}{}%
%\theoremstyle{break}
%\newtheorem{theorem}{Theorem}
%
%\begin{document}
%	
%	\begin{theorem}[Some note]
	%		\lipsum*[2]
	%	\end{theorem}
%	
%\end{document}

%2. Beispiel
%\newtheoremstyle{side}{}{}{\advance\leftskip3cm\relax\itshape}{}
%{\bfseries}{}{0pt}{%
	%	\makebox[0pt][r]{%
		%		\smash{\parbox[t]{2.5cm}{\raggedright\thmname{#1}%
				%				\thmnumber{\space #2}\thmnote{\newline (#3)}}}%
		%		\hspace{.5cm}}}
%
%\theoremstyle{side}
%\newtheorem{theorem}{Theorem}[section]
%
%\theoremstyle{definition}
%\newtheorem{definition}[theorem]{Definition}
%
%\begin{document}
%	
%	\lipsum[1]
%	
%	\begin{theorem}
	%		\lipsum[1]
	%	\end{theorem}
%	
%	\begin{theorem}[Euclid]
	%		\lipsum[2]
	%	\end{theorem}
%	
%	\begin{theorem}[Very long name]
	%		\lipsum[3]
	%	\end{theorem}
%	
%	\begin{definition}
	%		\lipsum[1]
	%	\end{definition}
%	
%\end{document}






%%%%%%%%%%%%%%%%%%%%%%%%%


\newtheorem{thb}{Theorem}[chapter]
\newtheorem{bsp}[thb]{Beispiel}

%https://tex.stackexchange.com/questions/338209/remove-dot-after-theorem-with-amsthm-and-hyperref

\usepackage{xpatch}
\makeatletter
\AtBeginDocument{\xpatchcmd{\@thm}{\thm@headpunct{.}}{\thm@headpunct{}}{}{}}
\makeatother

\numberwithin{equation}{chapter} %Numerierung der Formeln mit Kapitelnummer 

%%%%%%%%%%%%%%%%%%%%%Tabellenbreite

%\usepackage{tabulary}

%%%%%%%%%%%%%%%%%%%%%




%%%%%%Neues Enviroment für Defintion
%% https://tex.stackexchange.com/questions/43495/defining-a-custom-environment-with-per-section-numbering

\newcounter{mydefcount}
\newcounter{mybspcount}
\newcounter{myaufgcount}

\newenvironment{definition}{%      define a custom environment
	\bigskip\noindent%         create a vertical offset to previous material
	\refstepcounter{mydefcount}% increment the environment's counter
	\textbf{Definition \themydefcount}% or \textbf, \textit, ...
	
}{\par\bigskip}  %          create a vertical offset to following material
\numberwithin{mydefcount}{chapter}

%%%%%%Neues Enviroment für Definition Ende

\newenvironment{beispiel}{%      define a custom environment
	\bigskip\noindent%         create a vertical offset to previous material
	\refstepcounter{mybspcount}% increment the environment's counter
	\textbf{Beispiel \themybspcount}\mbox{}
	\vspace*{-\baselineskip}
	\newline
	
}{\par\bigskip}  %          create a vertical offset to following material
\numberwithin{mybspcount}{chapter}


\newenvironment{aufgabe}{%      define a custom environment
	\bigskip\noindent%         create a vertical offset to previous material
	\refstepcounter{myaufgcount}% increment the environment's counter
	\textbf{* Aufgabe \themyaufgcount}\mbox{}
	\vspace*{-\baselineskip}
	\newline
	
}{\par\bigskip}  %          create a vertical offset to following material
\numberwithin{myaufgcount}{chapter}

\title{Grundlagen der Mathematik, Abbildungen, Funktionen, Folgen}

%%%Pfeile
\pgfdeclarelayer{background}
\pgfsetlayers{background,main}
\newcommand{\bglayer}[1]{%
	\begin{pgfonlayer}{background}
		\begin{scope}[every picture]
			#1
		\end{scope}
	\end{pgfonlayer}
}
%%%Pfeile

\everymath{\displaystyle}


%\newcolumntype{C}[1]{>{\centering\arraybackslash}m{#1}}



%%%Caption in tabelle auch links
\usepackage[singlelinecheck=false % <-- important
]{caption}

\usepackage{booktabs} 
\usepackage{floatrow} % um die caption nach rechts zu setzen

%Abbildung nach Bild umbenennen
\renewcaptionname{german}{\figurename}{Bild}
%%%%Besipiele
%\renewcaptionname{ngerman}{\contentsname}{Inhalt}
%\renewcaptionname{ngerman}{\listfigurename}{Abbildungen}
%\renewcaptionname{ngerman}{\listtablename}{Tabellen}
%\renewcaptionname{ngerman}{\figurename}{Abb.}
%\renewcaptionname{ngerman}{\tablename}{Tab.}
%%%%%%%%



%%%%%%%%%%%%%%%%%%%%Test Caption
%\makeatletter
%\newcommand{\captionabove}[2][]{%
	%	\vskip-\abovecaptionskip
	%	\vskip+\belowcaptionskip
	%	\ifx\@nnil#1\@nnil
	%	\caption{#2}%
	%	\else
	%	\caption[#1]{#2}%
	%	\fi
	%	\vskip+\abovecaptionskip
	%	\vskip-\belowcaptionskip
	%}

% If \captionof is required:
% Usage: \captionaboveof[<short caption>]{table}{<caption>}
%\newcommand{\captionaboveof}[3][]{%
	%	\vskip-\abovecaptionskip
	%	\vskip+\belowcaptionskip
	%	\def\@captype{#2}%
	%	\ifx\@nnil#1\@nnil
	%	\caption{#3}%
	%	\else
	%	\caption[#1]{#3}%
	%	\fi
	%	\vskip+\abovecaptionskip
	%	\vskip-\belowcaptionskip
	%}
%\makeatother
%%%%%%%%%%%%%%%%%%%%Test Caption