5

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?

4
  • Do you mean tabbing?
    – azetina
    May 13, 2016 at 3:10
  • @azetina see edit.
    – 9301293
    May 13, 2016 at 3:13
  • You can do this with a variety of boxes as well as with tabular environments.
    – A Feldman
    May 13, 2016 at 3:42
  • \begin{quote} ... \end{quote}?
    – alexis
    May 13, 2016 at 11:45

2 Answers 2

5

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}

enter image description here

5

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
\bgroup\advance\leftskip by \mytab
#1\egroup\par}

\begin{document}
\lipsum[1]
\myindent{\lipsum[2]
  \myindent{\lipsum[3]}
  \lipsum[4]
}
\lipsum[5]
\end{document}
5
  • Very good approach although I would define, like you rightfully suggested, a new length to avoid compilation issues.
    – azetina
    May 13, 2016 at 4:15
  • Sure, why not? ----- May 13, 2016 at 4:21
  • Wonderful :) Much better IMHO.
    – azetina
    May 13, 2016 at 4:23
  • 1
    So easy looking. I got jealous that I had not thought of that.
    – A Feldman
    May 13, 2016 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, 2016 at 7:16

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .