Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

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

share|improve this question
1  
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

4 Answers 4

up vote 6 down vote accepted

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.

share|improve this answer
    
\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.

share|improve this answer
\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}

enter image description here

share|improve this answer

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

enter image description here

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

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

\begin{document}
\lipsum[1]
\begin{leftbar}[0.5\linewidth]
\lipsum[1-3]
\end{leftbar}
\lipsum[3]
\end{document}
share|improve this answer
1  
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

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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