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.

Consider the following example that uses changepage's adjustwidth to set a single paragraph at 80% of the text width (on the left). Compare this to the use of \parshape (on the right):

enter image description here

\documentclass{article}
\usepackage[a5paper]{geometry}% http://ctan.org/pkg/geometry
\usepackage{changepage,lipsum}% http://ctan.org/pkg/{changepage,lipsum}
\begin{document}

\lipsum[1]

\begin{adjustwidth}{0pt}{.2\textwidth}
\hspace*{\parindent}\lipsum[2]
\end{adjustwidth}

\lipsum[2]

\clearpage

\lipsum[1]

\parshape 1 0pt .8\textwidth
\lipsum[2]

\lipsum[2]

\end{document}

How can I adjust the vertical spacing introduced by adjustwidth so that it matches that of the \parshape output?

I understand that adjustwidth sets its contents in a list (see changepage.tex), and lists naturally have some gap above/below it. However, \topsep is set to zero (\z@) already, so I'm not sure where these lengths come from/how to remove them.

share|improve this question

1 Answer 1

The extra space comes from \partopsep. You can set \partopsep to 0pt:

\documentclass{article}
\usepackage[a5paper]{geometry}% http://ctan.org/pkg/geometry
\usepackage{changepage,lipsum}% http://ctan.org/pkg/{changepage,lipsum}

\makeatletter
\renewenvironment{adjustwidth}[2]{%
  \begin{list}{}{%
    \partopsep\z@%
    \topsep\z@%
    \listparindent\parindent%
    \parsep\parskip%
    \@ifmtarg{#1}{\setlength{\leftmargin}{\z@}}%
                 {\setlength{\leftmargin}{#1}}%
    \@ifmtarg{#2}{\setlength{\rightmargin}{\z@}}%
                 {\setlength{\rightmargin}{#2}}%
    }
    \item[]}{\end{list}}
\makeatother

\begin{document}

\lipsum[1]

\begin{adjustwidth}{0pt}{.2\textwidth}
\hspace*{\parindent}\lipsum[2]
\end{adjustwidth}

\lipsum[2]

\clearpage

\lipsum[1]

\parshape 1 0pt .8\textwidth
\lipsum[2]

\lipsum[2]

\end{document}

Or, with the help of etoolbox:

\documentclass{article}
\usepackage[a5paper]{geometry}% http://ctan.org/pkg/geometry
\usepackage{changepage,lipsum}% http://ctan.org/pkg/{changepage,lipsum}
\usepackage{etoolbox}
\AtBeginEnvironment{adjustwidth}{\partopsep0pt}

\begin{document}

\lipsum[1]

\begin{adjustwidth}{0pt}{.2\textwidth}
\hspace*{\parindent}\lipsum[2]
\end{adjustwidth}

\lipsum[2]

\clearpage

\lipsum[1]

\parshape 1 0pt .8\textwidth
\lipsum[2]

\lipsum[2]

\end{document}

enter image description here

share|improve this answer

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.