我希望我的新命令即使以多段落或 tikz 图片作为参数也能起作用。
\documentclass{article}
\usepackage{paralist,xparse,calc}
\NewDocumentCommand{\HorsListe}{sO{1}m}{%
\IfBooleanTF{#1}{%
\par\nopagebreak[4]\addvspace{1\itemsep}%
\hspace{-#2\leftmargin}}{%
\par\nopagebreak[4]\addvspace{2\itemsep}%
\hspace{-#2\leftmargin}}%
\begin{minipage}[t]{\linewidth+#2\leftmargin}
#3
\addvspace{3\itemsep}
\end{minipage}%
\nopagebreak[2]}
\begin{document}
\begin{itemize}
\item This works
\HorsListe{Something wide}
\item This doesn't work.
\HorsListe{Something wide
with paragraph}
\item This doesn't work too
\HorsListe{\begin{tikzpicture}
\draw (0,0) rectangle (\linewidth,0) ;
\end{tikzpicture}}
\end{itemize}
\end{document}
答案1
的参数\NewDocumentCommand
假定很短。您需要+
使它们变长:
\NewDocumentCommand{\HorsListe}{sO{1}+m}{ CODE HERE }