3

Consider the following LaTeX manuscript:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times}
\begin{document}
    \fontsize{50}{50}\selectfont
    Hello, world!
\end{document}

When processed with xelatex, it renders the text as follows. In particular, the font size is 50pt, as expected:

Big size

If I now move the \fontsize...\selectfont commands to the preamble, like this:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Times}
\fontsize{50}{50}\selectfont
\begin{document}
    Hello, world!
\end{document}

xelatex ignores the size specifications, and the text renders small:

Small size

Why is this?

  • 4
    If I'm not mistaken begin document contains a normalize declaration to ensure fonts gave been setup correctly. – daleif Jul 29 '17 at 6:31
  • 3
    \begin{document} calls for \normalsize which negates your font size setting. See tex.stackexchange.com/a/152085/117534 – Troy Jul 29 '17 at 6:32
  • @daleif: So there's no general way of setting the default font size in the preamble? – Evan Aad Jul 29 '17 at 6:33
  • 1
    @EvanAad try: \AtBeginDocument{\fontsize{50}{50}\selectfont} – koleygr Jul 29 '17 at 6:42
  • Use a class that supports custom font sizes and make a custom clo file. – daleif Jul 29 '17 at 9:08
3

When latex or xelatex reads \begin{document} it changes fontsize back to \normalsize... Try the next code to see it:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\renewcommand\normalsize{\fontsize{50}{50}\selectfont}

\begin{document}
   Hello, world!
\end{document}

The problem is that if you use the above command, then \Large, \small etc has also to be changed. So, a better solution is to make the command be read at begin of document:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Linux Libertine O}
\AtBeginDocument{\fontsize{50}{50}\selectfont}

\begin{document}
   Hello, world!
\end{document}

Edit: (the below is not true) This way it will give you the desired results even if you start a section, or use \Large etc

Unfortunately you have to change manually every size:

See here: Change font size of \Large etc.

5

Setting up a new "normal" font size involves also changing \Large, \small and some other commands and also spacings (e.g. for lists). Check size10.clo (loaded by your document) or scrsize11.clo (loaded by mine) to get an idea what is involved. There exist a number of .clo-files for other fontsizes, but if you want to change to an arbitrary fontsize you should better use a class like scrartcl from the KOMA-bundle:

\documentclass{scrartcl}
\KOMAoptions{fontsize=50pt}
\usepackage{fontspec}
\setmainfont{Times New Roman}


\begin{document}
Test, \Large large, \tiny tiny
\end{document}

enter image description here

2

If your aim is just to print a line with big font size, just do the declaration when you want to output the line. I see no real advantage in issuing the declaration in the preamble. There's always

\AtBeginDocument{\fontsize{50}{50}\selectfont}

that will do.

For the more general problem of defining a larger base font size, since you're using XeLaTeX or LuaLaTeX, there is a simple (or perhaps simplistic) solution to the fact that LaTeX issues \normalsize at begin document. Note you need to also set the sans and mono font at the same scale, if you use them.

\documentclass{article}
\usepackage[a3paper]{geometry}
\usepackage{fontspec}

\setmainfont{Times New Roman}[Scale=5]
\linespread{5}

\begin{document}

\section{Humongous}

Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.
Some text at 50pt size.

\end{document}

enter image description here

I add the info window

enter image description here

  • The "scale" option is less than ideal, since in the case of outline fonts (which is what I was interested in yesterday when I wrote this post), it pumps up the outline's line width relative to a font that is the same size, but not scaled. – Evan Aad Jul 30 '17 at 3:08
  • @EvanAad Click on this link: one line uses \fontsize{50}{50}, the other one the font at natural size, but defined with Scale=5. I won't tell which is which: can you guess? – egreg Jul 30 '17 at 6:23
  • No, I can't. Sorry. I thought fontspec's Scale was similar to PGF's canvas scale, which changes line widths. But then when you tell fontspec to scale a font by x amount, relative to what does it scale it? Can you specify the normal size relative to which the scaling should take place? – Evan Aad Jul 30 '17 at 6:47
  • @EvanAad Unless the font has optical sizes, such as Latin Modern, it is designed at a single size. – egreg Jul 30 '17 at 7:04
  • Is there a way to tell what this size is? – Evan Aad Jul 30 '17 at 7:12

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.