8

Consider $a \triangleright b$ and $a \overline{\triangleright} b$. They behave completely different in terms of spacing:

enter image description here

Why? How do I fix that?

9
  • 1
    You would enclose the object, \overline{\triangleright}, in the appropriate math terminology macro, of which the choices, in general, are \mathpunct, \mathop, \mathrel, \mathbin, and \mathord, Apr 30 '15 at 14:12
  • 3
    \mathbin{\overline\triangleright}
    – LaRiFaRi
    Apr 30 '15 at 14:12
  • 3
    And if used often, wrap LaRiFaRis solution in a \newcommand
    – daleif
    Apr 30 '15 at 14:13
  • So is there a way to "keep the way the spacing was before", so the \overline would work with characters as well?
    – Turion
    Apr 30 '15 at 14:21
  • 1
    @StevenB.Segletes The sequences \mathbin, \mathop etc. are not macros byt they are TeX primitives.
    – wipet
    Apr 30 '15 at 14:37
7

The command \triangleright is a so called binary operator. LaTeX treats this binary operators in a way, that a small horizontal space is set before and after it. What happened here is that you have wrapped this command in some other command which does hide this feature. You can see the same effect if you just try $a+b{+}c$.

Therefore, you will have to make your construct a binary operator again by wrapping it in the command \mathbin:

 % arara: pdflatex

\documentclass{article}
\newcommand*{\oltriangleright}{\mathbin{\overline\triangleright}}

\begin{document}
$a \triangleright b$ and $a \oltriangleright b$
\end{document}

enter image description here


What does this symbol mean? If you have some reference, you might recommend it to the unicode.

4
  • I'm using \overline as an operation that can be applied to many objects, for example the triangle, but also to variables, so I don't think it justifies a definition on its own.
    – Turion
    Apr 30 '15 at 14:24
  • @Turion You can always do it manually or you use the command I posted as comment above.
    – LaRiFaRi
    Apr 30 '15 at 14:25
  • If the symbol represents a relation, should it not be mathrel?
    – Raphael
    Apr 30 '15 at 15:38
  • 1
    @Raphael If it does, of course. As I have no idea about the meaning and as \triangleright is a binary operator, I suggested the new symbol to be one, too.
    – LaRiFaRi
    Apr 30 '15 at 23:35
4

Each object in math typesetting has one of the classes: 0=Ord, 1=Op, 2=Bin, 3=Rel, 4=Open, 5=Close, 6=Punct. This class influences the horizontal spaces (automatically inserted between objects). The elementary objects in math typesetting are typically declared by \mathchardef primitive (for control sequences) or \mathcode (for native codes). The \mathode of a and b are declared as class Ord and triangleright is declared as

\mathchardef\triangleright="212E

which means class=2=Bin, family=1, fontcode=2E. The most important (for now) is the class Bin. The sequence a\triangleright b is "Ord Bin Ord" and this influences the right horizontal spaces. The things are more complicated, but the basic principle is shown here.

Now, the most important is the fact that braces (like {\triangleright}) or other constructions (like \overline{\triangleright}) creates the composed object in the class Ord. So, we have Ord Ord Ord in our example and this inserts none spaces between. But there are class-retyping primitives \mathord, \mathop, \mathbin, \mathrel, \mathopen, \mathclose and \mathpunct which generates the object of given class. So

a \mathbin{\overline{\triangleright}} b

gives the sequence "Ord Bin Ord" and this influences the right spacing.

2

You can get the correct spacing using a modified version of \overline that uses the same infrastructure as \overset:

\documentclass{article}
\usepackage{amsmath,amssymb}

\makeatletter
\DeclareRobustCommand{\coverline}[1]{% clever overline
  \binrel@{#1}\binrel@@{\overline{#1}}%
}
\makeatother

\begin{document}

$a\coverline{<}b$

$a<b$

$a\coverline{\triangleright} b$

$a\triangleright b$

\end{document}

The instruction \binrel@ determines whether the argument is a binary operation or relation symbol and sets \binrel@@ to mean \mathbin or \mathrel accordingly; if the type cannot be determined, it is set to \mathord.

enter image description here

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.