183

This is my code

\documentclass[12pt,a4paper]{book} 
\renewcommand{\baselinestretch}{1.5} 
\begin{document}
\include{Chapter1}
\end{document}

I have please a question:

I would change the line spacing (1.5 --> 1.0) of a page inside the document and not the entire document and the size of the words, how can I do please?

researcher
  • 4,555
  • after using your code my chapters start being displayed on the left side (which is odd and wrong) - how can I make latex display them on the right (also known as the right) side again? I'm using the {book} class. – TheChymera Nov 14 '13 at 19:19

5 Answers5

166

You can use \setstretch{}. If you want to only affect a certain content you can use it with a group.

enter image description here

You can also apply any size changing switches such as \small or \tiny inside the {} group as well.

Code

\documentclass[12pt,a4paper]{book} 
\usepackage{xcolor}
\usepackage{lipsum}
\usepackage{setspace}

\renewcommand{\baselinestretch}{1.5}

\begin{document} \lipsum[1] {\setstretch{1.0}\color{blue} \lipsum[2] } \lipsum[3] \end{document}

Peter Grill
  • 223,288
  • 15
    Just remember to end the paragraph before the final } (\lipsum adds a \par at its end). Using \linespread{1.5} (or some command of setspace) is better than redefining \baselinestretch. – egreg Nov 22 '12 at 21:47
  • 1
    @Peter Thank you so much :) Please i have another question: i have used \documentclass[12pt,a4paper]{book} and i'd like to change the size 12 to 10 of one paragraph inside the document, Have you an idea please ? – researcher Dec 21 '12 at 13:25
  • 2
    @researcher: You could try using the answers from LaTeX — specify font point size? and keep the change to be within a group (either inside a brace group {}, or within \begingroup, \endgroup pair. If that does not help you achieve the desired results you should post a separate question. Also, please note that you should use the full username with the @ syntax. I was only notified of this as it was a comment to an answer of mine. – Peter Grill Dec 21 '12 at 19:01
  • i set \fontsize{10} just before the text ? – researcher Dec 21 '12 at 19:19
  • @researcher: fontsize has two parameters, not one. – Peter Grill Dec 21 '12 at 19:20
  • yes it's \baselineskip but i don't understand its role ? – researcher Dec 21 '12 at 19:26
  • @researcher: As this discussion is not related to "line spacing" which is what this question is about, please post a new question. You should reference any questions that are relevant in this new question. – Peter Grill Dec 21 '12 at 19:39
  • Change line spacing of a page and size police inside the document--> its mentionned in the title, i should ask in a new discussion ? – researcher Dec 21 '12 at 21:06
  • @researcher: Yes I see that is mentioned in the title, but I would suggest you change this title to remove that and post a separate question regarding font size. That way it is more likely to be helpful to others as the two questions should be easier to find. And, you should also reference the question I linked to and explain why that did not solve your issue. The best way would be to compose a fully compilable MWE including \documentclass and the appropriate packages that illustrates how the linked question did not provide a solution. – Peter Grill Dec 21 '12 at 21:13
  • Very nice and neat solution. Thank you. – Hesham Eraqi Nov 30 '20 at 21:39
  • @PeterGrill: I know this is an old answer but the given code does not produce the desired output. No change in linespacing. Is setspace depreciated? Or is there some problem on my end? Using MacTeX current installation with TeXshop version 4.64. – Sandy G Sep 08 '21 at 19:32
  • @SandyG: Seems to work for me with TeXLive 2021. Don't think the version of TeXShop is related, but mine is 4.67. I suggest you post a new question, include a fully compilable MWE including \documentclass and the appropriate packages that sets up the problem. Also, you may want to use \listfiles to display the version info and include that in the question. I suspect something is out of date for you. – Peter Grill Sep 09 '21 at 09:25
  • It's not working for me with TexLive 2021 either. I'm using it inside a Minipage. Is it supposed to be that way (not working inside a minipage)? BTW, \linespread{} is not working either. – Andyc Nov 30 '21 at 11:35
  • 1
    @Andyc: Seems to work for me inside a minipage with TeXLive 2021. I suggest you post a new question and include a fully compilable MWE including \documentclass and the appropriate packages that reproduces the problem. Also, include a \listfiles before \begin{document}. This will output the versions of the pacakges and including that in your question will help to determine if some of your packages are not up to date. – Peter Grill Nov 30 '21 at 17:05
34

Alternatively, the following solution is a bit cleaner:

\documentclass[12pt,a4paper]{book} 
\usepackage{lipsum}
\usepackage{setspace}

\begin{document}

\onehalfspacing % Set line spacing to 1.5

\lipsum[1]

\singlespacing % Reset line spacing to 1 from here on \lipsum[2] \onehalfspacing % Reset line spacing to 1.5 from here on

\lipsum[3] \end{document}

For other values, you can use e.g. \setstretch{1.125} instead of \singlespacing and \onehalfspacing.

The advantage of this method is that you don't need a closing statement, such as end{} or a curly bracket.

ATH
  • 441
28

Other values

Other line spacing values that lie in between onehalf, single and double can also be achieved with:

\usepackage{setspace}

\begin{spacing}{1.125} … \end{spacing}

  • Note that this solution increases the spacing of all lines, if you have e.g. 2 lines, both will have the spacing of 1.125 – barfoos Sep 02 '22 at 07:47
1

Instead of redefining \baselinestretch, you can set a new value to \linespread and apply the changes with \selectfont:

\documentclass{article}
\begin{document}

\linespread{1.0}\selectfont Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat.

\linespread{2.5}\selectfont Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat.

\linespread{1.5}\selectfont Lorem ipsum dolor sit amet, consectetur adipisici elit, sed eiusmod tempor incidunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquid ex ea commodi consequat.

\end{document}

preview

finefoot
  • 529
  • 5
  • 15
0

A friendly reminder for everyone using the memoir class that it provides its own mechanisms for line spacing:

\begin{Spacing}{0.9}
      tightly spaced text
\end{Spacing}

There are also SingleSpace, OnehalfSpace and DoubleSpace environments; starred versions of those that do not automatically add \vskip\baselineskip at the end; various crutches to fine-tune everything; etc. Take a look at p. 51 of texdoc memoir.

ScumCoder
  • 1,639