11

I want to make a command that prints the argument with a font which is one point smaller than the current one.

For example, if a document has 11pt font, the command has to print with 10pt. If the document has 10pt font, I want the command to print with 9pt font.

I don't want this to be bound to the document's font size though. If the command is used in an environment that defines the font to be Xpt, I want the command to produce a text with the font size (X-1)pt

  • \small should be the font switch you search for. – Moriambar Apr 16 '17 at 20:54
  • @Moriambar I believe that \small is not always one point smaller, for two reasons: (1) It is an asolute size, depending on document class point size. (2) It is possible for a document class definition to make it a different size. My belief is that the OP wants to have a macro that reads the current size (which is not necessarily the document class size), calculates one point less, then applies the smaller size. – user103221 Apr 16 '17 at 20:58
  • Just for your information, \smaller does not choose a font one point smaller, but will switch to the next declaration among the predefined ones; which may be one point smaller or not. – egreg Sep 19 '17 at 8:20
7

You can also use the package relsize, which allows for what you need. Consider this MWE:

\documentclass{article}
\usepackage{relsize}
\begin{document}
This is normal size font.

\smaller

And this is one point smaller.
\end{document}

enter image description here

13

The current font size is stored in the macro \f@size:

\RequirePackage{fix-cm} % or use a scalable font
\documentclass{article}

\makeatletter
\newcommand{\oneptsmaller}[1]{%
  \begingroup
  \fontsize{\dimexpr\f@size pt-1pt}{\f@baselineskip}\selectfont
  #1%
  \endgroup
}
\makeatother

\begin{document}

\fontname\font\ \oneptsmaller{\fontname\font}

\large
\fontname\font\ \oneptsmaller{\fontname\font}

\footnotesize
\fontname\font\ \oneptsmaller{\fontname\font}

\end{document}

enter image description here

With a scalable font, say \usepackage{baskervald},

enter image description here

Note: \fontname\font is used just to show what font is currently used. In the case of ybvr8t there is no at clause because the font is at its natural size of 10pt.

  • Great answer (as always). I'm using this as an alternative to \scalebox... a good idea? I'm using it like \newcommand{\scalefont}[2][0]{... with the hard-coded 1pt replaced by +#1pt. Seems to work well. :-) – PatrickT Dec 4 '18 at 14:52
1

I personnally do it with my beloved fontspec and XelaTex. Here's an example with Libertine (because it's beautiful).

\usepackage{fontspec}
\setmainfont[Ligatures=TeX,]{Linux Libertine O}
\newfontfamily{\ninetypercent}[Scale=0.90]{Linux Libertine O}
\newcommand{\ninety}[1]{{\ninetypercent #1}

Doing this your \ninety{text} will be 10% smaller than your base font. To get a 10pt size from a 11pt you juste have to do a quick math and set the scaling parameter to 0.909 if you want to be ultra precise.

And that way you can decrease any font size by the factor you fancy (that can be 3.5%, 50%, etc...) and it would always be relative to your base fontsize.

I agree that it's a bit overkill but fontspec has a lot of very sweat features to play with.

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.