I tried to highlight parts of my pseudocode in algorithm2e with the following answer to a similar question: https://tex.stackexchange.com/a/51590/287916. I copied the code exactly the same and run it, but it doesn't compile with the following error: ! Package tikz Error: Cannot parse this coordinate.See the tikz package documentation for explanation.Type H for immediate help.... \end{frame}
Can anybody help me highlighting "if p<x" in one color and the corresponding "else" part in another one with a box around it?
\usepackage[edges]{forest}
\usepackage{caption}
\usepackage[linesnumbered,noend]{algorithm2e}
\newcommand\mycommfont[1]{\tiny\ttfamily\textcolor{blue}{#1}}
\SetCommentSty{mycommfont}
\SetKw{Or}{or}
\SetKw{And}{and}
\SetKw{Break}{break}
\SetKw{True}{true}
\SetKw{False}{false}
\SetKw{myfor}{for loop}
\begin{document}
%\begin{frame}[fragile]
%\begin{forest}
% for tree={circle, draw,
% minimum size=1.5em,
% inner sep=1pt,
% align=center, top color=white
% },
% for leaves={rectangle},
% my label/.style={label={[font=\scriptsize]south:#1}},
% [, top color=gray, bottom color=gray, minimum size=4mm
% [E
% [ILIG, my label=3]
% [U
% [CH, my label=1]
% [LE, my label=5]]]
% [FLOG, my label=2]
% [GEL
% [BE, my label=7]
% [D, my label=8]]
% [MIT, my label=4]
% [ZU, my label=6]]
%\end{forest}
%\end{frame}
%
%\begin{frame}{TIKZ ARRAYBOX}
% \begin{tikzpicture}
% \pgftransparencygroup
% \nodes{p,a,t,t,e,r,n}
% \endpgftransparencygroup
% \pgfsetstrokeopacity{0.5}
% \pgfsetfillopacity{0.5}
% \pgftransparencygroup
% \nodes{?,?,?,?,?,?}
% \endpgftransparencygroup
% \pgfsetstrokeopacity{.75}
% \pgfsetfillopacity{.75}
% \pgftransparencygroup
% \brckt{1}{6}{0}{size=6}
% \endpgftransparencygroup
% \pgfsetfillopacity{0.5}
% \pgfsetstrokeopacity{0}
% \pgftransparencygroup
% \brckt{7}{12}{0}{free space}
% \endpgftransparencygroup
% \pgfsetstrokeopacity{0.5}
% \pgftransparencygroup
% \brckt{1}{12}{1}{capacity=12}
% \endpgftransparencygroup
% \end{tikzpicture}
%
%
% \begin{tikzpicture}[font=\ttfamily,
%array/.style={matrix of nodes,nodes={draw, minimum size=7mm, fill=green!30},column sep=-\pgflinewidth, row sep=0.5mm, nodes in empty cells,
%row 1/.style={nodes={draw=none, fill=none, minimum size=5mm}},
%row 1 column 1/.style={nodes={draw}}}]
%
%\matrix[array] (array) {
%0 & 1 & 2 & 3 & 4 & 5 & 6 & 7 & 8 & 9\
% & & & & & & & & & \};
%\node[draw, fill=gray, minimum size=4mm] at (array-2-9) (box) {};
%
%\begin{scope}[on background layer]
%\fill[green!10] (array-1-1.north west) rectangle (array-1-10.south east);
%\end{scope}
%
%\draw[<->]([yshift=-3mm]array-2-1.south west) -- node[below] {Array length is 10} ([yshift=-3mm]array-2-10.south east);
%
%\draw (array-1-1.north)--++(90:3mm) node [above] (first) {First index};
%\draw (array-1-10.east)--++(0:3mm) node [right]{Indices};
%\node [align=center, anchor=south] at (array-2-9.north west|-first.south) (8) {Element\ (at index 8)};
%\draw (8)--(box);
%%
%\end{tikzpicture}
%\end{frame}
\begin{frame}
\scalebox{0.5}{
\begin{algorithm}[H]
\SetInd{0.3em}{0.8em}
\DontPrintSemicolon
\KwIn{Compact Suffix Trie T für Text X, Pattern P}
\KwOut{Startindex eines Matchs in X oder "KEIN MATCH"}
$p \gets P.length()$ ;
$j \gets 0$ ;
$v \gets T.root()$;
\Repeat{failed \Or T.isExternal(v)}{
$failed \gets$ \True ;
\ForEach{Kindknoten w von v}{
$i \gets start(w)$;
\If{P[j] = X[i]}
{
$x \gets end(w)-i+1$;
\eIf(\tcp[h]{HIGHLIGHT FROM HERE IN ONE COLOR}){$p \leq x$}{
\eIf{$P[j..j+p-1] = X[i..i+p-1]$}{
\Return{i-j}
}{
\Return{"KEIN MATCH"}
}
}(\tcp[h]{HIGHLIGHT ELSE IN ANOTHER COLOR})
{
\If{$P[j..j+x-1] = X[start(w)..end(w)]$}{
$p \gets p-x$;
$j \gets j+x$;
$v \gets w$;
$failed \gets \False$;
\Break \myfor ;
}
}
}
}
}
\Return{"KEIN MATCH"}
\end{algorithm}}
\end{frame}
\end{document}

