0

Continuing \mathsfup and \symsfup for variables, we try to get bold sans-serif upright exclamation and question marks from NewTX and TeX Gyre Termes Math. However, an attempt to typeset them makes me feel as if the fonts would offer only one possible exclamation mark and only one possible question mark. Namely, feeding

\documentclass{article}
\usepackage{iftex}
\ifTUTeX
  \tracinglostchars=2
  \usepackage[math-style=ISO]{unicode-math}
  \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
  \setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Sclaing smewhat ok.
  \setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
  \setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage[helvratio=.9]{newtxtext}%%% Sclaing smewhat ok.
  \usepackage[slantedGreek,subscriptcorrection]{newtxmath}
  \DeclareMathAlphabet{\mathbfsf}{\encodingdefault}{\sfdefault}{bx}{n}
\fi
\begin{document}\noindent
\(?\mathbf{?}\mathsf{?}\mathbfsf{?}\ifTUTeX\mathbfsfup{?}\mathbfsfit{?}\fi\)\\
\(!\mathbf{!}\mathsf{!}\mathbfsf{!}\ifTUTeX\mathbfsfup{!}\mathbfsfit{!}\fi\)\\
\ifTUTeX
\(?\symbf{?}\symsf{?}\symbfsf{?}\symbfsfup{?}\symbfsfit{?}\)\\
\(!\symbf{!}\symsf{!}\symbfsf{!}\symbfsfup{!}\symbfsfit{!}\)
\fi
\end{document}

to pdflatex yields

output of pdflatex

As you see, ALL question marks are visually equal, and ALL exclamation marks are visually equal.

The same code, fed to lualatex, yields

output of lualatex

Again, ALL question marks come out visually equal, and ALL exclamation marks come out visually equal.

If we substitute exclamation and question marks by Latin letters, we see that their shapes get properly changed.

In the case of question and exclamation marks, we get no feedback about failures to produce any nondefault symbol shape:

$ egrep -i "(warn)|(error)|(fail)|(miss)|(undef)" mwe.log
$
  1. Any idea how to get the mathematical bold sans-serif upright question mark (?) using

1.1 pdflatex and NewTX

1.2 lualatex and TeX Gyre Termes Math?

  1. Any idea how to get the mathematical bold sans-serif upright exclamation mark (!) using

2.1 pdflatex and NewTX

2.2 lualatex and TeX Gyre Termes Math?

If NewTX and TeX Gyre Termes Math wouldn't do, which pair of Times-like fonts (perhaps, even including a variant of Times itself) to take and how? Or should we resort to some packages or nontrivial commands (\usepackage{bm}, \bm, \boldmath, \boldsymbol, …) What would be the cleanest way?

6
  • the unicode math ranges (the main target of \symxx ) do not include punctuation symbols Oct 25, 2022 at 18:18
  • @DavidCarlisle Oh. Alright. So what do we do for lualatex then? Use \textbf{\textsf{?}} or \textsf{\textbf{?}} or similar?
    – user282514
    Oct 25, 2022 at 18:23
  • for a one-off use you could do that or set up a bold sans math font \mathbfsfor whatever for more structured font setup Oct 25, 2022 at 18:26
  • @DavidCarlisle It's not a one-off, I'm afraid. In our computer-science text, we typeset normal-font question/exclamation marks for actions such as c? or c! over arrows when describing the operational semantics of the modeling language CSP by Hoare. We wish to typeset bold sans-serif question/exclamation marks when we write commands of a programming language, such as c ! 1 or c ? v, which operate on the channels between processes. Currently, we typeset about 55 question marks of both kinds altogether and 76 exclamation marks of both kinds altogether.
    – user282514
    Oct 25, 2022 at 18:37
  • declaremathalphabet should work, let me trace your mwe... Oct 25, 2022 at 19:19

1 Answer 1

1

adding \showoutput to your example produces, with pdflatex

....\mathon
....\OT1/minntx/m/n/10 ?
....\hbox(6.74998+0.09)x4.44
.....\OT1/minntx/m/n/10 ?
....\hbox(6.74998+0.09)x4.44
.....\OT1/minntx/m/n/10 ?
....\hbox(6.74998+0.09)x4.44
.....\OT1/minntx/m/n/10 ?
....\mathoff

So the ? are "visually equal" because they are the same glyph.

Adding

\mathchardef\qqq\mathcode`? \show\qqq

produces

> \qqq=\mathchar"503F.

So ? always comes from the operators \fam0 with \mathclose (5) spacing it does not change with math alphabet commands.

Adding

\DeclareMathSymbol{\qn}{\mathalpha}{operators}{`?}
\show\qn

produces

> \qn=\mathchar"703F.

which is a ? with \mathord spacing (0) and variable (7) \fam

enter image description here

Or in the log

....\OT1/minntx/m/n/10 ?
....\OT1/minntx/b/n/10 ?
....\T1/qhv/m/n/10 ?
....\T1/qhv/b/n/10 ?

From

\(\qn\mathbf{\qn}\mathsf{\qn}\mathbfsf{\qn}\)

\documentclass{article}
\usepackage{iftex}
\showoutput
\ifTUTeX
  \tracinglostchars=2
  \usepackage[math-style=ISO]{unicode-math}
  \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
  \setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Sclaing smewhat ok.
  \setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
  \setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
\else
  \usepackage[T1]{fontenc}
  \usepackage[utf8]{inputenc}
  \usepackage[helvratio=.9]{newtxtext}%%% Sclaing smewhat ok.

  \usepackage[slantedGreek,subscriptcorrection]{newtxmath}
  \DeclareMathSymbol{\qn}{\mathalpha}{operators}{`?}
  \DeclareMathAlphabet{\mathbfsf}{\encodingdefault}{\sfdefault}{bx}{n}
\fi
\begin{document}



\noindent
\(?\mathbf{?}\mathsf{?}\mathbfsf{?}\ifTUTeX\mathbfsfup{?}\mathbfsfit{?}\fi\)\\
\(!\mathbf{!}\mathsf{!}\mathbfsf{!}\ifTUTeX\mathbfsfup{!}\mathbfsfit{!}\fi\)\\
\(\qn\mathbf{\qn}\mathsf{\qn}\mathbfsf{\qn}\)
\ifTUTeX
\(?\symbf{?}\symsf{?}\symbfsf{?}\symbfsfup{?}\symbfsfit{?}\)\\
\(!\symbf{!}\symsf{!}\symbfsf{!}\symbfsfup{!}\symbfsfit{!}\)
\fi
\end{document}
4
  • Thx!!! I've just checked, and this goes well for pdflatex. What do we do for lualatex? The same definition of \qn seems to produce a normal question mark …
    – user282514
    Oct 25, 2022 at 19:52
  • 1
    @AlbertNash I was planning to leave that as an "exercise for the reader":-) essentially the same code will work but you will have to supply the fonts and (see unicode-math) make sure \mathsf really selects a sans font, and is not made an alias for \symbf (which uses the unicode sans range which has no "?") unicode-math can do either. No time now but if you don't get it working ping me later and I may look Oct 25, 2022 at 19:57
  • Since you made “?” an operator: the intended usages are “channel?”, “channel?var”, “channel!”, and “channel!expression”. The question mark (as well as the exclamation mark) is a postfix command (i.e., the argument of the command comes before the keyword, similar to a factorial, e.g. “3!”) or an infix command (i.e., the argument of the command comes around the keyword, similar to the addition, e.g., “2+3”). Does the “operators“ class really suit or is there a better class?
    – user282514
    Oct 26, 2022 at 11:06
  • 1
    @AlbertNash I made ? a letter (\mathalpha) like x so it gets no spacing, and picks up the current font. the {operators} argument there is refering to the font used for operators such as \log and \sin, so \mathrm, typically. So bascally this makes ? act like a digit 0 : by default in the upright font but using whatever is current with \mathsf{..} etc Oct 26, 2022 at 11:10

You must log in to answer this question.