I have been having trouble with this for some time by now. I want a command \relfontsize{<fontstep>}{<spreadstep>}
that works exactly like \fontsize{<fontsize>}{<spreadsize>}
, except that it works relatively: It multiplies the font size by 1.20^(<fontstep>)
and the line spreading by 1.20^(<fontspread>)
. So what happens is
fontsize ---> (1.20)^(<fontstep>) * oldfontsize
linespread ---> (1.20)^(<spreadstep>) * oldlinespread
(here <fontstep>
and <spreadstep>
are integers, which may take negative values)
I have <fontstep>
more or less working (using this other question of mine), but <spreadstep>
causes trouble.
(I do not know if this is going to matter, but I am compiling my document using LuaLaTeX.)
\documentclass[10pt]{memoir}
% Commands that allow me to use powers in \dimexpr expressions:
\usepackage{expl3}
\ExplSyntaxOn
\cs_new_eq:NN \fpeval \fp_eval:n
\cs_new_eq:NN \fptodim \fp_to_dim:n
\ExplSyntaxOff
\makeatletter
\def\getcurrentfontsize{\f@size pt}
\makeatother
\newcommand*\relfontsize[2]{
\fontsize{\dimexpr\fpeval{1.2^(#1)}\dimexpr \getcurrentfontsize\relax}{%
%please do some magic for me
}\selectfont%
}
\begin{document}
First paragraph, normal size.
{
\relfontsize{1}{2} Let's increase the font size by 20 percent and the line spreading
by 20 percent two times (that is, by 44 percent), BOTH numbers relative to the first paragraph.
\relfontsize{1}{1} Let's increase both further by 20 percent compared to the last paragraph
}
Now we're back at the old size.
\end{document}