8

Code:

\documentclass{article}

\begin{document}

Lorem ipsum dolor sit amet, pri an timeam molestiae. Dictas sententiae ius ad. Quod indoctum quo at. Et nam sale elitr, cibo solum consetetur cu cum, congue expetenda et vel. Lorem ipsum dolor sit amet, pri an timeam molestiae. Dictas sententiae ius ad. Quod indoctum quo at. Et nam sale elitr, cibo solum consetetur cu cum, congue expetenda et vel. Lorem ipsum dolor sit amet, pri an timeam molestiae. Dictas sententiae ius ad. Quod indoctum quo at. Et nam sale elitr, cibo solum consetetur cu cum, congue expetenda et vel.

\end{document}

Output (with red line numbers added):

enter image description here

Question: How do I increase the line spacing between (say) lines 3 & 4 and lines 4 & 5, but not between any of the other lines?

(This is not a duplicate because this other question and its answers pertain to increasing line spacing for an entire paragraph.)

9
+25

It is not clear how you want to choose and identify the lines with the additional space and how automatic the solution should be. You can always add manually some \vspace:

\documentclass{article}

\begin{document}

Lorem ipsum dolor sit amet, pri an timeam molestiae. Dictas sententiae ius ad. 
Quod indoctum quo at. Et nam sale elitr, cibo solum consetetur cu cum, congue 
expetenda\vspace{1cm} et vel. Lorem ipsum dolor sit amet, pri an timeam molestiae. 
Dictas sententiae ius ad. Quod indoctum\vspace{1cm} quo at. Et nam sale elitr, cibo solum 
consetetur cu cum, congue expetenda et vel. Lorem ipsum dolor sit amet, pri an timeam 
molestiae. Dictas sententiae ius ad. Quod indoctum quo at. Et nam sale elitr, cibo solum 
consetetur cu cum, congue expetenda et vel.

\end{document}

enter image description here

  • +1 for simplicity! – NBur Sep 14 '18 at 7:22
  • 2
    i would do almost exactly the same thing, except i would insert a zero-width vertical rule with the desired depth instead of the \vspace. (picking the location carefully is the important thing with either method.) – barbara beeton Sep 14 '18 at 16:20
  • @barbarabeeton What is the difference between \vspace{1cm} and (say) \rule[-.3\baselineskip]{0pt}{1cm}? (After reading tex.stackexchange.com/a/30065 I understand a little about the technical differences, but what is the practical difference?) – banbh Sep 18 '18 at 13:53
6

Here's a solution implemented in expl3 that borrows from some code in TeX by Topic (See the \everypar macro on page 72).

You have to set your paragraph in a \vbox. Then the \SpaceParagraph macro breaks the paragraph into lines and inserts the specified space under the specified lines.

The argument for \SpaceParagraph is: {<line number>, <skip>, <line number>, <skip>, …}. It's not super clever and there is no error checking. In particular, you should make sure that you have an even number of arguments, the line numbers are integers and the skips have a unit. You should also specify your line numbers in order from lowest to highest. If you don't do these things it will break. :-)

MWE

\documentclass{article}

\usepackage{lipsum}
\usepackage{xparse}

\ExplSyntaxOn

\box_new:N \g__kenny_line_box
\int_new:N \g__kenny_lineno_int
\clist_new:N \g__kenny_spacespec_clist

\cs_new:Npn \__kenny_spacepar:
  {
    \box_set_to_last:N \g__kenny_line_box
    \if_box_empty:N \g__kenny_line_box
    \else:
      \unskip
      \unpenalty
      { \__kenny_spacepar: }
      \clist_get:NN \g__kenny_spacespec_clist \l_tmpa_tl
      \quark_if_no_value:NF \l_tmpa_tl
        {
          \int_compare:nNnT { \g__kenny_lineno_int } = { \l_tmpa_tl }
            {
              \clist_gpop:NN \g__kenny_spacespec_clist \l_tmpa_tl
              \clist_gpop:NN \g__kenny_spacespec_clist \l_tmpb_tl
              \box_set_dp:Nn \g__kenny_line_box { \l_tmpb_tl }
            }
        }
      \hbox:n { \box_use_drop:N \g__kenny_line_box }
      \int_gincr:N \g__kenny_lineno_int
    \fi:
  }

\NewDocumentCommand \SpaceParagraph { m }
  {
    \clist_gset:Nn \g__kenny_spacespec_clist { #1 }
    \int_gset:Nn \g__kenny_lineno_int { \c_one }
    \par
    \__kenny_spacepar:
  }

\ExplSyntaxOff

\begin{document}
\vbox{%
  \lipsum*[1]\SpaceParagraph{3, 5mm, 4, 10mm}
}
\end{document}

enter image description here

  • 2
    i haven't tested this, but i suspect that if there are no descenders in the last line of the paragraph, it might end up too close to the following paragraph. so it would be a good idea to put a strut at the end of the last line. that's not so easy if a lipsum paragraph is used, since that ends with a \par, and the strut must be inserted before the \par. – barbara beeton Sep 14 '18 at 16:16
  • @barbarabeeton, actually, it seems to be OK. I think the line box includes depth and I don't alter it. I notice that it works with both \lipsum and \lipsum* (which doesn't include \par) as well. – David Purton Sep 15 '18 at 2:39
  • @barbarabeeton, Oh! You mean the previous paragraph! You are right, it needs seem adjusting to behave correctly in all cases. And of course, it won't break across pages which is also a potential problem. – David Purton Sep 16 '18 at 9:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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