1

How can I redefine the standard font size commands (\small, \normalsize, \large, etc.) when using LuaLaTeX and fontspec?

From what I read after searching online, I did the following:

\documentclass{article}
\usepackage{fontspec}
\setmainfont{Calibri}
  \renewcommand{\footnotesize}{\fontsize{9bp}{11bp}\selectfont}
  \renewcommand{\small}{\fontsize{10bp}{12bp}\selectfont}
  \renewcommand{\normalsize}{\fontsize{11bp}{13bp}\selectfont}
  \renewcommand{\large}{\fontsize{13bp}{15bp}\selectfont}
\usepackage{soul}

\begin{document}
% HEADING
\begin{flushleft}\small
  Keywords: some, relevant, words, here.
\end{flushleft}
\begin{center}\large
  \textbf{The title is very important}\\[1ex]
  \ul{A. U. Thor}\footnote{An address, Country}
\end{center}

% MAIN TEXT
filler filler filler filler filler filler filler filler

filler filler filler filler filler filler filler filler filler 
filler filler 
\end{document}

It does compile quite well, using the Calibri font I have installed. However, I then get the following warnings (absent if the redefinitions are not present):

LaTeX Font Warning: Font shape `TU/Calibri(1)/m/n' undefined
(Font)              using `TU/lmr/m/n' instead on input line 13.
(load luc: /home/equaeghe/.texlive/texmf-var/luatex-cache/generic/font/otl/lmroman12-regular.luc)
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <13.04874> not available
(Font)              size <12> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <6.52437> not available
(Font)              size <7> substituted on input line 20.
LaTeX Font Warning: Font shape `OML/cmm/m/it' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Font shape `OMS/cmsy/m/n' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Font shape `OT1/cmr/m/n' in size <4.51686> not available
(Font)              size <5> substituted on input line 20.
LaTeX Font Warning: Size substitutions with differences
(Font)              up to 1.04874pt have occurred.
LaTeX Font Warning: Some font shapes were not available, defaults substituted.

I think

  1. that no reference to lmr and cm should be there, and
  2. that there should be a way to get (closer to) the actual sizes I request.
3
  • 1
    Are you sure you have Calibri installed? I only get the warnings about the math fonts, which are expected if you don't load \usepackage{fix-cm}. Anyway, the reference to Calibri(1) seems to point to something you have not shown in the example.
    – egreg
    Commented Feb 15, 2019 at 10:46
  • And the redefinitions of \footnotesize and friends are too simplistic.
    – egreg
    Commented Feb 15, 2019 at 10:50
  • @egreg: \usepackage{fix-cm} fixed the warnings. Can you add an answer with that and (pointer to) information about properly redefining \small and friends? I can then accept that answer.
    – equaeghe
    Commented Feb 15, 2019 at 10:53

1 Answer 1

2

The warning about Calibri(1) is not produced by your example, as the font family is not defined.

The warnings about the math fonts are expected; you can remove them by loading fix-cm.

The definition of \footnotesize in the standard 10pt option is

% size10.clo, line 66:
\newcommand\footnotesize{%
   \@setfontsize\footnotesize\@viiipt{9.5}%
   \abovedisplayskip 6\p@ \@plus2\p@ \@minus4\p@
   \abovedisplayshortskip \z@ \@plus\p@
   \belowdisplayshortskip 3\p@ \@plus\p@ \@minus2\p@
   \def\@listi{\leftmargin\leftmargini
               \topsep 3\p@ \@plus\p@ \@minus\p@
               \parsep 2\p@ \@plus\p@ \@minus\p@
               \itemsep \parsep}%
   \belowdisplayskip \abovedisplayskip
}

If you don't need math or lists in footnotes or wherever you use \footnotesize, you can stick to the simplistic redefinition of just the font size. Since you're setting 11bp size, it makes sense to load article with the 11pt option and then patch to use bp instead of pt.

\documentclass[11pt]{article}
\usepackage{fontspec,fix-cm}

\usepackage{soul}
\usepackage{regexpatch}

\setmainfont{Calibri}

\makeatletter
\newdimen\bp@ \bp@=1bp
\xpatchcmd{\normalsize}{\@xipt{13.6}}{{11bp}{13bp}}{}{}
\xpatchcmd*{\normalsize}{\p@}{\bp@}{}{}
\xpatchcmd{\small}{\@xpt\@xiipt}{{10bp}{12bp}}{}{}
\xpatchcmd{\small}{\p@}{\bp@}{}{}
\xpatchcmd{\footnotesize}{\@ixpt{11}}{{9bp}{11bp}}{}{}
\xpatchcmd*{\footnotesize}{\p@}{\bp@}{}{}
\renewcommand\large{\@setfontsize\large{13bp}{15bp}}
\makeatother

\begin{document}

% HEADING
\begin{flushleft}\small
  Keywords: some, relevant, words, here.
\end{flushleft}
\begin{center}\large
  \textbf{The title is very important}\\[1ex]
  \ul{A. U. Thor}\footnote{An address, Country}
\end{center}

% MAIN TEXT
filler filler filler filler filler filler filler filler

filler filler filler filler filler filler filler filler filler 
filler filler 

{\footnotesize footnotesize\par}

\end{document}

enter image description here

1
  • 1
    Is there a * missing in \xpatchcmd{\small}{\p@}{\bp@}{}{}? Is there a specific reason why \large adapted differently?
    – equaeghe
    Commented Feb 15, 2019 at 11:43

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .