0

I have borrowed a way for creating dialogues from the answer of this question: Create a dialogue. The code in this page works fine but when I added it in my document which uses geometry package the printout was not what I wanted: the labels were printed in the left margin. Using option leftmargin=* helps the labels not being printed in the left margin, but ruins the alignment at right of labels and text. I also tried dialogue package, but there the alignment of labels is not what I want. I would like to have the dialogue in a box (using tcolorbox) but the result was not either what I wanted. Any ideas to fix it?

my 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}

Output: enter image description here

If I use leftmargin=*

\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}

and the output: enter image description here

miltos
  • 2,605

0 Answers0