How can I increase the linespacing for just a few lines of code in LaTex?
[Tex/LaTex] Linespacing LaTeX for just a few lines
line-spacingpackagesspacing
line-spacingpackagesspacing
How can I increase the linespacing for just a few lines of code in LaTex?
Best Answer
The
setspace
package provides the means the change the line spacing in a very consistent (and easy) way trough environments or by a switch. Here's a small example:Note that there is some hidden information in the above example. Since LaTeX sets text on a paragraph basis, you need to ensure that you initiate a paragraph break (through an empty line or an explicit
\par
) in order for the line-spacing to take effect. This is implicitly done by thelipsum
package's\lipsum
command above.Switches should be grouped to limit the scope using something like
Switches and environment provided by
setspace
aresinĀglespacĀing
onehalfspacing
anddoublespacing
.However, the more general
\setstretch{<num>}
macro is the required interface for doing more general line-space setting.setspace
provides the interface with elements like\baselineskip
and\linespread
. See Why is the\linespread
factor as it is? for a general discussion on the choice of<num>
.Barbara mentioned the option of having an "equally wide" gap above/below the increased line spacing paragraph. The reason why it's not is because the
\baselineskip
is paragraph-based. So, the paragraph following the change has a different (smaller)\baselineskip
, and is therefore visually closer. A naive approach to correct for this is given below using some "fudging":The idea here is to insert a vertical strut -
\fudgestrut
- using the increased\baselineskip
within the first line of the paragraph following the line spacing change. I'm sure this process can be automated somewhat, but the use-case doesn't warrant such investigation.