TransWikia.com

Reduce line spacing when using smaller font size in an environment

TeX - LaTeX Asked on August 31, 2021

I am typesetting a collection of short stories found on Project Gutenberg, where most stories are introduced by a comment of the editor and/or an historical note.

In my understanding these blurbs are less relevant than the stories, so I decided to put them in an appropriate environment and typeset them in a smaller font

documentclass[11pt]{memoir}
chapterstyle{tandh}
newenvironment{blurb}{footnotesize}{bigskip}
begin{document}
chapter{Charan}
begin{blurb}
  Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.
end{blurb}

In the days of King Sung-jong (A.D. 1488-1495) one of Korea's noted
men became governor of Pyong-an Province. Now Pyong-an stands first
of all the eight provinces in the attainments of erudition and polite
society. Many of her literati are good musicians, and show ability
in the affairs of State.
end{document}

that, coupled with the memoir class, produces the following

charan

as you can see, the distance between the lines in the blurb is too much, I have played with linespread (even negative values…) but nothing changed.

OTOH, when I have a long footnote, I know that the line spacing is appropriately reduced…

How can I reduce the distance between the lines in my environment to take into account the smaller font?

4 Answers

You can change line spacing with begin{Spacing}{factor} ... end{Spacing}, see page 51 of memoir class

For example the following code

documentclass[11pt]{memoir}
chapterstyle{tandh}
newenvironment{blurb}{footnotesize}{bigskip}
begin{document}
chapter{Charan}
begin{blurb}
begin{Spacing}{0.8}
  Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.
end{Spacing}
end{blurb}

In the days of King Sung-jong (A.D. 1488-1495) one of Korea's noted
men became governor of Pyong-an Province. Now Pyong-an stands first
of all the eight provinces in the attainments of erudition and polite
society. Many of her literati are good musicians, and show ability
in the affairs of State.
end{document}

produce the following output: enter image description here

Answered by Luis Turcio on August 31, 2021

How to change line spacing in an environment

If you look at the source code of setspace package, it can be seen that line spacing can be changed by modifying baselinestretch. However, if you attempt to modify baselinestretch in the following way, it won't work.

begin{minipage}{linewidth}
renewcommand{baselinestretch}{0.8}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.
end{minipage}

Why? The answer is that you are missing a par command at the end of the environment. That is, the following example will have line spacing correctly modified. This is the the same for linespread command as well: one needs to terminate the paragraph with par for the modification to take effect.

begin{minipage}{linewidth}
renewcommand{baselinestretch}{0.8}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background. 
par
end{minipage}

Therefore, you can rewrite the environment as follows. You can change 0.8 to your desired value.

newenvironment{blurb}{footnotesizerenewcommand{baselinestretch}{0.8}}{parbigskip}

Setting line spacing programmatically

In the following example, I defined blurb* environment, which takes a font size command as argument. The line spacing will be automatically determined by a user-defined mathematical expression.

documentclass[11pt]{memoir}
usepackage{expl3}
usepackage{xparse}

chapterstyle{tandh}

begin{document}


makeatletter
ExplSyntaxOn

% get base fontsize
fp_new:N l_base_fontsize_fp
fp_set:Nn l_base_fontsize_fp {f@size}

fp_new:N l_now_fontsize_fp
fp_new:N l_new_baselinestretch_fp

% the command to compute new baselinestretch based on
% base fontsize and current fontsize
cs_new:Npn __compute_baselinestretch {
    % set it to the sqrt of ratio between two fontsizes
    fp_set:Nn l_new_baselinestretch_fp { sqrt(l_now_fontsize_fp / l_base_fontsize_fp) }
}

DeclareDocumentEnvironment{blurb*}{m}{
    group_begin:
    #1
    % get current fontsize
    fp_set:Nn l_now_fontsize_fp {f@size}
    % compute new baselinestretch
    __compute_baselinestretch
    % use new baselinestretch
    exp_args:NNx renewcommand baselinestretch {fp_use:N l_new_baselinestretch_fp}
    selectfont
}{
    pargroup_end:bigskip
}

ExplSyntaxOff
makeatother

chapter{Charan}

begin{blurb*}{tiny}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.

meaningbaselinestretch
end{blurb*}

begin{blurb*}{footnotesize}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.

meaningbaselinestretch
end{blurb*}

begin{blurb*}{normalsize}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.

meaningbaselinestretch
end{blurb*}

begin{blurb*}{large}
Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.

meaningbaselinestretch
end{blurb*}


end{document}

enter image description here

Reference

Answered by Alan Xiang on August 31, 2021

I guess the environment is for some introductory text after the chapter title.

You're missing par. If you don't end the paragraph before ending the group formed by the environment, the value of baselineskip set by footnotesize would be forgotten before the paragraph is split into lines, so the baselineskip value would be the one for the normal font size.

documentclass[11pt]{memoir}
chapterstyle{tandh}

newenvironment{blurb}
  {parfootnotesize}
  {paraddvspace{bigskipamount}}

begin{document}

chapter{Charan}

begin{blurb}
  Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it still has
  the fresh, sweet flavour of a romance of yesterday; albeit the setting
  of the East provides an odd and interesting background.
end{blurb}

In the days of King Sung-jong (A.D. 1488-1495) one of Korea's noted
men became governor of Pyong-an Province. Now Pyong-an stands first
of all the eight provinces in the attainments of erudition and polite
society. Many of her literati are good musicians, and show ability
in the affairs of State.

end{document}

enter image description here

Answered by egreg on August 31, 2021

Reinventing the chapterprecis memoir's command?

documentclass[11pt]{memoir}
chapterstyle{tandh}
begin{document}
tableofcontents
chapter{Charan}
chapterprecis{% also in toc 
  Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it ...}
In the days of King Sung-jong (A.D. 1488-1495) one of Korea's noted
men became governor of Pyong-an Province. 
end{document}

But if you are picky about how it has to look ...

documentclass[11pt]{memoir}
chapterstyle{tandh}
setlength{prechapterprecisshift}{-1baselineskip}
renewcommand*{precisfont}{slshapebgroupfootnotesizesffamily}
renewcommand{prechapterprecis}{
bgroupvspace*{prechapterprecisshift}parprecisfont}
renewcommand{postchapterprecis}{paregroupbigskip}
begin{document}
mainmatter
tableofcontents
mainmatter
chapter{Charan}
chapterprecishere{ % only in text
  Some think that love, strong, true, and self-sacrificing, is not to
  be found in the Orient; but the story of Charan, which comes down
  four hundred years and more, proves the contrary, for it .....}
In the days of King Sung-jong (A.D. 1488-1495) one of Korea's noted
men became governor of Pyong-an Province. 
end{document}

Answered by Fran on August 31, 2021

Add your own answers!

Ask a Question

Get help from others!

© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP