1

I would like to make customized list environment which work both in main text as well as in my own quotation (in my case environment that I call dialogue (list) is inside environment that I call myquotation (trivlist)). But I have troubles with obtaining expected indentations. My working example:

\documentclass{article}
\usepackage[paperwidth=12cm,paperheight=11cm]{geometry}
\usepackage{ifthen}

% quotes
\newenvironment{myquotation}
    {\begin{trivlist}
        \ifthenelse{\isodd{1}}
                   {\setlength\leftskip{6.5mm} \setlength\rightskip{0mm}}
                   {\setlength\leftskip{0mm} \setlength\rightskip{6.5mm}}
        \setlength\itemindent{\parindent}
        \item\relax \slshape}
    {\end{trivlist}}

% dialogues
\newcommand{\entrylabel}[1]{
    \ifthenelse{\equal{}{#1}}{
        \hfill\mbox{\small{\textsc{--}}}
    }{
        \mbox{\small{\textsc{#1:}}}
    }
}
\newenvironment{dialogue}{\list{}{\renewcommand{\makelabel}{\entrylabel}
                                  \itemsep=0cm \topsep=0cm \parsep=0cm
                                  \listparindent=0em}
                         }{\endlist}

\begin{document}
Dialogue inside the quotation (unwanted indentation of the first item):
\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}

    Some text inside the quotation following short customized dialogue.
\end{myquotation}

Dialogue inside the quotation (solution that doesn't work by flexible
vertical distances between list items):
\begin{myquotation}
    \mbox{}\vspace{-\baselineskip}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}
\end{myquotation}

Dialogue outside the quotation:
\begin{dialogue}
\item[Cookiemonster] Om, om, om...
\item[Roadrunner] Beep, beep, beep...
\item[Reksio] Hau, hau, hau...
\end{dialogue}
\end{document}

enter image description here

For me the most important is to remove indentation of the fist item inside my quotation. Initially I considered incorporation of line \mbox{}\vspace{-\baselineskip} into my list definition (called here dialogue), but in the case of float spaces between items and float vertical spacings around the list it does not work proper.

How to move automatically the following list items to the positions of no indented text boundary (as pointed with green arrows in the picture)?

1

The faulty indentation is from the wrong \setlength\itemindent{\parindent} in your trivlist. Also if you want that your dialogue environment changes depending on the level it is better if the outer enviroment is also a list.

I have no idea what vertical spaces you want so I removed them all. In the long run it is better and easier to define such lists with the package enumitem.

 \documentclass{article}
\usepackage[paperwidth=12cm,paperheight=11cm]{geometry}
\usepackage{ifthen}

% quotes

\newenvironment{myquotation}
    {\list{}{%
        \ifthenelse{\isodd{1}}
                   {\setlength\leftmargin{\parindent} \setlength\rightmargin{0mm}}
                   {\setlength\leftmargin{0mm} \setlength\rightmargin{6.5mm}}%
        \topsep=0cm \parsep=0cm \partopsep=0pt   \listparindent=0em
        }
        \item\relax \slshape
    }%
    {\endlist}

% dialogues
\newcommand{\entrylabel}[1]{%
    \ifthenelse{\equal{}{#1}}{%
        \hfill\mbox{\small{\textsc{--}}}%
    }{%
     \hspace\labelsep   \mbox{\small{\textsc{#1:}}}%
    }
}
\newenvironment{dialogue}{\list{}{\renewcommand{\makelabel}{\entrylabel}%
                                  \labelwidth0cm \itemindent-\leftmargin
                                  \topsep=0cm \parsep=0cm
                                  \partopsep=0pt
                                  \listparindent=0em
                                  }}{\endlist}

\begin{document}
Dialogue inside the quotation (unwanted indentation of the first item):

 \begin{myquotation}
 blblbl 
 \end{myquotation}


\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \item blbu
    \end{dialogue}

    Some text inside the quotation following short customized dialogue.
\end{myquotation}

Dialogue inside the quotation (solution that doesn't work by flexible
vertical distances between list items):
\begin{myquotation}
    \begin{dialogue}
    \item[Cookiemonster] Om, om, om...
    \item[Roadrunner] Beep, beep, beep...
    \item[Reksio] Hau, hau, hau...
    \end{dialogue}
\end{myquotation}

Dialogue outside the quotation:
\begin{dialogue}
\item[Cookiemonster] Om, om, om...
\item[Roadrunner] Beep, beep, beep...
\item[Reksio] Hau, hau, hau...
\end{dialogue}
\end{document}

enter image description here

|improve this answer|||||
  • Thx for the response. In fact I would like to have indented first line of the paragraph inside my customized environment myquotation. Only the list insiede this environment should be without of the first element indentation. So removing of the line \setlength\itemindent{\parindent} gives unwanted result for content other than list. I tried to solve the problem with the schematic of page layout - by \usepackage[inline]{enumitem} declaration in preamble. Also uneqalities in line spacings obtained with your code are difficut problem for me. – forrest Jul 25 '17 at 12:07
  • 1
    If you want to keep the itemindent you will imho have to use \begin{myquotation}\leavevmode\vspace{-\baselineskip}\begin{dialogue}. (you get such indentations for starting lists also with the quotation list, so it is not a problem of your definitions). – Ulrike Fischer Jul 28 '17 at 7:55
  • Thx - this advice in your comment solve my problem. But is there any way to configure dialogue environment to adjust its behavior automatically - dependently on the location (inside myquotation environment or beyond it)? – forrest Aug 11 '17 at 10:07

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.