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.

I would like to write something in LaTeX, where I need nested lists. It should be displayed like this:

segment = [
             [ [0,1,0],[1,1,1],[0,1,0] ]
             [ [1,1,1],[1,1,1],[1,1,1] ]
             [ [0,0,1],[1,0,0],[0,0,0] ]
           ]

How can I do this in LaTeX?

share|improve this question
    
Do you want syntax highlighting? –  N.N. Jul 5 '11 at 15:34
    
No, thats not needed. Thanks for your answer, its a perfect solution to my problem. I didn't \usepackage{verbatim}, though it worked. Do you know why? –  moose Jul 5 '11 at 16:30
    
It's probably loaded by one of the other packages you are using. If you want syntax highlighting it's not hard to achieve. Checkout tex.stackexchange.com/questions/867/syntax-coloring-in-latex –  N.N. Jul 5 '11 at 16:34

1 Answer 1

up vote 2 down vote accepted

You can enclose whatever you want displayed in the environment verbatim of the verbatim package and it will preserve spaces. Here's an example:

\documentclass{article}

\usepackage{verbatim}

\begin{document}

\begin{verbatim}
segment = [
             [ [0,1,0],[1,1,1],[0,1,0] ]
             [ [1,1,1],[1,1,1],[1,1,1] ]
             [ [0,0,1],[1,0,0],[0,0,0] ]
           ]
\end{verbatim}

\end{document}
share|improve this answer

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.