3

I would like to reduce the line spacing for some sentences of a paragraph, for example, the blue color sentences as below, how should I do?

\documentclass{article}

\usepackage{setspace,lipsum}
\setstretch{1.2}
\usepackage{xcolor}

\begin{document}

\lipsum[1] {\color{blue}\lipsum[2]}

\lipsum[1]

\end{document}

enter image description here

2 Answers 2

7

The task isn't clear: what t do when the blue text starts inside a line?

The problem is that TeX uses \baselineskip value for whole paragraph when \par is processed.

Your example can be solved using two paragraphs, first one is black text and second one is blue text. First paragraph is finalized without stretchable \parfillskip and second paragraph is started with \noindent and with modified \baselineskip.

\documentclass{article}

\usepackage{setspace,lipsum}
\setstretch{1.2}
\usepackage{xcolor}

\def\endpar{{\parfillskip=0pt \par}
   \smallskip\baselineskip=10pt \lineskiplimit=-10pt \noindent}

\begin{document}

\lipsum[1] {\endpar\color{blue}\lipsum[2]\par}

\lipsum[1]

\end{document}
0
3

This won't work if the part before the blue part is not long enough, in the sense that it may produce large interword spaces in the last line.

The idea is similar to wipet's but I use a proper LaTeX environment that avoids the need to do explicit \par and \color instructions, besides getting the top line spacing right without any need to guess.

\documentclass{article}

\usepackage{setspace}
\usepackage{xcolor}

\usepackage{lipsum}% for the example

\setstretch{1.2}

\newenvironment{innerpar}[1]{%
  {\unskip\strut\parfillskip=0pt \par}%
  \vspace*{0.2\baselineskip}%
  \setstretch{1}\noindent\ignorespaces\color{#1}%
}{\par}

\begin{document}

\lipsum[1]
\begin{innerpar}{blue!60}
\lipsum[2]
\end{innerpar}

\lipsum[1]

\end{document}

enter image description here

You must log in to answer this question.

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