2

I'm just a poor latex user who wants customized font style. Here is my basic setting.

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}
\usepackage[T1]{fontenc}
\usepackage[lf]{Baskervaldx} % lining figures
\usepackage[bigdelims]{newtxmath} % math italic letters from Nimbus Roman (vvarbb for mathbb font)
\usepackage[bb=px, cal=cm, scr=boondoxo]{mathalfa}

\DeclareMathAlphabet{\mathup}{OT1}{\familydefault}{m}{n}

\begin{document}
$\mathup{Category}$ $\text{Category}$
\end{document}

enter image description here

My problem is when I use \mathup in my setting, it uses Computer Modern instead of the Baskervaldx that I'm using as the text font. (Obviously using \text is bad decision because it is not a math mode...) Is there a way to fix this? Is the unicode-math package work for this? (I tried but somehow my overleaf has some problem with loading this package. Maybe conflict with some other parts of my code.)

  • Welcome to TeX.SE. Your code is incomplete. Are missed \begin{document} and \end{document}. Thank you. – Sebastiano Jul 28 at 21:22
  • 1
    @Sebastiano Thanks I edited. – HLEE Jul 28 at 21:41
  • 3
    Baskervaldx is not available in the OT1 encoding and this will produce a wealth of problems, for instance with Greek uppercase letters in math. I'd suggest baskervillef instead; add also the baskerville option to newtxmath. – egreg Jul 28 at 22:04
  • I've taken the liberty of adding code to pretty-print the LaTeX code, and to fix a slight textual inaccuracy. (You had written that with your setup, \mathup was producing sans-serif output; I think you meant to write that LaTeX was using Computer Modern.) Feel free to revert. – Mico Jul 29 at 7:23
  • Thanks both for @egreg and Mico, I found this useful but it is not exactly what I wanted. I come up with an easy solution and posted it below. – HLEE Aug 11 at 23:28
2

Here's a solution which, essentially, consists of incorporating all of @egreg's suggestions.

Note that with all recommendations in place, \mathup is more or less the same as \mathrm.

enter image description here

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}

\usepackage[T1]{fontenc}
\usepackage{baskervillef} % text font (lining figures are the default)
\usepackage[bigdelims,baskerville]{newtxmath} % math font
\DeclareMathAlphabet{\mathup}{T1}{\familydefault}{m}{n}
%\usepackage[bb=px,cal=cm,scr=boondoxo]{mathalfa} % optional

\begin{document}
\obeylines
$\mathup{Category}$ $\text{Category}$
$\mathrm{abc ABC 0123568}$
$\mathup{abc ABC 0123568}$
$\text{abc ABC 0123568}$
abc ABC 0123568
\end{document}
0

In fact, I found an easy solution. Instead of \mathup or \mathrm, one can use \normalfont to use the text font and keep it upright in any environment.

\documentclass[11pt]{article}
\usepackage{amsthm,amssymb,amsmath,amsbsy}

\usepackage[T1]{fontenc}
\usepackage{baskervald}
\usepackage[bigdelims]{newtxmath} % math font
%\usepackage[bb=px,cal=cm,scr=boondoxo]{mathalfa} % optional
\newcommand{\textup}[1]{\normalfont{\text{#1}}}
\begin{document}
\obeylines
$\textup{Category}$ $\text{Category}$
\end{document}

This gives the same as \text with upright even in the theorem environment.

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.