Indentation superfunction LaTeX

There are a lot of questions on here that are about indentation and I feel like what most people are looking for is something similar to the following.

It would be nice to have some sort of function to call, \indent{}, so that everything sounded by {} was placed one tab length from the left margin.

Also, the ability to call this function inside itself, so that, for instance,

 %this is an example of what I am talking about.
\indent{
textbody1

\indent{
textbody2
}
}


resulted in the entirety of textbody2 being one tab unit away from the entirety of textbody1's left margin.

Is this possible?

• Do you mean tabbing? May 13 '16 at 3:10
• @azetina see edit. May 13 '16 at 3:13
• You can do this with a variety of boxes as well as with tabular environments. May 13 '16 at 3:42
• \begin{quote} ... \end{quote}? May 13 '16 at 11:45

You can use lists, with the help of enumitem for setting parameters more easily.

\documentclass{article}
\usepackage{enumitem}

\usepackage[nopar]{lipsum} % just for the example

\newenvironment{subindent}[1][0.5in]
{\itemize[label={},leftmargin=#1,nosep]\item\relax}
{\enditemize}

\begin{document}

\lipsum[2]
\begin{subindent}
\lipsum[3]
\begin{subindent}[1in]
\lipsum[4]
\end{subindent}
\lipsum[5]
\end{subindent}
\lipsum[6]

\end{document}


Since \indent is already used, I used \myindent and used \mytab for the "tab" size. Pretty much any length will do.

\documentclass{article}
\usepackage{lipsum}
\usepackage{showframe}

\newlength{\mytab}
\setlength{\mytab}{\bibindent}

\newcommand{\myindent}[1]% #1 = text to be indented
{\ifvmode\else\par\fi
#1\egroup\par}

\begin{document}
\lipsum[1]
\myindent{\lipsum[2]
\myindent{\lipsum[3]}
\lipsum[4]
}
\lipsum[5]
\end{document}

• Very good approach although I would define, like you rightfully suggested, a new length to avoid compilation issues. May 13 '16 at 4:15
• Sure, why not? ----- May 13 '16 at 4:21
• Wonderful :) Much better IMHO. May 13 '16 at 4:23
• So easy looking. I got jealous that I had not thought of that. May 13 '16 at 4:41
• This won't work if the content contains a list (including quote and center) or verbatim material. See also tex.stackexchange.com/questions/237551/… May 13 '16 at 7:16