6

In some cases it is common to use the same symbol to refer to a mathematical relation and to instances of the relation. For example, > as the relation of being greater than and x>y for the instance saying that x is greater than y.

You can manipulate relations for example

>' = > \cup \{(x,y)\}

Normally, TeX automatically adds (the right) amount of space around math relations and binary operators. However, the spacing must be adjusted manually in scenarios like the example above, for example:

{>'} = {>} \cup \{(x,y)\}
\mathord{>}' = \mathord{>} \cup \{(x,y)\}

I wonder if there are ways to handle situations like the one above automatically (beside the solutions above or defining commands for the relations, e.g., \newcommand{\greater}{\mathord{>}}, and then

\greater' = \greater \cup \{(x,y)\}
1
  • The only way would be to make the leading character active so as to gauge the following input and construct a symbol accordingly. Just my opinion.
    – Werner
    Sep 19, 2012 at 2:54

1 Answer 1

3

I can think to $<\subset\le$, where the fact that \le is not to be considered a relation symbol depends on what comes before. So you'd need to define a parser for your expressions, which is not something I would do.

I suggest you to prefix a relation symbol when it's to be considered an ordinary one:

\documentclass[a4paper]{amsart}

\begingroup\lccode`~=``
\lowercase{\endgroup\def~}#1{\mathord{#1}}
\AtBeginDocument{\mathcode``=\string"8000 }


\begin{document}
$`>' = `> \cup \{(x,y)\}$

${>'} = {>} \cup \{(x,y)\}$ % for checking the result
\end{document}

The character ` is free of meaning in formulas (and it's handy to produce on my keyboard); you can also use ?.

enter image description here

Alternatively, you can decide to quote the symbol; again, I'm used to it because of this site:

\documentclass[a4paper]{amsart}

\begingroup\lccode`~=``
\lowercase{\endgroup\def~}#1`{\mathord{#1}}
\AtBeginDocument{\mathcode``=\string"8000 }


\begin{document}
$`>'` = `>` \cup \{(x,y)\}$

${>'} = {>} \cup \{(x,y)\}$ % for checking the result
\end{document}

What's in between back quotes is considered an ordinary symbol. This might be more semantically sound, take your pick.

2
  • 1
    Not exactly what I was after, still need to manually signal that a symbol has to be treated differently from its "normal" beahviour. The second one is a nice technical solution, but I would prefer to use {} instead of `.
    – Guido
    Sep 23, 2012 at 21:53
  • As I said, parsing those expressions is not very easy; at least that's my feeling. Without a proper parsing rule, it's very difficult to provide a solution that doesn't rely on additional markup. And writing a proper parser, even if the rules are clearly laid out, might reveal quite difficult.
    – egreg
    Sep 23, 2012 at 22:02

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .