我有一个很长的列表。它是运行 Python 脚本获得的结果。如下所示
[[0, [[38], [65]]]
[0, [[39], [6]]]
[0, [[40], [67]]]
[0, [[41], [68]]]
[0, [[42], [69]]]
[1, [[43], [70]]]
[1, [[44], [71]]]
[0, [[50], [77]]]
[0, [[51], [78]]]
[0, [[52], [79]]]
[1, [[53], [80]]]
[0, [[12], [54]]]
[1, [[13], [55]]]
[1, [[14], [56]]]
[0, [[57]]]
[1, [[58]]]
[0, [[59]]]
[0, [[60]]]
[0, [[61]]]
[1, [[1, 2], [69]]]
[0, [[1], [2, 3], [70]]]
[1, [[2], [3, 4], [71]]]
[1, [[3], [4, 5], [15], [72]]]
[1, [[4], [5, 6], [16], [73]]]
[0, [[5], [6, 7], [17], [74]]]]
我是 Latex 的新手,我想将这些内容写在论文中作为结果的一部分。拆分页面并不能给我带来理想的结果,因为对于其他示例,元素会变得更长并且会消失。
是否有一种动态技术可以用来有效地添加此类列表,即在同一行中添加较短的元素,在下一行中添加较长的元素,而无需针对每种情况都这样做?
也欢迎提出有关如何合并此类列表的其他建议。
答案1
]
最后好像少了一个?
这样允许换行,之后]
的嵌套不会超过一层。
以上内容是在文档末尾进行的,也许在注释之后你想要输出如下内容
在顶层条目强制换行,并允许在(未显示的)较长的条目中换行,在这种情况下你需要
\begin{flushleft}
\rightskip0pt
\catcode`\[=13
\catcode`\]=13
\def[{\advance\bdepth1 \ifnum\bdepth=2 \hfill\mbox{}\linebreak\fi\lbrack}
\def]{\ifnum\bdepth=1 \hfill\mbox{}\linebreak\fi\rbrack\advance\bdepth-1
\ifnum\bdepth=2\penalty-900 \fi\ignorespaces}
$
原始文件:
\documentclass{article}
\newcount\bdepth
\errorcontextlines1000
\begin{document}
\begin{flushleft}
\catcode`\[=13
\catcode`\]=13
\def[{\advance\bdepth1 \lbrack}
\def]{\rbrack\advance\bdepth-1
\ifnum\bdepth<2 \penalty0 \;\fi}
$
[[0, [[38], [65]]]
[0, [[39], [6]]]
[0, [[40], [67]]]
[0, [[41], [68]]]
[0, [[42], [69]]]
[1, [[43], [70]]]
[1, [[44], [71]]]
[0, [[50], [77]]]
[0, [[51], [78]]]
[0, [[52], [79]]]
[1, [[53], [80]]]
[0, [[12], [54]]]
[1, [[13], [55]]]
[1, [[14], [56]]]
[0, [[57]]]
[1, [[58]]]
[0, [[59]]]
[0, [[60]]]
[0, [[61]]]
[1, [[1, 2], [69]]]
[0, [[1], [2, 3], [70]]]
[1, [[2], [3, 4], [71]]]
[1, [[3], [4, 5], [15], [72]]]
[1, [[4], [5, 6], [16], [73]]]
[0, [[5], [6, 7], [17], [74]]]
]%missing?
$
\end{flushleft}
\end{document}