Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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)

share|improve this question

1 Answer 1

up vote 7 down vote accepted

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}
share|improve this answer
    
@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
    
@Hendrik The only thing missing from Yiannis's answer is the line \SetAlgoVlined (or \SetAlgoLined depending on the style you want.) –  Alan Munn Jan 14 '11 at 16:07
    
@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

Your Answer

 
discard

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.