enumitem 包声明的 itemize 列表在左边距打印标签。如何修复?

enumitem 包声明的 itemize 列表在左边距打印标签。如何修复?

我借用了这个问题的答案中的一种创建对话的方法:创建对话。此页面中的代码运行良好,但当我将其添加到使用几何包的文档中时,打印输出不是我想要的:标签打印在左边距。使用选项leftmargin=*有助于标签不打印在左边距,但会破坏标签和文本右侧的对齐。我也试过了dialogue package,但标签的对齐不是我想要的。我想在一个框中进行对话(使用 tcolorbox),但结果也不是我想要的。有什么想法可以解决这个问题吗?

我的 MWE:

\documentclass{article}  
\usepackage[a4paper, total={180mm,247mm},left=15mm,top=20mm]{geometry}  
\usepackage{tcolorbox}  
\usepackage{enumitem,blindtext}  
\usepackage{xparse}  
\DeclareDocumentCommand\dia{ o m }{%  
    \begin{itemize}[%  
        ,label=\IfNoValueTF {#1} {}{#1:}  
        ,labelsep=8mm  
        ,nosep % optional  
        ,font=\color{black}  
        ]  
        \item #2  
    \end{itemize}%    
}  
\begin{document}  
    \dia[First guy]{Hi, how are you?}  
    \dia[Second guy]{Fine and you?}  
    \dia[Guy with long hair]{My god, this dialogue is so boring.\\ %start a new line  
        Yeah! It's so boring.}  
    \dia[First guy]{Indeed, but have you heard that \blindtext}     
      
    \begin{tcolorbox}  
        \dia[First guy]{Hi, how are you?}  
        \dia[Second guy]{Fine and you?}  
        \dia[Guy with long hair]{My god, this dialogue is so boring.\\ %start a new line  
            Yeah! It's so boring.}  
        \dia[First guy]{Indeed, but have you heard that \blindtext}  
    \end{tcolorbox}    
\end{document}  

输出: 在此处输入图片描述

如果我使用左边距=*

\documentclass{article}  
\usepackage[a4paper, total={180mm,247mm},left=15mm,top=20mm]{geometry}  
\usepackage{tcolorbox}  
\usepackage{enumitem,blindtext}  
\usepackage{xparse}  
\DeclareDocumentCommand\dia{ o m }{%  
    \begin{itemize}[%  
        ,label=\IfNoValueTF {#1} {}{#1:}  
        ,leftmargin=*  
        ,labelsep=8mm  
        ,nosep % optional  
        ,font=\color{black}  
        ]  
        \item #2  
    \end{itemize}%    
}  
\begin{document}  
    \dia[First guy]{Hi, how are you?}  
    \dia[Second guy]{Fine and you?}  
    \dia[Guy with long hair]{My god, this dialogue is so boring.\\ %start a new line  
        Yeah! It's so boring.}  
    \dia[First guy]{Indeed, but have you heard that \blindtext}  
      
    \begin{tcolorbox}  
        \dia[First guy]{Hi, how are you?}  
        \dia[Second guy]{Fine and you?}  
        \dia[Guy with long hair]{My god, this dialogue is so boring.\\ %start a new line  
            Yeah! It's so boring.}   
        \dia[First guy]{Indeed, but have you heard that \blindtext}  
    \end{tcolorbox}  
\end{document}  

输出: 在此处输入图片描述

相关内容