# Indented paragraphs

I want to show an indented paragraph in which indentation means the the top level condition is acquired (suppose a if then else structure) a copy of what I need is shown

I have implemented this sample using the following code:

\documentclass{article}

\begin{document}

\newenvironment{myindentpar}[1]%
{\begin{list}{}
{\setlength{\leftmargin}{#1}}
\item[]
}
{\end{list}}

\begin{myindentpar}{1em}
\textbf{HelloMsg}
\end{myindentpar}

\begin{myindentpar}{2em}
This is a text to fill the line.

\textbf{HelloMsg.Hello}
\end{myindentpar}

\begin{myindentpar}{3em}
The Hello Message description goes here

\textbf{HelloMsg.Hello.Ack}
\end{myindentpar}

\end{document}


But frankly speaking it looks so odd to me. Do we have any better way of doing this? Do we have a package that depicts some vertical lines that shows which item is underneath of the other? (such a thing is so common in programming environments. Some slim lines are drawn to show where a block ends)

Edit This section contains materials regarding the comments, it is not part of the main question.

\documentclass{article}

\begin{document}

this is the default indentation!!!

\noindent this is without indentation

\newenvironment{myindentpar}[1]%
{\begin{list}{}
{\setlength{\leftmargin}{#1}}
\item[]
}
{\end{list}}

\begin{myindentpar}{1em}
\textbf{HelloMsg (indented 1em)}
\end{myindentpar}

\begin{myindentpar}{2em}

\textbf{HelloMsg.Hello (indented 2em)}
\end{myindentpar}

\begin{myindentpar}{3em}

\textbf{HelloMsg.Hello.Ack (indented 3em)}
\end{myindentpar}

this is source of critic!

\newenvironment{herbertIndentPar}%
{\begin{list}{}
\item[]}
{\end{list}}

\begin{herbertIndentPar}
\textbf{Hello Herbert (I'm shifted 3em to the right! but my parameter says it must be shifted 2em one for the start of the paragraph and plus one for the passed 1em)}

\begin{herbertIndentPar}

\textbf{HelloMsg.Hello}

\begin{herbertIndentPar}

\textbf{HelloMsg.Hello.Ack}
\end{herbertIndentPar}
another line
\end{herbertIndentPar}
another line
\end{herbertIndentPar}

this is the source of critic (back to 1em indent)!

\end{document}


I am geting this output:

-
if this is for code the algorithms package cano it. –  Yiannis Lazarides Jan 5 '11 at 14:03
I am aware of algorithm package, but this is not for code. See my previous post: tex.stackexchange.com/questions/6415/… –  Yasser Sobhdel Jan 5 '11 at 14:10

\documentclass{article}
\usepackage[showframe]{geometry}

\newlength\myLeftmargin

\newenvironment{herbertIndentPar}
{\begin{list}{}%
\setlength\leftmargin{\myLeftmargin}%
\listparindent=0pt
}%
\item\relax}

\begin{document}

\begin{herbertIndentPar}
\textbf{Hello Herbert (I'm shifted 3em to the right! but my
parameter says it must be shifted 2em one for the start of the
paragraph and plus one for the passed 1em)}

\begin{herbertIndentPar}
\textbf{HelloMsg.Hello}

\begin{herbertIndentPar}
\textbf{HelloMsg.Hello.Ack}
\end{herbertIndentPar}

another line
\end{herbertIndentPar}

another line
\end{herbertIndentPar}

this is the source of critic (back to 1em indent)!

\end{document}


-
@Herbert: Looks like a good answer. If you have time for that, you could improve the answer (and other answers) by adding one or two sentences of explanation. –  Hendrik Vogt Jan 5 '11 at 15:01
@Herbert: Thanks! That is it. Can you please tell me why in my code after the last \end{myindentpar} the next paragraph (or ordinary text) is still shifted to the right as wide as the first parameter passed to the first \begin{myindentpar}. let me rephrase with a sample: copy my code to a file and just before \end{document} add a "Text". It will be indented for 1em, why is it so? (I have to use \noindent before it to suppres the indent, but your code works fine :D) –  Yasser Sobhdel Jan 5 '11 at 16:04
@Yasser: it is only indented, as usual. Compare it with \noindent Text after the last environemnt. Use \parindent=0pt in your preamble if you do not like it. If I do not understand your problem, then please create a small example –  Herbert Jan 5 '11 at 16:20
@Herbert: let me clarify, use your code and place a text just before the \end{document}. It will not be indented. Now use my code, it will be indented but it is out of my new environment but keeps the indentation. why? –  Yasser Sobhdel Jan 5 '11 at 16:40
@Yasser: maybe that I am blinded my the light, but I cannot see any difference. I uploded the two screenshots above. –  Herbert Jan 5 '11 at 17:02