\documentclass[onecolumn,a4paper,10pt]{IEEEtran}
%\documentclass{article}

\usepackage{kblocks}
%\tikzexternalize[prefix=figs/] % activate tikzpicture exports

\usepackage{bm}
\usepackage{listings}

\usepackage{verbatim}
\usepackage{fancyvrb} % extended verbatim environments
\usepackage{fancyvrb-ex}


\usepackage{units}

\usepackage{zi4}
%\usepackage{garamondx}
%\usepackage[lig=true]{baskervald}
%\usepackage{palatino}
%\def\rmdefault{zi4}
%\def\sfdefault{zi4}
\usepackage[defaultsans]{lato}

\usepackage{csquotes}

\newcommand*{\kblocks}{\relax~\textit{k}\textsc{blocks}}
\newcommand*{\Tikz}{
    Ti\textit{k}Z
}
\newcommand*{\TikzPGF}{\relax~{Ti\textit{k}Z/\textsc{pgf}}}
\newcommand*{\spacetweak}{\medskip\medskip}

\DefineVerbatimEnvironment
{cvl}{Verbatim}
{formatcom=\color{blue!10!black!90},
	numbers=left,numbersep=2mm,gobble=0,
	frame=lines,rulecolor=\color{gray},framesep=1mm,
	fontseries=,labelposition=none,fontsize=\normalsize,
	xrightmargin=1cm, samepage=false}
%
\newenvironment{apilist}{
	\vspace{1ex}}%
{\vspace{1em}}
%
\newcommand{\cvhd}[1]{{
		{\subsection{#1}}{\mbox{}\break}\vspace{-5ex}
}}

%
\fvset{formatcom=\color{darkgray},
	fontfamily=tt,fontsize=\footnotesize, fontseries=b,
	frame=single,rulecolor=\color{olive},label=\fbox{A},
	numbers=left,numbersep=5pt}
%red,green,blue,cyan,magenta,yellow,black,gray,white,
%darkgray,lightgray,brown,lime,olive,orange,pink,purple,teal,violet

\usepackage[open]{bookmark}
\newcommand*{\urlink}[1]{{
		{\texttt{\url{#1}}}
}}

\begin{document}

\title{\kblocks~Package}
\author{

\IEEEauthorblockN{
\textsc{Oluwasegun~Somefun}~(\textbf{oasomefun@futa.edu.ng}) \\
\footnotesize{\textsc{Department of Computer Engineering, Federal University of Technology, Akure, Nigeria}}
}

}

\markboth{01,~February~2021.~\kblocks~Documentation.~Version~2.0};

\maketitle

\section{Introduction}
Welcome to the demo documentation of\kblocks. Desiring to typeset control block diagrams in \LaTeX~and dissatisfied with the other \LaTeX~macro packages that
can be found online, I thought: \textit{why not write my own macro package for this purpose}.

I wish to start with the question, \enquote{What is\kblocks?} The\kblocks~macro package is the product of using\TikzPGF~to
directly typeset beautiful control block diagrams and signal flow graphs in my Masters' dissertation and papers directly with \LaTeX.
Basically, it just defines a dedicated \enquote{kblock} environment and a number of macro commands to make drawing control block diagrams with\TikzPGF{} more structured and easier. In a sense, when you
use\kblocks~you \textit{program} or typeset graphics for control block diagrams, just as you “program” graphics in your document when you use
\LaTeX~using\TikzPGF.

The powerful options offered by\TikzPGF~often intimidates beginner users not ready to spend careful time learning about\TikzPGF. Like all
\LaTeX~packages,\TikzPGF~inherits the steep learning curve of \LaTeX, that is, no \textit{what you see is what you get}.
The\kblocks~macro reduces the length of this learning curve, by focusing the graphics theme on control block diagrams only.


Fortunately this documentation as it grows and gets to be improved, will come with a number of demos and proper documentation of the\kblocks{} API, which will guide you on creating control block diagrams with\kblocks{} without your having to read the\TikzPGF~manual.

My wish is that you do find it useful and helpful. 

Please, don't forget to share and star the Github repo: \urlink{https://github.com/somefunAgba/kblocks}, if you did.

I will readily welcome any issues or emails for improvement or suggestion with respect to
using\kblocks{} and making it useful for researchers, students and others involved in the applications and field of control theory and signal processing.


\pagebreak
\section{Demos}
\centering
\spacetweak
\subsection{Ex:A}\spacetweak
\begin{SideBySideExample}[label=\fbox{A},xrightmargin=10cm]
\begin{kblock}
% global ref point
\kJumpCS{init}
%% blocks
\kMarkNodeRight{0.2cm}{0cm}{$r$}{init}{rin}
\kPlusPlusMinus{rin}{sb1}{0.2cm}
\kTFRight[0.2cm]{sb1}{tfb1}{$\frac{1}{s}$}
\kMarkNodeRight{0.2cm}{0cm}{}{tfb1}{ny}
\kOutRight[0.2cm]{ny}{yout}{$y$}{0cm}
%% links
\kLink[]{rin}{sb1}
\kLink[$e$]{sb1}{tfb1}
\kLinkn[]{tfb1}{ny}
\kLinkVHHVBelow[0cm]{$1$}{ny}{sb1}{0cm}{0cm}
\kLinkVHHVAbove[0cm]{$1$}{ny}{sb1}{0cm}{0cm}
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:B}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{B},xrightmargin=10cm]
\begin{kblock}
% global ref point
\kJumpCS{init}
%% blocks
\kMarkNodeRight{0.2cm}{0cm}{$r$}{init}{rin}
\kPlusMinusDown{rin}{sb1}{0.2cm}
\kTFRight[0.25cm]{sb1}{tfb1}{$G\left( s \right)$}
\kTFBelow[0.2cm]{tfb1}{tfb2}{$H\left( s \right)$}
\kMarkNodeRight{0.2cm}{0cm}{}{tfb1}{ny}
\kOutRight[0.2cm]{ny}{yout}{$y$}{0cm}
%% links
\kLinkVH[$y$]{ny}{tfb2}{0cm}{0cm}{0cm}{}
\kLinkHV[$\hat{y}$]{tfb2}{sb1}{0cm}{0cm}{9}{}
\kLink[]{rin}{sb1}
\kLink[$e$]{sb1}{tfb1}
\kLinkn[]{tfb1}{ny}
%% coverings
\kCoverRect[blue]{sb1}{1cm}{2cm}{0.5cm}{3cm}
\kCoverTextLeft{2cm}{1cm}{covtx}{Closed-loop system};
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:C}	
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{C},xrightmargin=10cm]
\begin{kblock}
% ref
\kJumpCS{spt}
% top blocks
\kMarkNodeRight{0cm}{0cm}{$I^\star$}{spt}{inI}
\kPlusMinusDown{inI}{sb1}{1.cm}
\kTFRight[0.2cm]{sb1}{tfb1}{$s$}
\kTFBelow[0.5cm]{sb1}{tfb2}{$\frac{1}{2}$}	
\kPlusDownPlusUpL{tfb2}{sb2}{0cm}
\kMinusPlusUp{tfb1}{sb3}{0cm}
\kTFRight[0cm]{sb3}{tfb3}{$0.2$}
\kTFRight[0cm]{tfb3}{tfb4}{$K_3$}
\kMarkNodeAbove{0cm}{0cm}{$V_{dc}$}{inI}{inVdc}
\kMarkNodeBelow{0cm}{0.3cm}{$V_2$}{inI}{inV2}
\kMarkNodeBelow{0cm}{-0.4cm}{$V_3$}{inV2}{inV3}
% bottom blocks
\kMarkNodeBelow{3cm}{0cm}{$V_1$}{inI}{inV1}
\kPlusPlusUpB{tfb4}{sb4}{3cm}
\kPlusMinusDown{inV1}{sb5}{0cm}
\kTFRight[0cm]{sb5}{tfb5}{$\lambda$}
\kOutRight[0cm]{sb4}{outV}{$V_{out}^{\star}$}{0cm}
\kMarkNodeBelow{0cm}{0cm}{$V_4$}{inV1}{inV4}
% top links
\kLinkHV[]{inVdc}{sb3}{0cm}{0cm}{0}{}
\kLinkHV[]{inV2}{sb2}{0cm}{0cm}{0}{}
\kLinkHV[]{inV3}{sb2}{0cm}{0cm}{0}{}
\kLink[]{inI}{sb1}
\kLink[]{sb1}{tfb1}
\kLink[$I_{\beta}$]{tfb2}{sb1}
\kLink[]{tfb1}{sb3}
\kLink[]{sb2}{tfb2}
\kLink[]{sb3}{tfb3}
\kLink[]{tfb3}{tfb4}
\kLink[$V_{\alpha}$]{tfb4}{sb4}
% bottom links
\kLink[]{inV1}{sb5}
\kLink[]{sb5}{tfb5}
\kLink[]{tfb5}{sb4}
\kLinkHV[]{inV4}{sb5}{0cm}{0cm}{0}{}
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:D}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{D},xrightmargin=10cm]
\begin{kblock}
% ref
\kJumpCS{ioref}

% blks
\kTFRight[0cm]{ioref}{tfb1}{
$\bm{\hat{m}$}\\\textbf{PID}
\\\textbf{model}}
\kTFRight[1cm]{tfb1}{tfb2}{$\bm{K\left(y_m,y\right)}$
\\\textbf{PID}\\\textbf{controller}}
\kTFBelowRight{0.25cm}{0.5cm}{tfb2}{tfb3}
{$\bm{P\left(s\right)}$\\\textbf{process}}

% links
\kInLeft[0cm]{tfb1}{inR}{$r$}{0cm}
\kOutDown[0cm]{tfb1}{outU}{$u_m$}{0cm}
\kLink[$y_m$]{tfb1}{tfb2}
\kLinkHV[$u$]{tfb2}{tfb3}{0cm}{0cm}{1}{}
\kLinkHV[$y$]{tfb3}{tfb2}{0cm}{0cm}{4}{}
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:E}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{E},xrightmargin=10cm]
\begin{kblock}
% ref
\kJumpCS{refpt}

% blks
\kTFRight[0cm]{refpt}{tfb1}{
	$\bm{\hat{m}$}\\\textbf{closed PID-loop}
	\\\textbf{model}}
\kTFRight[2cm]{tfb1}{tfb2}{\textbf{PID}$\bm{(y_m,y)}$}
\kTFBelow[0.25cm]{tfb2}{tfb3}
{$\bm{P\left(s\right)}$\\\textbf{process}}

% links
\kInLeft[0cm]{tfb1}{inR}{$r$}{0cm}
\kOutDown[0cm]{tfb1}{outU}{$u_m$}{0cm}
\kLink[$y_m$]{tfb1}{tfb2}
\kLinkHVHRight[0]{$u$}{tfb2}{tfb3}{0cm}{0cm}{1cm}
\kLinkHVHLeft[0.8cm]{$y$}{tfb3}{tfb2}{0cm}{-0.2cm}
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:F}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{F},xrightmargin=10cm]
\begin{kblock}
% generic coordinate reference points
%\kJumpCS[$(0,0)$]{i}
\kJumpCS{i}
\kJumpCSRight[-0.5cm]{i}{iR}{0cm}{3}
\kJumpCSLeft[-0.5cm]{i}{iL}{0cm}{9}
\kJumpCSAbove[-0.5cm]{i}{iA}{0cm}{12}
\kJumpCSBelow[-0.5cm]{i}{iB}{0cm}{6}

% blks
\kTFBelow[]{iB}{tfb1}{\kmT{\mathcal{K}(\cdot)}}
\kTFBelow[]{tfb1}{tfb2}{\kmT{\mathcal{P}(s)}}

% links
\kInLeftM[0cm]{tfb1}{inR}{$r$}{0.05cm}{6}
\kMarkNodeLeft{0cm}{0cm}{}{tfb2}{ny}
\kOutLeft[-0.5cm]{ny}{outY}{$y$}{0cm}
\kLinkn[]{ny}{tfb2}
\kLinkVH[$y$]{ny}{tfb1}{-0.1cm}{0cm}{2}{}
\kLinkHVHRight[0.6cm]{$u$}{tfb1}{tfb2}{0cm}{0cm}

% covers
\kCoverRect[magenta!5!red]{tfb2}
{0.1cm}{0.1cm}{0.3cm}{0.3cm}
\kCoverTextBelow{0cm}{0cm}{txt1}
{physical system (e.g: a dc motor)};
%
\kCoverRect[green!75!blue!80!]{tfb1}
{0.1cm}{0.1cm}{0.2cm}{0.2cm}
\kCoverTextAbove{0cm}{0cm}{txt2}
{computing system (embedded control algorithm)};
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:G}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{G},xrightmargin=10cm]
\centering

\begin{kblock}
\kJumpCS{R}

% blks
\kTFRight{R}{tfb1}{$\bm{P}$}
\kTFBelow{tfb1}{tfb2}{$\bm{C}$}

% links
\kInLeftM[0cm]{tfb1}{inW}{$w$}{0.05cm}{2}
\kInLeftM[0cm]{tfb2}{inR}{$r$}{-0.05cm}{5}
\kOutRight[0cm]{tfb1}{outZ}{$z$}{0.05cm}
\kOutRight[0cm]{tfb2}{outV}{$v$}{-0.05cm}
\kLinkHVHRight[0.6cm]{$y$}{tfb1}{tfb2}{-0.1cm}{0.1cm}
\kLinkHVHLeft[0.6cm]{$u$}{tfb2}{tfb1}{0.1cm}{-0.1cm}

% covers
\kCoverRect[blue!50!]{tfb1}
{0.1cm}{0.1cm}{0.3cm}{0.3cm}
\kCoverTextAbove{0cm}{0cm}{txt1}{Physical System};
%
\kCoverRect[red]{tfb2}
{0.1cm}{0.1cm}{0.3cm}{0.3cm}
\kCoverTextBelow{0cm}{0cm}{txt2}{Computing System};
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:H}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{H},xrightmargin=10cm]
% Description: Closed PID-loop
\centering
\begin{kblock}
% global ref point
\kJumpCS{SRef}

%% blocks
\kTFAbove[5cm]{SRef}{tfD}{\kmT{D}}
\kMarkNodeLeft{0.1cm}{0cm}{}{tfD}{yin}
\kPlusMinusDownPlaceAbove{yin}{S1}{0cm}
\kTFAbove[]{tfD}{tfA}{\kmT{A}}
\kTFAbove[]{tfA}{tfB}{\kmT{B}}
\kPlusPlusMinus{tfA}{S2}{0cm}
\kTFRight[0.5cm]{S2}{tfP}{\kmT{\mathcal{P}(s)}}

%% other nodes-paths
\kMarkNodeRight{0cm}{0cm}{}{tfP}{ycut}
\kInLeft[0.1cm]{S1}{rin}{$r$}{0cm}
\kOutRight[0.1cm]{ycut}{yout}{$y^*$}{0cm}
\kMarkNodeRight{-0.4cm}{0cm}{}{rin}{rcut}
	
%% links
\kLink[$e$]{S1}{tfA}
\kLinkVH[]{rcut}{tfB}{0cm}{0cm}{0}{}
\kLink[]{tfA}{S2}
\kLinkHV[]{tfB}{S2}{0cm}{0cm}{0}{}
\kLink[$u^*$]{S2}{tfP}
\kLinkHV[]{tfD}{S2}{0cm}{0cm}{0}{}
\kLinkn[]{tfP}{ycut}
\kLinknVHHVBelow[1.2cm]{}{ycut}{yin}{0cm}{0cm}
\kLink[]{yin}{tfD}
\kLink[]{yin}{S1}	
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:I}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{I},xrightmargin=10cm]
% Description: Closed PID-loop
\centering
\begin{kblock}
% global ref point
\kJumpCS{SRef}

%% blocks

\kTFAbove[]{SRef}{tfA}{\kmT{A}}
\kPlusMinusDownL{tfA}{S1}{0cm}
\kTFAbove[]{tfA}{tfB}{\kmT{B}}
\kPlusPlusMinus{tfA}{S2}{0cm}
\kTFRight[0.5cm]{S2}{tfP}{\kmT{\mathcal{P}(s)}}
\kTFBelow[0cm]{tfP}{tfD}{\kmT{D}}
\kMarkNodeRight{0cm}{0cm}{}{tfP}{ycut}
\kMarkNodeBelow{0cm}{0cm}{}{ycut}{yin}
\kInLeftM[0.1cm]{S1}{rin}{$r$}{0cm}{0}
\kOutRight[0.1cm]{ycut}{yout}{$y^*$}{0cm}
\kMarkNodeRight{-0.4cm}{0cm}{}{rin}{rcut}

%% links
\kLink[$e$]{S1}{tfA}
\kLinkVH[]{rcut}{tfB}{0cm}{0cm}{0}{}
\kLink[]{tfA}{S2}
\kLinkHV[]{tfB}{S2}{0cm}{0cm}{0}{}
\kLink[$u^*$]{S2}{tfP}
\kLinkHV[]{tfD}{S2}{0cm}{0cm}{0}{}
\kLinkn[]{tfP}{ycut}
\kLinkn[]{ycut}{yin}
\kLinknVHHVBelow[0.5cm]{}{yin}{S1}{0cm}{0cm}
\kLink[]{yin}{tfD}	
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:J}
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{J},xrightmargin=10cm]
% Description: Anon
\centering
\begin{kblock}
% global ref point
\kJumpCS{o}
	
%% blocks
\kTFAbove[0cm]{o}{tfi}{\kmT{f_i(\cdot)}}
\kTFAbove[0.5cm]{tfi}{tfd}{\kmT{f_d(\cdot)}}
\kTFAbove[0.5cm]{tfd}{tfp}{\kmT{f_p(\cdot)}}

%% links
\kInUpM[0cm]{tfp}{inu}{$u$}{0cm}{0}
\kOutRight[0.3cm]{tfp}{kp}{$K_p$}{0cm}
\kOutRight[0.3cm]{tfi}{ki}{$K_i$}{0cm}
\kOutRight[0.3cm]{tfd}{kd}{$K_d$}{0cm}
\kInLeftM[0cm]{tfd}{inwn}{$\omega_n$}{0cm}{6}
\kInLeftM[0cm]{tfp}{iny}{$y$}{0.15cm}{6}
\kInLeftM[0cm]{tfp}{inym}{$y_m$}{-0.15cm}{4}
\kMarkNodeLeft{-0.35cm}{0cm}{}{kp}{kpcut}
\kLinkVH[$\lambda$]{kpcut}{tfd}{0.2cm}{0cm}{2}{kpcutb}
\kLinkVH[]{kpcutb}{tfi}{0.2cm}{0cm}{0}{}
\kMarkNodeRight{-0.8cm}{0cm}{}{inwn}{wncut}
\kLinkVH[]{wncut}{tfi}{0cm}{0cm}{0}{}
\end{kblock}
\end{SideBySideExample}

\subsection{Ex:K}
\spacetweak
\begin{SideBySideExample}[label=\fbox{K},xrightmargin=10cm]
% DESCRIPTION: CPLMFC-Algorithm
\begin{kblock}
% global ref point
\kJumpCS{SRef}
%% blocks
% place TF_fts right of global ref.
\kTFRight[4cm]{SRef}{TF_fts}{ \kmTw{f_\mathrm{t_s}} }
% place TF_mfc at h cm above TF_fts
\kTFAbove[0.3cm]{TF_fts}{TF_mfc}{ \kmT{f_\mathrm{MFC}} }
\kTFAbove[0.3cm]{TF_mfc}{TF_pid}{ \kmT{f_\mathrm{PID}} }
\kTFRight[3cm]{TF_mfc}{TF_sys}{ \kmTw{ \mathcal{P} } }

%% nodes and links
% mark visible node N1 right of TF_mfc
\kMarkNodeRight{0.6cm}{0cm}{}{TF_mfc}{N1}
\kMarkNodeBelow{-0.8cm}{0cm}{}{N1}{N2}
\kMarkNodeRight{-0.6cm}{0cm}{}{N1}{N3}
\kMarkNodeRight{0cm}{}{}{TF_sys}{N4}
% extend node-path outwards
\kOutRight[0.1cm]{N4}{Y1}{$y^*$}{0cm}
\kMarkNodeLeft{0.3cm}{0cm}{}{TF_fts}{N5}
\kMarkNodeLeft{0.3cm}{-0.12cm}{}{TF_mfc}{N6}
\kInLeft[0.12cm]{TF_pid}{R1}{$r$}{-0.12cm}
\kMarkNodeLeft{0cm}{-0.12cm}{}{TF_pid}{N7}
% link TF_sys to N4
\kLinkn[]{TF_sys}{N4}
\kLink[$u^*$]{N3}{TF_sys}
\kLink[]{N1}{TF_mfc}
\kLinkHV[]{TF_fts}{N2}{0cm}{0cm}{0}{}
% HV link from TF_pid to N1
%\kLinkHV[]{$(TF_pid.east) + (0,0cm)$}{N1}{0cm}{0cm}{0}{}
\kLinkHV[]{TF_pid}{N1}{0cm}{0cm}{0}{}
% link N1 to N3
%\kLink[]{N1}{N3}
% link N2 to N3
\kLink[]{N2}{N3}
% VHHV feedback link from N4 to N5
\kLinknVHHVBelow[1.5cm]{}{N4}{N5}{0cm}{0cm}
\kLink[]{N5}{TF_fts}
\kLink[]{N6}{$(TF_mfc.west) + (0,-0.12cm)$}
% arrowless link N5 and N6
\kLinkn[]{N5}{N6}
\kLinkVH[]{N6}{TF_pid}{0.12cm}{0cm}{0}{}
\kLinkVH[]{N7}{TF_mfc}{0.12cm}{0cm}{0}{}
%% vector links
% link from inside TF_fts to TF_mfc
\kVecLink[$$]{TF_fts}{TF_mfc}
% link from inside TF_mfc to TF_pid
%\kVecLink[$$]{TF_mfc}{TF_pid}
\kVecLink[$$]{$(TF_mfc.north) + (-0.15cm,0cm)$}
{$(TF_pid.south) + (-0.15cm,0cm)$}
% link from inside TF_pid to TF_mfc
\kVecLink[$$]{$(TF_pid.south) + (0.15cm,0cm)$}
{$(TF_mfc.north) + (0.15cm,0cm)$}

%% cover-sectioning
\kCoverRect[gray]{TF_mfc}
{1.8cm}{1.8cm}{1.5cm}{1.6cm}
\kCoverTextAbove{0cm}{0cm}{CT1}{CPLMFC Algorithm};%

\end{kblock}
\end{SideBySideExample}
% \kLinkVH[$\bm{\omega_n}$]{T3}{T1}{0cm}{0cm}{0}{}
%
% \kVecLinkVH[$\bm{\kappa_{pid}}$]{T2}{T3}{0.1cm}{-0.1cm}{8}
% \kVecLinkHV[$\bm{\kappa_{pid,\lambda_{id}}}$]{T3}{T2}{-0.1cm}{0.1cm}{1}
% \kVecInUp[-0.3cm]{T3}{TS2}{$\bm{t_s,\tau_l}$}{0.5cm}

\subsection{Ex:L}\spacetweak\spacetweak
\spacetweak\spacetweak
\begin{SideBySideExample}[label=\fbox{L},xrightmargin=10cm]
\begin{kblock}
\kJumpCS{fspt}

% blks
\kTFBelow[0.5cm]{fspt}{plt}{\kmT{P(s)}}
\kTFBelow[0cm]{plt}{pidcm}{
\textbf{PID closed-loop model}\\
$
\begin{array}{c}
	\bm{\dot{x}_m=\mathcal{S}({x_m},{r})}
\end{array}
$
}
\kTFBelow[0.33cm]{pidcm}{tscalc}
{\kmT{f_{\omega_n}(\cdot)}}
\kTFBelow[0.33cm]{tscalc}{fis}{\kmT{f_{x_s}(\cdot)}}
\kTFBelow[0.2cm]{fis}{pid}{
\textbf{PID Control Law}\\
\kmT{u = f_{pid}(\cdot)}
}
\kTFRight[2.5cm]{tscalc}{obs}{
\textbf{State Observer}\\
$
\begin{array}{c}
	\bm{\hat{\dot{x}}=\mathcal{S}(\hat{x},{r})}\\
\end{array}
$
}

% links
\kInDown[-0.4cm]{pid}{cp}{\kmT{\lambda_p}}{-0.6cm}
\kInDown[-0.4cm]{pid}{ci}{\kmT{\lambda_i}}{0.6cm}
\kInDown[-0.2cm]{pid}{cd}{\kmT{\lambda_d}}{0cm}
\kLinkHVHLeft[2cm]{\kmT{u}}{pid}{plt}{0cm}{0cm}{}
\kLinkHV[\kmT{y}]{plt}{obs}{0cm}{0cm}{1}{}
\kLinkVH[\kmT{\hat{x}}]{obs}{pid}{-0.1cm}{0cm}{3}{}
\kLinkHVHRight[]{\kmT{{x}_m}}{pidcm}{pid}{0cm}{0.1cm}
\kLink[$\bm{\omega_n}$]{tscalc}{pidcm}
\kLink[$\bm{x_s}$]{fis}{tscalc}
\kLink[$\bm{b,c}$]{pid}{fis}
\kMarkNodeAbove{-0.5cm}{0cm}{}{tscalc}{mkwn}
\kLinkHV[]{mkwn}{pid}{0cm}{1cm}{0cm}{}
\kMarkNodeAbove{-0.5cm}{0cm}{}{fis}{mkxts}
\kLinkHV[]{mkxts}{pid}{0cm}{0.8cm}{0}{}
\kInLeftM[0cm]{pidcm}{rin}{$\bm{r}$}{-0.15cm}{3}
\kOutLeft[0cm]{pidcm}{umout}{$\bm{u_m}$}{0.15cm}
\kInLeftM[0.2cm]{tscalc}{tsl}{$\bm{t_s,t_l}$}{0cm}{6}
\kMarkNodeRight{-0.84cm}{0cm}{}{tsl}{mktsl}
\kLinkVH[]{mktsl}{pid}{0.15cm}{0cm}{0}{}
\kMarkNodeBelow{0cm}{0cm}{}{obs}{mkxhat}
\kLinkHV[]{mkxhat}{obs}{0cm}{-0.5cm}{0}{}
\end{kblock}
\end{SideBySideExample}

\pagebreak
%% API
\spacetweak\spacetweak
\section{\kblocks{} API}
\bfseries TODO ...
%\begin{apilist}
%\cvhd{Place an invisible Node at origin, as reference point}
%\begin{cvl}
%\kJumpCS{current coordinate label}
%\end{cvl}
%
%\cvhd{Place Node with variable x-y coordinate shift}
%\begin{cvl}
%\kMarkNodeLeft{node x distance shift}{node y distance shift}
%{node text-label}{from node label}{to node or current node label}
%
%\kMarkNodeRight{node x distance shift}{node y distance shift}
%{node text-label}{from node label}{to node or current node label}
%
%\kMarkNodeAbove{node x distance shift}{node y distance shift}
%{node text-label}{from node label}{to node or current node label}
%
%\kMarkNodeBelow{node x distance shift}{node y distance shift}
%{node text-label}{from node label}{to node or current node label}
%\end{cvl}
%	
%\cvhd{Place a Node at a specific coordinate}
%\begin{cvl}
%\kMarkNode{optional x distance shift}{optional y distance shift}
%{node label}{current node coordinate}
%\end{cvl}
%
%\cvhd{Arithmetic Summer Blocks}
%\begin{cvl}
%\kPlusPlusMinus{from node label}{to current sum node label}
%{optional horizontal position shift}
%\end{cvl}
%
%\cvhd{Transfer-Function block}
%\begin{cvl}
%\kTFRight[optional shift dimension]{from node label}
%{to current tf node label}{tf text content}
%\end{cvl}
%
%\cvhd{Scalar Link (arrowed) and Linkn (no arrow)}
%\begin{cvl}
%\kLink[optional signal label]{from node label}{to node label}
%
%\kLinkn[optional signal label]{from node label}{to node label}
%\end{cvl}
%
%
%\cvhd{Output Link from a node point}
%\begin{cvl}
%\kOutRight[optional distance shift]{from node label}
%{to current node label}{out signal label}{direction shift}
%\end{cvl}
%
%
%\cvhd{Scalar Link Full Feedback/FeedForward Vertical (Up or Down) to Horizontal (Right or Left) to Vertical (Up or Down)}
%\begin{cvl}
%\kLinkVHHVBelow[optional link shift]{unity link label}
%{from node{to node}{from node direction shift}{to node direction shift}
%
%\kLinkVHHVAbove[optional link shift]{unity link label}
%{from node}{to node}{from node direction shift}{to node direction shift}
%\end{cvl}
%
%
%
%
%\end{apilist}
\spacetweak\spacetweak




\end{document}
