1

I'm currrently using the complexity package, where I have defined a lot of new commands for complexity classes, and I'm writing my document using the libertine font. I want to use the regular math font for everything except for the commands rendered by the complexity package... That is, I want the commands defined by the complexity package to use the math font libertinust1math while the rest of the math should be rendered in the usual math font.

I imagine there must be a simple command to change the font of specific commands, but I don't know that it is.

  • 1
    Are you using LuaLaTeX? You could probably use \fontspec and \newfontfamily. – Ingmar Jun 05 '22 at 11:44
  • 1
    Mixing Latin Modern Math with Libertine? Oh, no! – egreg Jun 05 '22 at 12:38
  • For the rest sentence, I don't think there's one. You might have to resort to learning TeX programming and copy paste the appropriate lines from the font file, depends on the cases (for XeLaTeX/LuaLaTeX it's a bit easier with fontspec – user202729 Jun 05 '22 at 12:49
  • 1
    @egreg What would be the right math font for Libertine? I've seen libertinust1math but it is rather ugly, so I tried newtxmath instead, which is the combination the ACM proceedings use, I believe. Is there a better combination you suggest? – Noel Arteche Jun 05 '22 at 15:33

2 Answers2

1

The following does what was requested in the question (tested with pdflatex). I leave it up to the author to choose matching fonts.

\documentclass{article}
\usepackage[T1]{fontenc}
\usepackage{lmodern}     % for instance
\usepackage{amsmath}     % only for stuff in the last formula
\usepackage{amsfonts}    % ditto
\usepackage{complexity}

\makeatletter % Define math alphabet \mathsfliti using LibertinusT1Math (adapted from % libertinust1math.sty) \unless\ifdefined\iflibus@sansmath \newif\iflibus@sansmath \fi

\DeclareFontEncoding{LS1}{}{} \DeclareFontSubstitution{LS1}{libertinust1math}{m}{n} \DeclareMathAlphabet{\mathsfliti}{LS1}{libertinust1mathsf}{m}{n}

% Adapted from complexity.sty: use \mathsfliti for everything in complexity.sty \renewcommand{\complexity@fontcommand}{\mathsfliti} \renewcommand{\lang}[1]{{\ensuremath{\mathsfliti{#1}}}} \renewcommand{\func}[1]{{\ensuremath{\mathsfliti{#1}}}} \makeatother

\begin{document}

% \showoutput % Uncomment to verify which font is used for which glyph [ \begin{array}{l} \P \subseteq \NP\ \CVP \leq_m \SAT\ \polylog \in O(\poly)\ \PSPACE \subseteq \EXP\ \SAT \leq_T \MaxSAT\ \polylog \in \Omega(\llog) \end{array} ]

\newcommand{\diff}{\mathop{}!d}% https://tex.stackexchange.com/a/84308/73317 [ \forall z\in \mathbb{C}, \Bigl( \Re(z) > 0 \implies \Gamma(z) = \int_{0}^{+\infty} x^{z-1} e^{-x} \diff x \Bigr) ] \end{document}

enter image description here

frougon
  • 24,283
  • 1
  • 32
  • 55
1

The acmart class uses Linux Libertine fonts for text and does

\RequirePackage[libertine]{newtxmath}

If you do the same (with \usepackage, of course), you'll get what you want and avoid mixing visually incompatible fonts.

Using the code provided by frougon

\documentclass{article}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{amsmath}
\usepackage{complexity}

\begin{document}

[ \begin{array}{l} \P \subseteq \NP\ \CVP \leq_m \SAT\ \polylog \in O(\poly)\ \PSPACE \subseteq \EXP\ \SAT \leq_T \MaxSAT\ \polylog \in \Omega(\llog) \end{array} ]

\newcommand{\diff}{\mathop{}!d}% https://tex.stackexchange.com/a/84308/73317 [ \forall z\in \mathbb{C}, \Bigl( \Re(z) > 0 \implies \Gamma(z) = \int_{0}^{+\infty} x^{z-1} e^{-x} \diff x \Bigr) ] \end{document}

enter image description here

This will use Linux Biolinum for the sans serif. If you want the sans serif used by libertinust1math, then you can do

\documentclass{article}
\usepackage{libertine}
\usepackage[libertine]{newtxmath}
\usepackage{amsmath}
\usepackage{complexity}

\DeclareFontEncoding{LS1}{}{} \DeclareFontSubstitution{LS1}{libertinust1mathsf}{m}{n} \DeclareMathAlphabet{\mathsf}{LS1}{libertinust1mathsf}{m}{n} \SetMathAlphabet{\mathsf}{bold}{LS1}{libertinust1mathsf}{b}{n}

\begin{document}

[ \begin{array}{l} \P \subseteq \NP\ \CVP \leq_m \SAT\ \polylog \in O(\poly)\ \PSPACE \subseteq \EXP\ \SAT \leq_T \MaxSAT\ \polylog \in \Omega(\llog) \end{array} ]

\newcommand{\diff}{\mathop{}!d}% https://tex.stackexchange.com/a/84308/73317 [ \forall z\in \mathbb{C}, \Bigl( \Re(z) > 0 \implies \Gamma(z) = \int_{0}^{+\infty} x^{z-1} e^{-x} \diff x \Bigr) ] \end{document}

enter image description here

egreg
  • 1,121,712