TransWikia.com

write list of list using latex

TeX - LaTeX Asked on December 5, 2021

I want to get something like this

enter image description here

I wrote this code

begin{document}
    begin{center}
        [[0 0 1 ... 0 -1 1]\
        [0 0 -1 ... 0 1 1]\
        [0 -1 0 ... 0 1 0]\
        ...\
        [0 1 0 ... 1 1 0]\
        [1 0 0 ... -1 0 1]\
        [-1 1 1 ... 1 0 0]]
    end{center}
end{document}

but Im getting this

enter image description here

2 Answers

You can use BVerbatim from fancyvrb.

documentclass{article}
usepackage{fancyvrb}

usepackage{lipsum} % just to provide context

begin{document}

lipsum[1][1-6]
[
begin{BVerbatim}
[[0 0 1 ... 0 -1 1]
 [0 0 -1 ... 0 1 1]
 [0 -1 0 ... 0 1 0]
 ...
 [0 1 0 ... 1 1 0]
 [1 0 0 ... -1 0 1]
 [-1 1 1 ... 1 0 0]]
end{BVerbatim}
]
lipsum[1][1-6]

end{document}

Don't indent the contents of BVerbatim. You can use center instead of [...] (which, on the other hand, ensures no page breaks).

enter image description here

Answered by egreg on December 5, 2021

To display code, use the verbatim environment.

documentclass{article}
begin{document}
begin{center}
    begin{minipage}{.6textwidth}
        begin{verbatim}
        [[ 0  0  1 ...  0 -1  1]
         [ 0  0 -1 ...  0  1  1]
         [ 0 -1  0 ...  0  1  0]
         ...
         [ 0  1  0 ...  1  1  0]
         [ 1  0  0 ... -1  0  1]
         [-1  1  1 ...  1  0  0]]
        end{verbatim}
    end{minipage}
end{center}
end{document}

enter image description here

Answered by Henri Menke on December 5, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP