3

The font Open Sans offers various font weights like, Light, Condensed Light, Regular, Semibold, Bold and Extrabold.

"Regular" and "Bold" are naturally the defaults for \mdseries and bfseries, but I'd prefer "Light" and "Semibold" to be the defaults.

How can I redefine the default font weights in a way, that also understands them and can detect-all?

\documentclass{beamer}

\usepackage[utf8]{luainputenc}
\usepackage[T1]{fontenc}
\usepackage[default]{opensans}
\usepackage{siunitx}

\begin{document}

\sisetup{detect-all}

Regular numbers and unit: \SI{42}{\micro\meter}\par
\textit{Regular italic numbers and unit: \SI{42}{\micro\meter}}\par
\textbf{Bold numbers and unit: \SI{42}{\micro\meter}}\par
\textbf{\textit{Bold italic numbers and unit: \SI{42}{\micro\meter}}}\par

\medskip
But I actually want:
\smallskip

\sisetup{detect-none}

{\fontfamily{fos}\fontseries{l}\fontshape{n}\selectfont%
Regular numbers and unit: \SI{42}{\micro\meter}\par
\fontfamily{fos}\fontseries{l}\fontshape{it}\selectfont%
Regular italic numbers and unit: \SI{42}{\micro\meter}\par
\fontfamily{fos}\fontseries{sb}\fontshape{n}\selectfont%
Bold numbers and unit: \SI{42}{\micro\meter}\par
\fontfamily{fos}\fontseries{sb}\fontshape{it}\selectfont%
Bold italic numbers and unit: \SI{42}{\micro\meter}\par
}

\medskip
But \emph{detect-all} of siunitx fails and I'd like to use the commands above.

\end{document}

I thought about creating an new font composed from the sub fonts of Open Sans I'd like to use:

\DeclareFontFamily{T1}{fosn}{}
\DeclareFontShape{T1}{fosn}{m}{n}{<-> ssub * fos/l/n }{}
\DeclareFontShape{T1}{fosn}{b}{n}{<-> ssub * fos/sb/n }{}
\DeclareFontShape{T1}{fosn}{m}{it}{<-> ssub * fos/l/it }{}
\DeclareFontShape{T1}{fosn}{b}{it}{<-> ssub * fos/sb/it}{}

\renewcommand{\sfdefault}{fosn}
\renewcommand{\rmdefault}{fosn}
\renewcommand{\familydefault}{\rmdefault}
\renewcommand{\mddefault}{m}
\renewcommand{\bfdefault}{b}
\renewcommand{\seriesdefault}{\mddefault}

Which already seems to work quite good, but the greek letters still fail. Any hints?

enter image description here

I'm explicitly looking for a non-fontspec solution.

2

I finally found out how I can do what I want - important is to keep the order "LGR, T1" while using fontenc. Thanks also to egreg, for his answer here.

\documentclass{beamer}

\usepackage[utf8]{luainputenc}
\usepackage[LGR, T1]{fontenc}
\usepackage{amsmath}
\usepackage{sansmathfonts}
\usepackage[default]{opensans}
\usepackage{siunitx}

\DeclareFontFamily{T1}{fosn}{}
\DeclareFontShape{T1}{fosn}{m}{n}{<-> ssub * fos/l/n }{}
\DeclareFontShape{T1}{fosn}{b}{n}{<-> ssub * fos/sb/n }{}
\DeclareFontShape{T1}{fosn}{m}{it}{<-> ssub * fos/l/it }{}
\DeclareFontShape{T1}{fosn}{b}{it}{<-> ssub * fos/sb/it}{}

\DeclareFontFamily{LGR}{fosgreek}{}
\DeclareFontShape{LGR}{fosgreek}{m}{n}{<-> ssub * fos/l/n }{}
\DeclareFontShape{LGR}{fosgreek}{b}{n}{<-> ssub * fos/sb/n }{}
\DeclareFontShape{LGR}{fosgreek}{m}{it}{<-> ssub * fos/l/it }{}
\DeclareFontShape{LGR}{fosgreek}{b}{it}{<-> ssub * fos/sb/it}{}

\renewcommand{\sfdefault}{fosn}
\renewcommand{\rmdefault}{fosn}
\renewcommand{\familydefault}{\rmdefault}
\renewcommand{\mddefault}{m}
\renewcommand{\bfdefault}{b}
\renewcommand{\seriesdefault}{\mddefault}

\DeclareFontEncoding{LGR}{}{}
\DeclareSymbolFont{osgreek}{LGR}{fos}{l}{n}
\SetSymbolFont{osgreek}{bold}{LGR}{fos}{sb}{n}
\DeclareMathSymbol{\upmu}{\mathord}{osgreek}{`m}

\DeclareSymbolFont{osgreekit}{LGR}{fos}{l}{it}
\SetSymbolFont{osgreekit}{bold}{LGR}{fos}{sb}{it}
\DeclareMathSymbol{\mu}{\mathord}{osgreekit}{`m}

\makeatletter
\DeclareRobustCommand{\textmu}{{\usefont{LGR}{fosgreek}{\f@series}{\f@shape}\symbol{\string"6D}}}
\DeclareRobustCommand{\textohm}{{\usefont{LGR}{fosgreek}{\f@series}{\f@shape}\symbol{\string"5F}}}
\makeatother
\sisetup{math-micro=\upmu,text-micro=\textmu,
         math-ohm=\upOmega,text-ohm=\textohm}

\usepackage{mathastext}

\begin{document}

\sisetup{detect-all}

Regular numbers and unit: \SI{42}{\micro\meter}\par
\textit{Regular italic numbers and unit: \SI{42}{\micro\meter}}\par
\textbf{Bold numbers and unit: \SI{42}{\micro\meter}}\par
\textbf{\textit{Bold italic numbers and unit: \SI{42}{\micro\meter}}}\par

\[
\int \sum X_\mathrm{\mu\upmu}\mu\upmu\mathrm{\mu\upmu}A + 2 = \SI{42}{\micro\meter\ampere\gram}
\]

\end{document}

enter image description here

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.