# hanging indent within indented texttt quote environment

I'm working on a memoir class document which happens to use interparagraph spacing rather than indented first lines, yet I'm trying to create an environment that showcases sample text - I'm calling it hangingsample - where:

• the text is indented (like in a quote or quotation environment),
• the text is set in typewriter font (I use \texttt for this),
• the text is set \raggedright,
• each paragraph uses hanging indentation (like in APA referencing), and
• the interparagraph spacing is zero.

To illustrate:

The only way I have managed to create this effect thus far is to do everything manually, combining the figure, minipage, and hangparas environment, the \raggedright command, and enveloping each separate paragraph in \texttt{x} and following up each paragraph with \vspace{-\parskip}:

Preceding text ...

\begin{figure}[h]
\hspace*{5mm}\begin{minipage}[h]{125mm}
\begin{hangparas}{5mm}{1}\RaggedRight
\texttt{Technic is ... LEGO.}\vspace{-\parskip}

\texttt{Technic sets are ... electric motors.}\vspace{-\parskip}

\texttt{The style of ... technic bricks.}\vspace{-\parskip}

\texttt{Lego Technic. ... wiki/Lego\_Technic}
\end{hangparas}
\end{minipage}
\end{figure}

Following text...


surely this cannot be the most economical way of doing it... I'm looking for a simple new (or renewed) environment that does all of these things.

So far, I have created the following environment:

\newenvironment{hangingsample}{%
\everypar{\hangafter=1 \setlength{\hangindent}{5mm}}\ttfamily\raggedright}
{\par%
}


Which achieves most points except the full indentation of the paragraphs.

Anyone any idea what I could do to solve this?

Most kind regards,

Cees

\documentclass{memoir}
\usepackage{lipsum}

\newenvironment{ttquote}
{\list{}{%
\ttfamily\raggedright
\setlength{\itemindent}{-1em}%
\setlength{\listparindent}{\itemindent}%
\setlength{\rightmargin}{\leftmargin}%
\setlength{\parsep}{0pt plus 1pt}%
}%
\item[]}
{\endlist}

\nonzeroparskip
\setlength{\parindent}{0pt}

\begin{document}

\lipsum[2-3]

\begin{ttquote}
\lipsum[2]

\lipsum[3]
\end{ttquote}

\end{document}


Hope this helps. It's an adaptation of Herbert's answer to Within a single paragraph, hang a wrapped line, but do not hang new lines. Being based in a minipage, this environment won't break between pages.

\documentclass{article}
\usepackage{lipsum}
\usepackage{environ}

\NewEnviron{ttpar}{%
\begin{minipage}{.9\linewidth}
\everypar{\setlength\hangindent{1em}\ttfamily}
\BODY\end{minipage}}

\begin{document}

\lipsum[1]

\begin{ttpar}
\lipsum[1]

\lipsum[2]
\end{ttpar}

\lipsum[3]
\end{document}


• I have a feeling @egreg's solution will work even better for me, but I will give both a try. Thanks! Sep 29 '16 at 4:44
• @Krottsy No doubt! Any egreg's solution will work better than mine. He knows what he's doing. ;-) Sep 29 '16 at 7:47