3

Most (but not all) of the math-mode stuff in my book consists of terms and formulas of a clean logic:

  • The terms are recursively constructed from constants (such as 0, 1, 2, true, f, g, +, , or, not, … of any arity including 0) and variables (such as S, x, y, …) using applications of terms to other terms (such as 1+x, f(0,g(y)), x∈S, …).

  • The atomic formulas are of the form t₁ = t₂, where t₁ and t₂ are terms (such as 3 = x+2, x∈S and not false = true, …).

  • The formulas are recursively constructed from atomic formulas using logical negation (¬) of formulas (such as ¬(1=2+3), ¬(f(x)=g(0,y)), …), conjunctions () and disjunctions () (such as v=2+x ∧ y+2=z, v=x ∨ y∈S = true, …), and variables binders (such as ∃ x: x+1=2, ∀ x,y: x+y=y+x, {x|x+1>y}, …).

(Btw., all terms have sorts, and there is also a well-sortedness condition imposed on terms and atomic formulas. We drop this here for simplicity.)

Now, when I typeset my formulas containing equality = and binary logical connectives and , do I get counterintuitive distances? E.g., in v=x \land y=z, the distances around \land (a binary operator in LaTeX) are smaller than around = (a relation in LaTeX), aren't they?

If so, what would be the cleanest way to repair this in my setup? I don't really know and was thinking of something like

\documentclass{article}
\newcommand{\formulaConjunction}{\mskip1.2mu plus.6mu minus.6mu\land\mskip1.2mu plus.6mu minus.6mu}
\newcommand{\formulaDisjunction}{\mskip1.2mu plus.6mu minus.6mu\lor\mskip1.2mu plus.6mu minus.6mu}
\newcommand{\memberOf}{\mathbin{\in}}
\begin{document}\noindent
\(v\memberOf S = \mathsf{true} \formulaConjunction y=f(z)\)\\
\(v=x+1 \formulaDisjunction y=z\)
\end{document}

This way, the distances around the logical conjunction and disjunction connectives become slightly larger than around the equality symbol of the logic, and the distances around the equality symbol become slightly larger than the distances around infix operators (such as +, ), don't they? However, this seems very ad-hoc to me. Before I change hundreds of formulas in my book this way, are there any potential pitfalls? Is there anything better that works for all of [pdf|xe|lua]latex ? My guess is that the aforementioned logic is somewhat standard, so some someone must have already done this (or at least a similar) exercise.

2
  • Would using parentheses be ok, e.g., \( (v=x+1) \formulaDisjunction (y=z) \)?
    – Mico
    Commented Nov 1, 2022 at 4:44
  • @Mico Parens are used to force a formula into a particular tree structure that it wouldn't have with default operator precendences in logics, e.g., ∨ binds weaker than ∧. I'm speaking, on the contrary, about what happens with default operator precendences. You don't want to clutter your formulas with parens when not necessary, after all.
    – user282514
    Commented Nov 1, 2022 at 22:21

2 Answers 2

2

I gather that you would like to change the amount of whitespace TeX inserts around certain symbols of type mathbin -- specifically, \land and \lor, but maybe some others as well. The default amount of whitespace for mathbin objects (governed by the parameter \medmuskip) is 4mu in PlainTeX and in all LaTeX document classes I'm familiar with. You may want to increase it to at least 6mu or 7mu. Why not 5mu, you may ask? Because that's the default value of \thickmuskip, the parameter that governs the amount of whitespace around objects with status mathrel.

Unfortunately, the number of distinct math-type or math-status categories is quite limited, and none of the existing categories lends itself easily to your typesetting needs. E.g., you don't want to modify the properties of objects with status mathbin and mathrel, right?

However, I can suggest that you create two new user macros via, say, the instructions

\newcommand\Nashland{{\mkern7mu{\land}\mkern7mu}}
\newcommand\Nashlor{{\mkern7mu{\lor}\mkern7mu}}

and use \Nashland and \Nashlor instead of \land and \lor. Of course, this setup assumes that \Nashland and \Nashlor will only ever be surrounded by objects with math status mathord. That is the case in the examples you posted. However, I don't know if this assumption is always valid.

A separate comment: You may be expecting a lot -- and quite possibly too much -- from your readers if you need them to notice and fully understand the semantic significance of subtle differences in the amounts of whitespace that TeX places around various math objects. In "ordinary" (non-Nash...) notation, there's really no semantic significance attached to the amounts of whitespace that surrounds mathbin objects -- such as + and - -- and mathrel objects -- such as =, >, and <. I'm pretty sure that one could switch the values of \medmuskip and \thickmuskip in expressions such as 1+1<2+2 and not cause a major disturbance (though quite possibibly some minor irritation) among readers. But that's not permitted in the use cases that require \Nashland and \Nashlor, is it? Hence, I think you may be better off using parentheses judiciously and not rely on your readers to truly appreciate the semantic significance of subtle differences in whitespace amounts.


Here's an MWE (minimum working example). Note that I've had to set the amount of whitespace involved in \Nashland and \Nashlor to a whopping 10mu in order to ensure that readers have no choice but to notice that there must be a non-random, semantic meaning to the amount of whitespace that surrounds the \land and \lor symbols. Well, you might be able to get by with 9mu or 8mu instead of 10mu; I certainly wouldn't go below 8mu.

In contrast, using parentheses requires no appreciation at all of subtle differences in whitespace amounts. Parentheses can indeed cause visual clutter. But what's worse: cause some visual clutter, or risk rampant confusion?

enter image description here

\documentclass{article}
\usepackage{amsmath} % for 'gather*' env.
\newcommand{\true}{\mathsf{true}}
%\newcommand{\false}{\mathsf{false}} % not needed for this example

\newcommand\Nashland{{\mkern10mu{\land}\mkern10mu}}
\newcommand\Nashlor{{\mkern10mu{\lor}\mkern10mu}}

\begin{document}

Case 1: \texttt{\string\land} and \texttt{\string\lor}:
\begin{gather*}
v \in S = \true \land y=f(z) \\
v=x+1 \lor y=z
\end{gather*}

\medskip
Case 2: \texttt{\string\Nashland} and \texttt{\string\Nashlor}:
\begin{gather*}
v \in S = \true \Nashland y=f(z) \\
v=x+1 \Nashlor y=z
\end{gather*}

\medskip
Case 3: Parentheses alongside \texttt{\string\land} and \texttt{\string\lor}:
\begin{gather*}
(v \in S = \true) \land (y=f(z)) \\
(v=x+1) \lor (y=z)
\end{gather*}

\end{document}
9
  • Sometimes you have a formula spanning several lines, e.g., a conjunction of lines, in which each line starts with & \land ( … in an array-like environment, e.g., align*. So the assumption that ∧ and ∨ are always surrounded by Ord is not valid – sometimes there's nothing on one side and an opening symbol on another side, for example. Independent thereof, I wonder what's the point of \mkern… instead of \mskip… plus… minus…. Don't we want the in-line formulas to stretch, shrink, and break automatically?
    – user282514
    Commented Nov 1, 2022 at 22:32
  • @AlbertNash - You're entirely welcome to replace \mkern with \mskip. If the main length is 10mu, I wouldn't see the point of adding puny stretch and shrink components, as in plus .6mu minus.6mu. plus 3mu minus 3mu might be more useful in practice.
    – Mico
    Commented Nov 1, 2022 at 22:35
  • Thanks! It's more about the relative values of stretch and shrink rather than the absolute values. So far, I've beein using 50%: \mskip𝑥mu plus(𝑥/2)mu minus(𝑥/2)mu, whether it's \mskip1.2mu plus.6mu minus.6mu or \mskip12mu plus6mu minus6mu. You seem to favour 30% in your comment above: \mskip10mu plus 3mu minus 3mu. Any specific reason behind it?
    – user282514
    Commented Nov 2, 2022 at 10:29
  • As for my 50%: the computation of a half in my book comes from macros that automatically set an elastic positive or negative space: \newcommand{\flexAddMSpace}[1]{\mskip#1 plus.5\muexpr#1\relax minus.5\muexpr#1\relax\relax} \newcommand{\flexReduceMSpace}[1]{\mskip-#1 plus.5\muexpr#1\relax minus.5\muexpr#1\relax\relax} I have no particular reason to take exactly one half. Concerning puny values: a single tiny stretch or shrink does nothing in my experience, but if they accumulate from various sources in a single line, it sometimes makes a difference. E.g., an overfull sometimes disappears.
    – user282514
    Commented Nov 2, 2022 at 10:39
  • @AlbertNash - In order to be able to distinguish readily between \thickmuskip (5mu plus minus some stretching and shrinking) and whatever amount of whitespace should surround \land and \lor, I don't think that this "whatever amount" should be less than 8mu. Maybe 7mu, if \medmuskip and \thickmuskip also get shrunk. Hence, a mild preference for 10mu plus 3mu minus 3mu.
    – Mico
    Commented Nov 2, 2022 at 11:01
1

You may want, in select places, change the nature of = and \in to be binary operations rather than relations.

You possibly need other symbols.

\documentclass{article}

\newcommand{\true}{\mathsf{true}}
\newcommand{\false}{\mathsf{false}}

\newcommand{\logic}[1]{%
  \begingroup
  \expanded{\mathchardef\in = \the\numexpr\in-"1000}%
  \mathcode`= = \numexpr\mathcode`=-"1000\relax
  #1
  \endgroup
}


\begin{document}

\[
\logic{v \in S = \true \land y=f(z)}
\]

\[
\logic{v=x+1 \lor y=z}
\]

\end{document}

enter image description here

1
  • First, if we do this, wouldn't the space around = be the same as around +? Ideally, we should have the space around infix operators (such as +, *, or ) slightly smaller than the space around =, and the space around ∨ and ∧ slightly larger than the space around =. Second, would this work in {xelua}latex? I thought we would need something like \Umathchardef instead of \mathchardef.
    – user282514
    Commented Nov 1, 2022 at 14:24

You must log in to answer this question.