28

I'd like to set the main font size (i.e. all text which isn't a heading or something else with an explicit font size) to a particular font size, in this case, 9.5pt.

I can't use the default package options. I also can't use \fontsize{9.5pt}{9.5pt}\selectfont at the start of my document because then latex (xelatex 3.1415926-2.4-0.9998 (MiKTeX 2.9)) selects some other font than the font set with \setmainfont.

What's a nice, simple way to set the default font size, analogous to the \setmainfont command from fontspec?

I have no version information about fontspec.

Marcin
  • 3,111
  • 2
    \setmainfont[Ligatures=TeX,Scale=0.95]{Some Nice Font} – egreg Oct 31 '13 at 21:11
  • Please provide a bit more information about how the problem arises. Ideally, the information would come in the form of an MWE (minimum working example, starting with \documentclass and ending with \end{document}. Please also provide information about the version of XeLaTeX and fontspec that you use. – Mico Oct 31 '13 at 21:11
  • 1
    @egreg Scaling doesn't sound right, not least because the final size depends on whatever is set by the package. – Marcin Oct 31 '13 at 21:12
  • 2
    @Mico I'm not sure what you want in my minimal working example. I know what an MWE is, but I don't see what you would get from it. All the information is already in this post. – Marcin Oct 31 '13 at 21:13
  • Then build a package yourself, changing from size10.clo, to use what you need. But it's not at all clear what you want. – egreg Oct 31 '13 at 21:15
  • 6
    @egreg Surely you realise what an incredibly unhelpful response that is. – Marcin Oct 31 '13 at 21:16
  • An MWE would provide further important information -- not contained in your posting -- such as real error and/or warning messages that could shed light on what's going on. – Mico Oct 31 '13 at 21:16
  • 4
    @Mico There are no error messages. The behaviour is as described. Not every question requires an MWE. – Marcin Oct 31 '13 at 21:17
  • 8
    @Marcin You're saying that XeLaTeX selects a different font; this is not what one expects and XeLaTeX does normally; so a MWE is needed. However, my proposal will work, because when a 10pt font is requested, XeLaTeX will use it scaled, so you'll get 9.5pt. – egreg Oct 31 '13 at 21:19
  • 5
    It may be the case that not every question requires an MWE. Experience does show, though, that the odds that someone will come up with a diagnosis and, better still, a solution to the problem(s) you describe improve dramatically if an MWE is, in fact, provided. – Mico Oct 31 '13 at 21:25
  • 3
    @Mico If you don't like the way I've asked this question, feel free not to answer it. – Marcin Oct 31 '13 at 21:46

3 Answers3

29

I can't see what's wrong with scaling the main font:

\documentclass{article}
\usepackage{fontspec}
\setmainfont[Ligatures=TeX,Scale=0.95]{Linux Libertine O}

\usepackage{blindtext}

\linespread{0.95833} % 11.5/12

\begin{document}
\blinddocument
\end{document}

With \Large you'll get 13.4 instead of 14pt; it doesn't seem a big difference (and I'd say it's even better). At \Huge the font will be 24pt instead of 25pt.

enter image description here

This can be supplemented by appropriate \DeclareMathSizes commands, where the last three arguments are scaled at 95%:

\DeclareMathSizes{5}{4.75}{4.75}{4.75}
\DeclareMathSizes{6}{5.7}{4.75}{4.75}
\DeclareMathSizes{7}{6.65}{4.75}{4.75}
\DeclareMathSizes{8}{7.6}{5.7}{4.75}
\DeclareMathSizes{9}{8.55}{5.7}{4.75}
\DeclareMathSizes{\@xpt}{9.5}{6.65}{4.75}
\DeclareMathSizes{\@xipt}{10.4}{7.6}{5.7}
\DeclareMathSizes{\@xiipt}{11.4}{7.6}{5.7}
\DeclareMathSizes{\@xivpt}{13.68}{9.5}{6.65}
\DeclareMathSizes{\@xviipt}{16.42}{11.4}{9.5}
\DeclareMathSizes{\@xxpt}{19.7}{13.68}{11.4}
\DeclareMathSizes{\@xxvpt}{23.64}{19.7}{16.42}
egreg
  • 1,121,712
  • Unfortunately, this does not scale math, which the \normalsize solution does. – Alexander Pavlov Dec 03 '15 at 16:09
  • @AlexanderPavlov Sorry, but scaling math was not required; redefining \normalsize is definitely not the way to go. There's the much safer \DeclareMathSizes command. – egreg Dec 03 '15 at 16:10
  • Yes, that definitely looks like dangerous tinkering and too low-level. But see my comment below for @Marcin's answer, is a package setting default document font size, including math, to an arbitrary integer parameter possible? Being stuck with standard 10, 11, 12pt while having all of the fontspec's modern might at your disposal is really silly. – Alexander Pavlov Dec 03 '15 at 16:26
  • @AlexanderPavlov I added the suitable \DeclareMathSizes commands – egreg Dec 03 '15 at 17:08
  • @AlexanderPavlov A good solution is to load unicode-math and \setmathfont with scale=MatchLowercase. – Davislor Dec 03 '15 at 22:23
  • 1
    The problem with scaling the main font is that some journals require exact font sizes of various pieces of text. Is there a way to ensure that you're getting e.g., exactly 11.5pt size? – Jonathan W. Jun 18 '16 at 20:51
  • @JonathanW. If the font design size is 10pt and this matches the document class size option, Scale=1.15 should do. If you use 11pt as size option, Scale=1.04545. – egreg Jun 18 '16 at 20:57
  • @egreg, does Scale adjust all aspects of font size correctly? – Jonathan W. Jun 18 '16 at 22:34
  • @JonathanW. Yes, as far as I know. – egreg Jun 18 '16 at 22:34
  • 1
    @egreg, please see this question in regards to the issue of using Scale to specify font size. – Jonathan W. Jun 19 '16 at 05:08
3

Unfortunately, the only way to do this (without, perhaps, using the KOMA packages), is to redefine \normalsize:

\makeatletter
\renewcommand\normalsize{%
\@setfontsize\normalsize{9.5pt}{11.5pt}% Will look incredibly crabbed if line height is too small
\abovedisplayskip 10\p@ \@plus2\p@ \@minus5\p@%
\abovedisplayshortskip \z@ \@plus2\p@%
\belowdisplayshortskip 5\p@ \@plus2\p@ \@minus3\p@%
\belowdisplayskip \abovedisplayskip%
\let\@listi\@listI%
}
\normalsize  
\makeatother

Code adapted from: http://wiki.lyx.org/FAQ/ChangeFontUsingLatex

Marcin
  • 3,111
  • 4
    It's disappointing to me that people downvote without explaining their downvotes. Now I have no idea whether this is a useful answer or not without doing my own investigation. I know that some people believe in downvoting answers by the person asking the question. (I don't.) Perhaps that's the reason. – Mars Dec 19 '14 at 17:12
  • 3
    Hey, was looking to scale an entire document including math, and yours was the only answer which accomplished that! However, to get a consistent document for large sizes, you really have to redefine \small, \large, \huge etc., essentially redo from scratch what the .clo files do for standard document classes. Interesting that header comments in size12.clo mention classes.dtx with options 12pt. So maybe the .clo files can actually be computed with the base size as a parameter, and one might even try to roll a package that does this for any size. It won't be perfect but sounds tempting. – Alexander Pavlov Dec 03 '15 at 16:23
2

If you can afford to use a different class, then the Koma-Script ones will give you a lot more flexibility in terms of size:

\documentclass[fontsize=11.5pt]{scrartcl}

This has the added advantage that it applies to all fonts in the document (tt, etc), without requiring individual scaling.

Clément
  • 4,004