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.)

15
  • 1
    Would \stackrel{\text{def}}{\scalebox{2}[1]{=}} (with \scalebox from the graphicx package) be acceptable?
    – Marijn
    Feb 9, 2023 at 18:58
  • @Marjin Works for me in {lua|xe|pdf}latex, but NOT with latex (the DVI output is wrong).
    – user282514
    Feb 9, 2023 at 19:13
  • 2
    Take a look at extarrows: It provides \xlongequal{<stuff>}
    – Werner
    Feb 9, 2023 at 19:21
  • 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 9, 2023 at 21:34
  • 1
    @Sebastiano Thx! Looking into it. Here, I explicitly allow for ALL four engines.
    – user282514
    Feb 10, 2023 at 18:41

5 Answers 5

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

4
  • Thanks! The input is elegant! However, the output seems to suffer from a similar problem (bumps at low resolution): i.imgur.com/0xy0qgz.png . This happens also if we shorten “definition” to “def”.
    – user282514
    Feb 9, 2023 at 20:17
  • well extensible symbols are build with parts, use the real unicode symbol (u+225D) if you want a single symbol. Feb 9, 2023 at 20:33
  • Of course. My hope is that some OTF/TTF font has ≝ (U+225D) long.
    – user282514
    Feb 9, 2023 at 20:36
  • Btw., in your suggestion, you probably wish to add spacing: \mathrel{\Uoverdelimiter 0 "3D {\text{ \vphantom{j}definition }}}?
    – user282514
    Feb 9, 2023 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}
3
  • First, thanks! Second, if you draw it, the equality doesn't show out in the text layer of the output, does it?
    – user282514
    Feb 9, 2023 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. Feb 9, 2023 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.
    – user282514
    Feb 9, 2023 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.

3
  • 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”?
    – user282514
    Feb 9, 2023 at 22:10
  • Further, the equality symbol in \wdDefiningEquals seems to be vertically thinner than the usual =.
    – user282514
    Feb 9, 2023 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 =.
    – user282514
    Feb 9, 2023 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.

3
  • 1
    First, thanks! Second, it has a similar problem at low resolutions: i.imgur.com/AX18YxL.png .
    – user282514
    Feb 9, 2023 at 19:13
  • @AlbertNash You're welcome :-). Could you show me what happens in low resolution?
    – Sebastiano
    Feb 9, 2023 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.
    – user282514
    Feb 9, 2023 at 19:16
2

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

1
  • Yes, and in its representation the equality symbol is shorter than "def" in all fonts I know.
    – user282514
    Feb 10, 2023 at 18:32

You must log in to answer this question.