TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

Say I have algorithm appear as followed

enter image description here

Is it possible to reference the line number using ~\ref or any other possiblities?

share|improve this question
You have accepted 50% of your answered questions. All your questions are excellent answered. We don't put any thanks in our question but you should thank users by upvoting [his/her] answer (with the upward pointing arrow to the left of it). Some users are ignoring questions where the OP has such an accepting rate. I am one of them. – Marco Daniel Aug 7 '12 at 19:03
up vote 14 down vote accepted

Yes, it's possible. :)Use the normal \label command in the line you want to refer (page 4 of the algorithm2e manual), then use \ref to display the line number.




Line \ref{alg:goto} is important.


\KwData{this text}
\KwResult{how to write algorithm with \LaTeX2e }
\While{not at end of this document}{
read current\;
go to next section\;\label{alg:goto}
current section becomes this one\;
go back to the beginning of current section\;


The output:

Line 5

share|improve this answer

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.