为什么尽管事实并非如此,但节itemize
内的一个节却会出现问题?minipage
Something's wrong--perhaps a missing \item
最小示例:
\documentclass{article}
\begin{document}
\begin{minipage}[c]{0.35\textwidth}
\begin{itemize}[nosep]
\item my first item
\end{itemize}
\end{minipage}\hfill
\begin{minipage}[c]{0.65\textwidth}
\end{minipage}
\end{document}
结果:
This is LuaTeX, Version 1.10.0 (TeX Live 2019 Gentoo Linux)
restricted system commands enabled.
(./test.tex
LaTeX2e <2018-12-01>
luaotfload | main : initialization completed in 0.073 seconds
(/usr/share/texmf-dist/tex/latex/base/article.cls
Document Class: article 2018/09/03 v1.4i Standard LaTeX document class
(/usr/share/texmf-dist/tex/latex/base/size10.clo)) (./test.aux)
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.6 \item m
y first item
? X
545 words of node memory still in use:
3 hlist, 1 rule, 2 local_par, 2 dir, 1 glue, 3 kern, 8 glyph, 4 attribute, 6
1 glue_spec, 4 attribute_list, 3 temp, 4 if_stack, 1 shape, 1 write nodes
avail lists: 3:2,4:1,7:1,9:1
warning (pdf backend): no pages of output.
Transcript written on test.log.
答案1
您遇到的错误也可能由以下代码产生:
\documentclass{article}
\begin{document}
\begin{itemize}[nosep]
\item my first item
\end{itemize}
\end{document}
正如您已经发现的,错误的真正根源是无法加载包enumitem
。enumitem
包(而不是 LaTeX 内核)定义了可选设置nosep
。
尽管如此,追踪为什么运行上面显示的 MWE 时,LaTeX 会发出以下消息:
! LaTeX Error: Something's wrong--perhaps a missing \item.
See the LaTeX manual or LaTeX Companion for explanation.
Type H <return> for immediate help.
...
l.4 \item m
y first item
?
如果enumitem
包裹不是加载后,LaTeX 要求第一个项目 [双关语]\begin{itemize}
为。因此,由于方括号中的内容在 MWE 中\item
没有语句,LaTeX 会感到困惑并停止并显示一个显然不是特别清晰的错误消息。\item
顺便说一句,如果在 之前立即插入一条\item
指令[nosep]
,即如果将 MWE 更改为
\documentclass{article}
\begin{document}
\begin{itemize}\item[nosep]
\item my first item
\end{itemize}
\end{document}
LaTeX 运行正常,单词“nosep”显示为默认的 1 级标记(恰好是文本项目符号)的替代:
enumitem
最后,正如已经指出的,为了从选项中获得预期的行为,必须加载包[nosep]
。
答案2
加载enumitem
解决问题:
\documentclass{article}
\usepackage{enumitem}
\begin{document}
\begin{minipage}[c]{0.35\textwidth}
\begin{itemize}[nosep]
\item my first item
\end{itemize}
\end{minipage}\hfill
\begin{minipage}[c]{0.65\textwidth}
\end{minipage}
\end{document}