# Locally setting the line width in a paragraph

How can I make a specific paragraph have a specific line width?

-
You need the paragraph to be able to span across pages? – xport Jun 22 '11 at 9:41
In this particular case no span is ok. – Gadi A Jun 22 '11 at 10:40

Use \parbox{<linewidth>}{<content>} for the paragraph. Alternatively you can use the very similar minipage environment which also takes the line width as first argument. However, both do not allow page breaks in the paragraph. Also have a look on the quote and quotation environments which narrow the paragraph width.

-
\parbox and minipage cannot span across pages. – xport Jun 22 '11 at 9:40
@xport: In this case I would recommend framed.. Oh wait ;-) – Martin Scharrer Jun 22 '11 at 10:24
@xport: I just figured that \par\begingroup\hsize=<width> ... \par\endgroup might be also do it and support page breaks. I'm not 100% sure if it is OK this way or if it needs extra care. Anyway, \textwidth, \columnwidth and \linewidth should all be set to \hsize as well, I think. – Martin Scharrer Jul 8 '11 at 16:49

The method with \leftskip and \rightskip doesn't work if the reduced width part of the document contains lists. In this case it's best to define an environment based on list:

\usepackage{keyval}
\makeatletter
\define@key{setpar}{left}[0pt]{\leftmargin=#1}
\define@key{setpar}{right}[0pt]{\rightmargin=#1}
\define@key{setpar}{both}{\leftmargin=#1\relax\rightmargin=#1}
\makeatother

\newenvironment{narrow}[1][]
{\list{}{\setkeys{setpar}{left,right}%
\setkeys{setpar}{#1}%
\listparindent=\parindent
\topsep=0pt
\partopsep=0pt
\parsep=\parskip}\item\relax\hspace*{\listparindent}\ignorespaces}
{\endlist}


One can specify the settings in the following ways, that should be easily understood:

  \begin{narrow}[left=1cm]
\begin{narrow}[right=2cm]
\begin{narrow}[both=1cm]
\begin{narrow}[left=2cm,right=1cm]


and lists inside the environment will work properly.

-
\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage[english]{babel}
\usepackage{blindtext}
\begin{document}
\blindtext

\leftskip=1cm
\blindtext

\rightskip=1cm
\blindtext

\leftskip=0pt\rightskip=0pt
\blindtext
\end{document}


-

Good feature: The paragraph can span across pages and be enclosed by a fancy frame.

\documentclass{article}
\usepackage{framed,lipsum,xcolor}

\renewenvironment{leftbar}[1][\hsize]{%
\def\FrameCommand{{\color{red}\vrule width 3pt}\hspace{0pt}\fboxsep=\FrameSep\colorbox{yellow}}%

I much prefer the mdframed approach to defining new frame environments: framed's approach is hard to read... – Seamus Jun 22 '11 at 11:34