4

I would like to have a command to write dialogues. Something like

\newcommand\fdia{---~ }
\newcommand\dia{\\ \indent ---~ }

with usage:

\fdia Hi how are you?
\dia Fine and you?
\dia My god, this dialogue is so boring.

Is fine, except that it does not handle an answer with multiple lines the way I want: I want every line of an answer to be indented after the dash. This can be achived easily using

\begin{itemize}
\item[---~] Hi how are you?
\item[---~] Fine and you?
\item[---~] Still boring...
\end{itemize}

But I would like the command to be as quick to use as possible. Would there be by any chance, a solution to achieve what I want without using an environment?

6

It is no problem to start an itemize over and over again (I checked the vertical spacing). So you may put the whole environment in your command if you do not want to type it every time.

Below, you have to decide if you want to use the option nosep or if you don't. In your question, you have given two approaches with different vertical spacing.

% arara: pdflatex

\documentclass{article}
\usepackage{blindtext}
\usepackage{enumitem}
\usepackage{xparse}
\DeclareDocumentCommand \dia { o m } {%
    \begin{itemize}[%
        ,label=\IfNoValueTF {#1} {---}{#1:}
        ,nosep % optional
        ]
        \item #2
    \end{itemize}%  
    }

\begin{document}
\dia[First guy]{Hi, how are you?}
\dia[Second guy]{Fine and you?}
\dia{My god, this dialogue is so boring.}
\dia{Indeed, but have you heard that \blindtext}
\end{document}

enter image description here

| improve this answer | |
  • Thanks. This is not bad, but despite the "nosep", there is still extra vertical spacing compare to the use of a single list – Archimondain Jun 12 '15 at 13:50
  • @Archimondain Really? Not for me. Please clarify in your question, what you want exactly. And give all code which is needed to show your issues. Thanks. – LaRiFaRi Jun 12 '15 at 13:53
  • Indeed, this is because I modified the spacing in my document between paragraphs (the value of \parskip), and apparently this affects the itemize command – Archimondain Jun 12 '15 at 14:08
  • Thanks for your time. I think maybe the easiest if I want to keep extra space between paragraph is to define two very short macros for starting and ending the environment, with all the options. – Archimondain Jun 12 '15 at 14:18

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.