4

I need to put a very long list of lists into LaTeX, hopefully with automatic formatting. For example I have the following list:

\{\{7, 2, 6, 5\}, \{7, 2, 6, 6\}, \{7, 3, 1, 1\}, \{7, 3, 1, 3\},
\{7, 3, 1, 6\}, \{7, 3, 2, 2\}, \{7, 3, 2, 3\}, \{7, 3, 2, 4\}, \{7,
3, 3, 1\}, \{7, 3, 3, 2\}, \{7, 3, 3, 3\}, \{7, 3, 3, 4\}, \{7, 3,
3, 5\}, \{7, 3, 3, 6\}, \{7, 3, 4, 2\}, \{7, 3, 4, 3\}, \{7, 3, 4,
4\}, \{7, 3, 4, 5\}, \{7, 3, 5, 3\}, \{7, 3, 5, 4\}, \{7, 3, 5, 5\},
\{7, 3, 5, 6\}, \{7, 3, 6, 1\}, \{7, 3, 6, 3\}, \{7, 3, 6, 5\}, \{7,
3, 6, 6\}, \{7, 4, 1, 1\}, \{7, 4, 1, 2\}, \{7, 4, 1, 4\}, \{7, 4,
1, 6\}, \{7, 4, 2, 1\}, \{7, 4, 2, 2\}, \{7, 4, 2, 3\}, \{7, 4, 2,
4\}, \{7, 4, 3, 2\}, \{7, 4, 3, 3\}, \{7, 4, 3, 4\}, \{7, 4, 3, 5\},
\{7, 4, 4, 1\}, \{7, 4, 4, 2\}, \{7, 4, 4, 3\}, \{7, 4, 4, 4\}, \{7,
4, 4, 5\}, \{7, 4, 4, 6\}, \{7, 4, 5, 3\}, \{7, 4, 5, 4\}, \{7, 4,
5, 5\}, \{7, 4, 6, 1\}, \{7, 4, 6, 4\}, \{7, 4, 6, 6\}, \{7, 5, 1,
1\}, \{7, 5, 1, 2\}, \{7, 5, 1, 5\}, \{7, 5, 2, 1\}, \{7, 5, 2, 2\},
\{7, 5, 2, 5\}, \{7, 5, 2, 6\}, \{7, 5, 3, 3\}, \{7, 5, 3, 4\}, \{7,
5, 3, 5\}, \{7, 5, 3, 6\}, \{7, 5, 4, 3\}, \{7, 5, 4, 4\}, \{7, 5,
4, 5\}, \{7, 5, 5, 1\}, \{7, 5, 5, 2\}, \{7, 5, 5, 3\}, \{7, 5, 5,
4\}, \{7, 5, 5, 5\}, \{7, 5, 5, 6\}, \{7, 5, 6, 2\}, \{7, 5, 6, 3\},
\{7, 5, 6, 5\}, \{7, 5, 6, 6\}, \{7, 6, 1, 1\}, \{7, 6, 1, 3\}, \{7,
6, 1, 4\}, \{7, 6, 1, 6\}, \{7, 6, 2, 2\}, \{7, 6, 2, 5\}, \{7, 6,
2, 6\}, \{7, 6, 3, 1\}, \{7, 6, 3, 3\}, \{7, 6, 3, 5\}, \{7, 6, 3,
6\}, \{7, 6, 4, 1\}, \{7, 6, 4, 4\}, \{7, 6, 4, 6\}, \{7, 6, 5, 2\},
\{7, 6, 5, 3\}, \{7, 6, 5, 5\}, \{7, 6, 5, 6\}, \{7, 6, 6, 1\}, \{7,
6, 6, 2\}, \{7, 6, 6, 3\}, \{7, 6, 6, 4\},\{7, 6, 6, 5\}, \{7, 6,
6, 6\}\}

Note that this is only a fraction of the whole list. Is there a package that I'm overlooking? I couldn't seem to get the listings package to work and I would prefer to not have to use multline or align* for this as I would have to count and put \\ for every line break. Any ideas?

  • Welcome to TeX.SE! Please provide a bit more information as to how this list should be formatted. E.g., should there be 3, 4, 5, 6 (or some other number) groups of four numbers per line? – Mico Apr 2 '14 at 21:45
3

enter image description here

\documentclass{article}
\newcommand\z{,\linebreak[0]}
\begin{document}

\begin{raggedright}
$\{7, 2, 6, 5\}\z \{7, 2, 6, 6\}\z \{7, 3, 1, 1\}\z \{7, 3, 1, 3\}\z
\{7, 3, 1, 6\}\z \{7, 3, 2, 2\}\z \{7, 3, 2, 3\}\z \{7, 3, 2, 4\}\z
\{7, 3, 3, 1\}\z \{7, 3, 3, 2\}\z \{7, 3, 3, 3\}\z \{7, 3, 3, 4\}\z
\{7, 3, 3, 5\}\z \{7, 3, 3, 6\}\z \{7, 3, 4, 2\}\z \{7, 3, 4, 3\}\z
\{7, 3, 4, 4\}\z \{7, 3, 4, 5\}\z \{7, 3, 5, 3\}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\z \{7, 6, 3, 3\}\z \{7, 6, 3, 5\}\z
\{7, 6, 3, 6\}\z \{7, 6, 4, 1\}\z \{7, 6, 4, 4\}\z \{7, 6, 4, 6\}\z
\{7, 6, 5, 2\}\z \{7, 6, 5, 3\}\z \{7, 6, 5, 5\}\z \{7, 6, 5, 6\}\z
\{7, 6, 6, 1\}\z \{7, 6, 6, 2\}\z \{7, 6, 6, 3\}\z \{7, 6, 6, 4\}\z
\{7, 6, 6, 5\}\z \{7, 6, 6, 6\}\}$
\end{raggedright}

\end{document}
  • you forgot the left-hand brace at the very beginning. too bad, adding it will mess up the pretty (but totally "accidental") alignment. – barbara beeton Apr 2 '14 at 22:16
  • @barbarabeeton oops \llap? :-) – David Carlisle Apr 2 '14 at 23:25
  • sure, but precede it by \noindent or \leavevmode. – barbara beeton Apr 3 '14 at 2:17
3

You can simplify the input syntax and also get centering (but the list can't be split across pages):

\documentclass{article}
\usepackage{xparse,lipsum,varwidth}

\ExplSyntaxOn
\NewDocumentCommand{\printbiglist}{m}
 {
  \[
  \begin{varwidth}{.8\textwidth}\raggedright 
  $\makebox[0pt][r]{$\lbrace$} % the opening brace hanging left
  \dan_print_biglist:n { #1 }
  \makebox[0pt][l]{$\rbrace$}$ % the closing brace hanging right
  \end{varwidth}
  \]
 }

\seq_new:N \l_dan_biglist_seq

\cs_new_protected:Npn \dan_print_biglist:n #1
 {
  \seq_set_split:Nnn \l_dan_biglist_seq { , } { #1 }
  \{ \seq_use:Nn \l_dan_biglist_seq { \},\linebreak[0]\{ } \}
 }

\ExplSyntaxOff

\begin{document}

\lipsum*[3]
\printbiglist{
  {7, 2, 6, 5}, {7, 2, 6, 6}, {7, 3, 1, 1}, {7, 3, 1, 3},
  {7, 3, 1, 6}, {7, 3, 2, 2}, {7, 3, 2, 3}, {7, 3, 2, 4},
  {7, 3, 3, 1}, {7, 3, 3, 2}, {7, 3, 3, 3}, {7, 3, 3, 4},
  {7, 3, 3, 5}, {7, 3, 3, 6}, {7, 3, 4,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  {7, 6, 6, 1}, {7, 6, 6, 2}, {7, 6, 6, 3}, {7, 6, 6, 4},
  {7, 6, 6, 5}, {7, 6, 6, 6}
}
\lipsum[3]

\end{document}

enter image description here

If you don't care about centering and need instead that the big list is broken across pages, change the definition of the main command into

\NewDocumentCommand{\printbiglist}{m}
 {
  \begin{quote}\raggedright 
  $\makebox[0pt][r]{$\lbrace$} % the opening brace hanging left
  \dan_print_biglist:n { #1 }
  \makebox[0pt][l]{$\rbrace$}$ % the closing brace hanging right
  \end{quote}
 }

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.