# How to produce white space for all text lines of an environment?

How can I produce whitespace before each line of an environment. If I have the following command in the preamble

\newenvironment{myenv}
{\vspace{3mm}\hspace{0.5cm}\noindent\ignorespaces\small\texttt}
{\par\noindent\ignorespacesafterend\vspace{0.5mm}}


and in the text:

\begin{myenv}
hello \\
world
\end{myenv}


this produces whitespaces only for the first line.

-
Welcome to TeX.sx! A tip: If you indent lines by 4 spaces, as I've done it just now, they'll be marked as a code sample. You can also highlight the code and click the "code" button (with "{}" on it). –  Speravir Oct 27 '12 at 23:35
Welcome to TeX.sx! Please add a minimal working example (MWE) that illustrates your problem. It is considered a lot better to put in some code that will compile, as it makes it a lot easier for us to copy it into our text editor and work with it, and see exactly what it is you are trying to do. –  Canageek Oct 27 '12 at 23:38
@Speravir and Canageek, thanks for the tips. –  narengi Oct 27 '12 at 23:46

Perhaps you might be interested in using a combination of \obeylines (so you don't have to manually break the line) and \doublespacing (provided by setspace):

\documentclass{article}
\usepackage{lipsum,setspace}% http://ctan.org/pkg/{lipsum,setspace}
\newenvironment{myenv}
{\par\hrulefill\doublespacing\obeylines}
{\hrulefill\par\ignorespacesafterend}
\begin{document}
\lipsum[6]
\begin{myenv}
hello
world
\end{myenv}
\lipsum[6]
\end{document}


The \hrulefill is only to show the start/end of the environment myenv and most likely not needed in your application.

Although the proposed solution does not show the typewriter font, you can issue \ttfamily to achieve this (not \texttt).

-

Depending on the application a minor problem of Werner's solution is that if a line is longer than the texwith the continuation is not indented. Here is an alternative solution (and comparison with Werner's solution).

\documentclass{article}
\usepackage{lipsum}

\newenvironment{myenv}
{\begin{list}{}{
\setlength{\topsep}{3mm}
\setlength{\leftmargin}{0.5cm}
\small\ttfamily}
\item[]\hrulefill\\}
{\hrulefill\end{list}}

\newenvironment{myenvW}
{\par\hrulefill\obeylines\small\ttfamily}
{\hrulefill\par\ignorespacesafterend}

\begin{document}

\lipsum[6]
\begin{myenv}
test\\
\lipsum[6]
\end{myenv}
\lipsum[6]
\begin{myenvW}
test
\lipsum[6]
\end{myenvW}
\end{document}


-