# XeLaTeX ignores \fontsize command in preamble

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:

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:

Why is this?

• 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
• \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
• @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

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.

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}

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]

\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}