I want to add a bullet next to a line number as shown in following picture. How can I get this.
Asked
Active
Viewed 471 times
2
NAASI
- 2,809
1 Answers
4
I just copied some sample code, used this answer simplify the usage and loaded tikzpagenodes to be able to place the star outside the text area to arrive at
\documentclass{article}
\usepackage[ruled,linesnumbered]{algorithm2e}
\usepackage{tikzpagenodes}
\usetikzlibrary{shapes.geometric,tikzmark}
\newcounter{tmkcount}
\tikzset{use tikzmark/.style={
remember picture,
overlay,
execute at end picture={
\stepcounter{tmkcount}
},
},
tikzmark suffix={-\thetmkcount}
}
\begin{document}
\begin{algorithm}[ht]
\SetAlgoLined % from https://tex.stackexchange.com/a/359622/121799
\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
\tikzmark{star}go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
\begin{tikzpicture}[use tikzmark]
\path (pic cs:star) coordinate (aux)
(current page text area.west|-aux)
node[anchor=east,star,star point ratio=2,draw,fill=yellow,inner sep=.2em,
yshift=.2em]{};
\end{tikzpicture}
\end{document}


tikzmarklibrary. If you cannot create it yourself, some dummy code to get us started would be appreciated. – Apr 30 '19 at 21:19