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?

  • 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? – Martin Thoma 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
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}

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.