3

For a long time, I've been defining a long „equals to by definition“ symbol ≝ for [pdf|lua|xe]latex via

\newcommand*{\longDefiningEquals}{\stackrel{\text{def}}{=\joinrel=}}

Its typical usage would be in a block formula such as

⨾ ≝ { (,) | ∃ : (,) ∈ ∧ (,) ∈ }

where there's enough space to accommodate a long equals-to-by-definition symbol (a short one, say, from TeX Gyre Termes Math, would semantically work, but here we wish to spend space on the main symbol of the formula). However, in my examples, the aforementioned command results in two small bumps in the middle of the equality sign. Here is an example to play with:

\documentclass{article}
\usepackage{iftex}
\ifTUTeX
  \usepackage[math-style=ISO]{unicode-math}
  \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
  \setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Somewhat ok scaling.
  \setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
  \setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
  \setmathfont[Ligatures=TeX,Extension=.otf,range={"2A3E},BoldFont=XITSMath-Bold]{XITSMath-Regular}%%% The fat semicolon comes from XITS.
\else
  \usepackage[helvratio=.9]{newtxtext}% Scale the sans font at 90%.
  \usepackage[slantedGreek,subscriptcorrection]{newtxmath}%% Should be loaded after the text font according to its manual. The default uppercase Greek letters should be slanted according to the SVMono manual.
\fi
\usepackage{graphics}
\newcommand*{\longDefiningEquals}{\stackrel{\text{def}}{=\joinrel=}}%%% long equality symbol that is used to define stuff
%\newcommand*{\longDefiningEquals}{\stackrel{\text{def}}{\scalebox{2}[1]{=}}}% Marjin's suggestion
\begin{document}
% \[R⨾\ \longDefiningEquals\ \{ (,) \mid ∃ \colon (,) ∈  ∧ (,) ∈ \}\]
% \[R⨾\ ≝ \{ (,) \mid ∃ \colon (,) ∈  ∧ (,) ∈ \}\]
\[\longDefiningEquals\]
\end{document}

The bumps sometimes become visible on the screen, especially at low resolutions:

output

Is there a better LONG ≝ symbol in a Type1 font or an OTF math font or, perhaps, can one construct a better symbol oneself? (Of course one can draw it via TikZ/PSTricks, but this would raise issues when such a symbol has to go into a TikZ/PS picture itself or when changing the font size.)

  • 1
    Would \stackrel{\text{def}}{\scalebox{2}[1]{=}} (with \scalebox from the graphicx package) be acceptable? – Marijn Feb 09 '23 at 18:58
  • @Marjin Works for me in {lua|xe|pdf}latex, but NOT with latex (the DVI output is wrong). –  Feb 09 '23 at 19:13
  • 2
    Take a look at extarrows: It provides \xlongequal{<stuff>} – Werner Feb 09 '23 at 19:21
  • @Werner Thanks! Unfortunately, it suffers from the same problem: a low-resolution cut from my stock extarrows-test.pdf shows artefacts on the long equality symbol: https://i.imgur.com/EJGzkQZ.png . –  Feb 09 '23 at 19:26
  • @Marjin At least as far as non-DVI output is concerned, is it possible to scale the equality symbol exactly to the width of “def”? Interestingly, the PostScript generated from the wrong DVI is fine again. –  Feb 09 '23 at 19:34
  • What viewer/renderer do you use (for each output formats)? Some of them don't produce nice results when things overlap each other. A few do show a much better result. On paper this won't be noticeable. – Qrrbrbirlbel Feb 09 '23 at 19:48
  • @Qrrbrbirlbel xdvi for DVI, evince for PDF, gv for PS. For getting low-resoultion stuff, I use gimp and open a file at 100 px/in. –  Feb 09 '23 at 19:49
  • @AlbertNash dvi output is often "wrong", it is an intermediate format where certain operations are not rendered yet. They are however passed on to the next format (either ps or pdf directly) so you should judge the final output only to see if something works in a certain toolchain. – Marijn Feb 09 '23 at 21:26
  • @Marijn Sure. We sometimes use DVI for debugging, and it's best we don't see additional issues there that could be avoidable. –  Feb 09 '23 at 21:28
  • 1
    For getting the exact width of "def" you can either try to adapt the scaling factor (I used 2 in my comment above, which looks slightly too wide, so maybe 1.95 or so) or you can actually measure the width using \resizebox{\widthof{def}}{\height}{=} (requires the calc package), however this is even wider than the version with scale factor 2 because the bounding box width of "def" is wider than the letters themselves. – Marijn Feb 09 '23 at 21:34
  • I'm puzzled why not use the := symbol which means "by definition" in many math contexts, or same but with the dots above & below the equals? – user3445853 Feb 10 '23 at 11:27
  • Is there a correlation with your question in this link? https://tex.stackexchange.com/questions/35404/is-there-a-wider-equal-sign – Sebastiano Feb 10 '23 at 12:45
  • 1
    @Sebastiano Thx! Looking into it. Here, I explicitly allow for ALL four engines. –  Feb 10 '23 at 18:41
  • @user3445853 the symbol ≔ means assignment in certain programming languages. When writing a text containing both maths and program texts, you may wish to distinguish the assignment command from the definition of a mathematical object. As for ≑, I've never seen it or used in in the sense of "define as". –  Feb 10 '23 at 18:53
  • @AlbertNash Welcome in this great community. – Sebastiano Feb 10 '23 at 20:27

5 Answers5

4

with luatex you can use extensible symbols:

\documentclass{article}
\usepackage[math-style=ISO]{unicode-math}
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}

\newcommand*{\longDefiningEquals} {\Uoverdelimiter 0 "3D {\text{ \vphantom{j}definition }}} \begin{document} [\longDefiningEquals] \end{document}

enter image description here

Ulrike Fischer
  • 327,261
  • Thanks! The input is elegant! However, the output seems to suffer from a similar problem (bumps at low resolution): https://i.imgur.com/0xy0qgz.png . This happens also if we shorten “definition” to “def”. –  Feb 09 '23 at 20:17
  • well extensible symbols are build with parts, use the real unicode symbol (u+225D) if you want a single symbol. – Ulrike Fischer Feb 09 '23 at 20:33
  • Of course. My hope is that some OTF/TTF font has ≝ (U+225D) long. –  Feb 09 '23 at 20:36
  • Btw., in your suggestion, you probably wish to add spacing: \mathrel{\Uoverdelimiter 0 "3D {\text{ \vphantom{j}definition }}}? –  Feb 09 '23 at 20:37
4

You don't have to draw it with PGF/TikZ. It's only two horizontal bars.

The value .225ex is half of TikZ “equal sign distance” (whereever that is from) and 2.57pt is from TikZ-CD's axis_height function. The value .56pt is from the rule_thickness function.

These values are different for each font and need to be evaluated better in the real use-case.

Only disadvantage is that it's not a = anymore and won't be selectable in the output.

Code

\documentclass{article}
\usepackage{iftex}
\ifTUTeX
  \usepackage[math-style=ISO]{unicode-math}
  \setmainfont[Ligatures=TeX]{TeX Gyre Termes}
  \setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Somewhat ok scaling.
  \setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
  \setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
  \setmathfont[Ligatures=TeX,Extension=.otf,range={"2A3E},BoldFont=XITSMath-Bold]{XITSMath-Regular}%%% The fat semicolon comes from XITS.
\else
  \usepackage{newtxtext,newtxmath}
\fi
\usepackage{graphics}
\newcommand*{\longDefiningEquals}{\stackrel{\text{def}}{=\joinrel=}}
\makeatletter
\newcommand*\lde[1][def]{%
  \stackrel{\mathrm{#1}}{%
    \settowidth\dimen@{$\scriptstyle\mathrm{#1}$}%
    \rlap{\rule[\dimexpr-.225ex+2.57pt]{\dimen@}{.56pt}}%
          \rule[\dimexpr+.225ex+2.57pt]{\dimen@}{.56pt}}}
\makeatother

\usepackage{tikz} \begin{document} %[R⨾\ \longDefiningEquals\ { (,) \mid ∃ \colon (,) ∈ ∧ (,) ∈ }] %[R⨾\ ≝ { (,) \mid ∃ \colon (,) ∈ ∧ (,) ∈ }] [\longDefiningEquals a = b \lde c \lde[definition] d = e] \tikz\node[draw,green,line cap=round]{$a \lde b$}; \end{document}

Qrrbrbirlbel
  • 119,821
  • First, thanks! Second, if you draw it, the equality doesn't show out in the text layer of the output, does it? –  Feb 09 '23 at 20:12
  • @AlbertNash No, it does not. With the accsupp package it might be possible to actually have show up in the text layer but I don't know how. – Qrrbrbirlbel Feb 09 '23 at 20:23
  • With accsupp you can indeed get the symbol as text into a PDF (for PS output, it's useless), and you don't the symbol into the main text layer but rather as replacement text. I used this package for quite some time with other self-constructed symbols of mine, and, finally, I stopped using accsupp. –  Feb 09 '23 at 20:27
4

You can use the graphicx package that provides \scalebox and \resizebox to change the width of any content. If the content is text then it will remain as text, i.e., a widened = symbol can still be selected/copied/searched as a normal character.

For \scalebox you can set the horizontal and vertical scale separately. To make a symbol wider the vertical scale should remain at 1.

To make the symbol as wide as the text on top you can use \widthof from the calc package as width value for \resizebox. For the height value you can use the macro \height which contains the original height of the box. However, because the box containing def is slightly larger than the word itself, the symbol may appear to wide. The calc package provides the construct * \real{number} to modify the outcome of \widthof.

MWE:

\documentclass{article}
\usepackage{graphicx}
\usepackage{calc}
\usepackage[math-style=ISO]{unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Termes}
\setsansfont{TeX Gyre Heros}[Scale=0.88]%%% Somewhat ok scaling.
\setmonofont{TeX Gyre Cursor}%%% No explicit turning on ligatures for the monospaced font.
\setmathfont[Ligatures=TeX]{TeX Gyre Termes Math}
\setmathfont[Ligatures=TeX,Extension=.otf,range={"2A3E},BoldFont=XITSMath-Bold]{XITSMath-Regular}%%% The fat semicolon comes from XITS.
\newcommand*{\longDefiningEquals}{\stackrel{\text{def}}{=\joinrel=}}%%% long equality symbol that is used to define stuff
\newcommand*{\scaleDefiningEquals}{\stackrel{\text{def}}{\scalebox{2}[1]{=}}}%%% long equality symbol that is used to define stuff
\newcommand*{\wdDefiningEquals}{\stackrel{\text{def}}{\resizebox{\widthof{def} * \real{0.8}}{\height}{=}}}%%% long equality symbol that is used to define stuff

\begin{document} [R⨾\ \longDefiningEquals\ { (,) \mid ∃ \colon (,) ∈ ∧ (,) ∈ }]

[R⨾\ \scaleDefiningEquals\ { (,) \mid ∃ \colon (,) ∈ ∧ (,) ∈ }]

[R⨾\ \wdDefiningEquals\ { (,) \mid ∃ \colon (,) ∈ ∧ (,) ∈ }] \end{document}

Result:

enter image description here

Note that the original symbol is stretched instead of repeated, so it is guaranteed not to have artifacts in the middle.

Marijn
  • 37,699
  • Thanks! Works like a charm. Is it possible to place "def" closer to the long equality symbol, without that much spacing in between? xelatex does it, but, apparently, not lualatex. Further, the factor 0.8 seems rather arbitrary. Perhaps, one could measure the width of \stackrel{\text{def}}{=} instead of taking 80% of the width of “def”? –  Feb 09 '23 at 22:10
  • Further, the equality symbol in \wdDefiningEquals seems to be vertically thinner than the usual =. –  Feb 09 '23 at 22:53
  • Further, the equality symbol in \wdDefiningEquals seems to be vertically thinner than the usual math-mode =. Probably, you wish to resize the mathm-mode = rather than the text-mode =. –  Feb 09 '23 at 23:06
3

Something like this?

\documentclass[12pt]{article}
\usepackage{amsmath,amssymb}
\makeatletter
\def\equalsfill{$\m@th\mathord=\mkern-7mu
\cleaders\hbox{$\!\mathord=\!$}\hfill
\mkern-7mu\mathord=$}
\makeatother
\begin{document}
\[R \stackrel{\text{def}}{\hbox{\equalsfill}} S\]
\[R \stackrel{\text{definition}}{\hbox{\equalsfill}} S\]
\end{document}

enter image description here

PS: The macro is taken from the documentation symbols-a4.

Sebastiano
  • 54,118
  • 1
    First, thanks! Second, it has a similar problem at low resolutions: https://i.imgur.com/AX18YxL.png . –  Feb 09 '23 at 19:13
  • @AlbertNash You're welcome :-). Could you show me what happens in low resolution? – Sebastiano Feb 09 '23 at 19:15
  • 1
    I've just re-uploaded a new image (a low-resolution imaged scaled up) in my previous comment. You see the thickened middle part. –  Feb 09 '23 at 19:16
2

The ≝ symbol is U+225D in Unicode, and \eqdef in unicode-math, stix or stix2.

Davislor
  • 44,045
  • Yes, and in its representation the equality symbol is shorter than "def" in all fonts I know. –  Feb 10 '23 at 18:32