6

This question already has an answer here:

How can I add left space to a block of text? (see the attempts and pictures below)

I can think of two ways:

minipage

\documentclass{article}

\usepackage{lipsum}

\begin{document}

\lipsum[1]

\noindent
\hspace{2em}%
\begin{minipage}{0.95\textwidth}
\lipsum[2-3]
\end{minipage}

\end{document}

minipage

Three problems:

  1. I cannot use another minipage within that minipage (which I need in my usecase)
  2. Indentation and paragraph spacing seem to change
  3. What to pass as the width optional argument?

enumitem

Using itemize with the enumitem options:

\documentclass{article}

\usepackage{lipsum}
\usepackage{enumitem}  % needed!

\begin{document}

\lipsum[1]

\begin{itemize}[label={},leftmargin=2em]
\item \lipsum[2-3]
\end{itemize}

\end{document}

It loses indentation and the paragraph spacing is a little different than the rest, but looks like much better:

enumitem

Anyhow, any other suggestion?

(Duplicate of: How can I change the margins for only part of the text?)

marked as duplicate by Ricardo Cruz, user13907, Andrew Swann, user11232, egreg spacing Oct 2 '15 at 12:17

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • see this tex.stackexchange.com/a/2639/71471 – touhami Sep 29 '15 at 6:31
  • @touhami I probably shouldn't have used the term margins. This is not about paper margins. This is about paragraph margins. Consider the examples I submitted. I searched and I do not think this is a dup of any other question. – Ricardo Cruz Sep 30 '15 at 17:14
  • Of course it is, this question is very frequent. I linked Will Robertson's answer the environment adjustwidth is what you look for, you can also search (google) for changemargin environment. Now, the fact that the question is duplicate does not mean it's not good. – touhami Sep 30 '15 at 19:06
  • 4
    @touhami you are right. The question you referenced was about page margins, but one of the answers he received can indeed be used for my purpose. I have added one answer to this question that uses the two approaches you mentioned in your last comment. If you'd like to make it a dup of another question, consider this one instead: tex.stackexchange.com/questions/588/… – Ricardo Cruz Oct 2 '15 at 9:02
2

Here is a suggestion using the addmargin environment defined by package scrextend.

\documentclass{article}
\usepackage{lipsum}
\usepackage{scrextend}
\begin{document}
\lipsum[1]
\begin{addmargin}[2em]{0em}
\lipsum[2-3]
\end{addmargin}
\end{document}

enter image description here

Note that scrextend is a package to use some KOMA-Script Features like addmargin with other classes. Hence if you use a KOMA-Script class there is no need to load scrextend.

  • Perfect. They can even by placed inside each other. – Ricardo Cruz Sep 29 '15 at 8:21
1

Considering @touhami's comment and this answer from another question, here is a MWE that uses two other approaches for local paragraph margins:

\documentclass{article}

\usepackage{lipsum}

% \adjustwidth
\usepackage{changepage}

% https://tex.stackexchange.com/a/600/34244
%\def\changemargin#1#2{\list{}{\rightmargin#2\leftmargin#1}\item[]}
%\let\endchangemargin=\endlist

% touhaim's suggestion:
\def\changemargin#1#2{\list{}{%
\setlength{\leftmargin}{#1}%
\setlength{\rightmargin}{#2}%
\setlength{\topsep}{0pt}%
\setlength{\parsep}{\parskip}%
\setlength{\itemindent}{\parindent}%
\setlength{\listparindent}{\parindent}%
}\item[]}

\begin{document}

\lipsum[1]

\begin{adjustwidth}{4cm}{4cm}
\lipsum[2]
\end{adjustwidth}

\lipsum[3]

\begin{changemargin}{4cm}{4cm} 
\lipsum[4]
\end{changemargin}

\lipsum[5]

\end{document}
  • you need to define it like this \def\changemargin#1#2{\list{}{% \setlength{\leftmargin}{#1}% \setlength{\rightmargin}{#2}% \setlength{\topsep}{0pt}% \setlength{\parsep}{\parskip}% \setlength{\itemindent}{\parindent}% \setlength{\listparindent}{\parindent}% }\item[]} – touhami Oct 2 '15 at 9:23
  • 1
    @touhami, updated it with your suggestion. Anyhow, to any users out there: I would suggest you just use the package changepage. Always better to use a package because it has been more widely tested and is continuously updated. – Ricardo Cruz Oct 2 '15 at 17:47

Not the answer you're looking for? Browse other questions tagged or ask your own question.