2

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?

3
  • Do you want syntax highlighting?
    – N.N.
    Commented Jul 5, 2011 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? Commented Jul 5, 2011 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.
    Commented Jul 5, 2011 at 16:34

1 Answer 1

2

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}

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .