1

I am trying to use calc to perform a basic multiplication of arguments of a user-defined command, like this:

\def\Verdana#1{
 \normalfont
 \fontsize{#1}{#1 * \real{1.2}}
 \VerdanaFont
 \selectfont}

But it is not working properly. Not sure if the length is being rounded to integer, of if the calc multiplication just can't operate on command parameters.

EDIT 1: I tried to change 1.2 to 12, but the output is the same. Thus, not really a rounding issue. Looks more like calc not liking to multiply parameter values.

EDIT 2: Temporary solution:

 \def\Palatino#1{
   \newlength{\tmpLength}
   \setlength{\tmpLength}{#1 * \real{1.2}}
   \normalfont\fontsize{#1}{\tmpLength}\PalatinoFont\selectfont}

Keeping no answer, in case someone can explain why the length is needed.

  • Please provide a full MWE. What I hacked together, I can't see the problem you are having. So, obviously, my MWE doesn't look like yours. – Steven B. Segletes Aug 30 '17 at 14:12
3

It's not really clear what you want to achieve, but you can do

\documentclass{article}
\usepackage{fontspec,xfp}
\usepackage{lipsum}

\newfontfamily{\PalatinoFont}{TeX Gyre Pagella}

\newcommand{\Palatino}[1]{%
  \normalfont
  \fontsize{#1}{\fpeval{1.2*(#1)}}%
  \PalatinoFont
}

\begin{document}

\Palatino{15}\lipsum[2]

\Palatino{5}\lipsum[3]

\end{document}

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.