In the example you've given, this text
is completely unformatted, and it's best to use it as-is in your text. However, components of an algorithm
are styled using various macros:
\DataSty{<stuff>}
Used to set data (default is \textsf
):

\ArgSty{<stuff>}
Used to set arguments (to functions; default is \textit
):

\KwSty{<stuff>}
Used to prefix input parameters for an algorithm (default is \textbf
):

\FuncSty{<stuff>}
Formatting of a function name (default is \texttt
):

\CommentSty{<stuff>}
Formatting of comments (default is \texttt
):

\TitleSty{<stuff>}
Used to set the title of the algorithm via \TitleOfAlgo
(default is regular text):

...
I would use the appropriate style in the text as well, like in the following example:

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\SetKwData{matrixinput}{some matrix}%
\begin{algorithm}[H]
\KwIn{\matrixinput}
\KwResult{how to write algorithm with \LaTeX2e }
initialization\;
\While{not at end of this document}{
read current\;
\eIf{understand}{
go to next section\;
current section becomes this one\;
}{
go back to the beginning of current section\;
}
}
\caption{How to write algorithms}
\end{algorithm}
We use \matrixinput as input.
\end{document}
The input \matrixinput
is defined outside the algorithm
environment in order to make it usable outside of that scope (without your text).
\KwData
outside thealgorithm
environment.\label
...\ref
. But I'm not sure whether this is what you're after. So I was asking about what you exactly want in return (say,this text
) for this "reference" (if that's what you're after). The Data: is formatted using\KwSty
, butthis text
is formatting as regular text.