7

How can I visualize code indentation? What I want is to draw a vertical line along the indentation. Since an example is easier to show then to explain you can see one in this paper (on page 2)

7

Use the "algorithm2e" package a short example is shown below:

\documentclass{article}
\usepackage{algorithm2e}
\begin{document}
\SetAlgoLined
\begin{procedure}
\Switch{the value of T}{
  \uCase{a value}{
    do this\;
    do that\;
  }
  \lCase{another value}{one line}\;
  \Case{last value}{
    do this\;
    break\;
  }
  \Other{
    for the other values\;
    do that\;
  }
}
\end{procedure}
\end{document}
  • @Yiannis: Did you read the question? It clearly says "What I want is to draw a vertical line along the indentation." – Hendrik Vogt Jan 14 '11 at 12:52
  • @Hendrik I read the part ..."you can see one in this paper (on page 2)", that clearly shows code that was typeset with alogorithm2e. How did you understand it? – Yiannis Lazarides Jan 14 '11 at 14:25
  • @Yiannis: On page 2, I see that there are vertical lines along the indentation. And the OP asks how to reproduce that. – Hendrik Vogt Jan 14 '11 at 14:47
  • 1
    @Alan: Well, then that's the essential thing missing. From how I read the question, this was the only thing the OP wanted to know. But: Thanks for the info; maybe you want to post a separate answer, or Yiannis edits his answer. – Hendrik Vogt Jan 14 '11 at 16:13
  • 1
    Thanks, Yiannis. One point for users with older installations: In previous versions of algorithms2e it was \SetLine, not \SetAlgoLined. – Hendrik Vogt Jan 14 '11 at 17:37

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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