0

I am trying to change the default font size in my document. I am using the fontspec package in XeLaTeX. This seems achievable using \defaultfontfeatures{Scale=2.5}, but this only takes effect after I add a \setmainfont{...} command. The problem is that I do not want to change the main font. How do I get the font to scale without explicitly selecting a font? The funny thing is that the math mode part of my document shows up as scaled even though the regular text doesn't. I'm assuming the unicode-math package must be selecting a font after this, but it's not explicit. Any advice on this would be VERY appreciated.

\documentclass{article}

\usepackage{fontspec}
\usepackage{unicode-math}
\defaultfontfeatures{Scale=2.5}
\linespread{3}
%\setmainfont{...} %%Putting the name of a font in this command makes it do what I want, but I don't want to specify a font.

\begin{document}

A physical dipole has a separation $\symbf{d}$ between two charges $\pm q$ and a dipole moment $\symbf{p}$:
$$\symbf{p}\equiv q\symbf{d}$$

\end{document}
  • Off-topic, but using $$ to delimit displayed equations is not recommended. See tex.stackexchange.com/q/503 – Troy Dec 10 '17 at 3:54
  • The default fonts are loaded together with fontspec, so they aren't subject to subsequent \declarefontfeatures declarations. – egreg Dec 10 '17 at 22:58
1

\renewcommand{\normalsize}{\fontsize{42}{46}\selectfont} in the preamble yields:enter image description here

Which hopefully is what you're looking for

0

Not sure if it is precisely what you want, but the Koma-Script classes allow to choose whatever (absolute) size of fonts you prefer thanks to their fontsize class parameter. E.g., for their scrartcl class (equivalent to the usual article class):

\documentclass[fontsize=25pt]{scrartcl}

\usepackage{fontspec}
\usepackage{unicode-math}
%\defaultfontfeatures{Scale=2.5}
\linespread{3}
%\setmainfont{...} %%Putting the name of a font in this command makes it do what I want, but I don't want to specify a font.

\begin{document}

A physical dipole has a separation $\symbf{d}$ between two charges $\pm q$ and a dipole moment $\symbf{p}$:
\[\symbf{p}\equiv q\symbf{d}\]

\end{document}

enter image description here

  • Thanks. This gives the desired effect, but the scrartcl class introduces some undesired behavior in the rest of my document (like sans serif fonts in section titles). I'm sure there are ways to fix these, too, but I was hoping there would be a solution using article. – Trevor Smith Dec 10 '17 at 21:54
0

One method of general applicability (does not involve math) is to use setmainfont in a way that does not change anything. It seems that \setmainfont sets some kind of flag, which needs to be seen by \addfontfeatures. The following MWE works in XeLaTeX and LuaLaTeX. It uses \setmainfont to echo whatever your default font actually is, at that point; if you didn't choose one, it echoes Latin Modern Roman, the standard default:

\documentclass{article}
\usepackage{fontspec}
\defaultfontfeatures{Scale=2.5}
\usepackage{xifthen}
\usepackage{ifxetex}
\ifxetex
  \ifthenelse{\equal{\rmdefault}{lmr}}{
    \setmainfont{lmroman12-regular.otf} % can be improved
  }{}
\else
  \ifthenelse{\equal{\rmdefault}{lmr}}{
    \setmainfont{Latin Modern Roman}
  }{}
\fi
\begin{document}
Hello!\par
\rmdefault
\end{document}

LuaLaTeX can find Latin Modern Roman by font family name, but in many cases XeLaTeX can only find it by font file name. The line marked "can be improved" is where you would add the font file names for bold and italics, as fontspec options to the main font.

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.