3

For school geometry, I would like to be able to write “A-P-B” to mean that a point P is between the points A and B. However, $A-P-B$ gives the spacing of the minus operator, and I do not want the extra inserted space; and $A$--$B$--$C$ sometimes gets broken across two lines.

This code produces the output I want.

\documentclass[12pt]{amsart}
\begin{document}

Point $P$ is \emph{between} points $A$ and $B$ is 
notated $A$\nobreakdash--$P$\nobreakdash--$B$.

$\overline{AB} = \{ A \} \cup \{ B\ } \cup 
\{ P \mid A\text{--}P\text{--}C \}$.
\end{document}

Hopefully, there is a better way to accomplish this.

But if this is the right approach, then I would like help defineing something in my preface so I don't have to type it out all the time. One possibility would be \newcommand{\Betw}{\nobreakdash--} % à la the AMS documentation. and then write $A$\Betw$P$\Betw$B$, but that isn't really much better.

I'd rather define something (a trinary operator?) where I could input (something like) $\Betw{APB}$ but I don't know how to define an operator/command like that.

I'm open to whatever suggestions, declarations, techniques or packages you might offer, but I need to use the A-P-B notation.


Note that \between is already defined as something else.

  • Do you really want the text-mode endash? (Or is it an emdash - I always forget, but think that's the triple?) Or is it just the spacing you want to change? I'm guessing the latter as the first seems a weird thing to want to do. However, many people want to do things I consider weird, so it is certainly possible. – cfr Feb 4 '18 at 4:51
  • @marmot Did you read the question? – cfr Feb 4 '18 at 4:52
  • My question really involves the spacing simply because that's what is obviously wrong to me. Having said that, I used the em-dash in my example as a kludge. I don't know what I am "supposed" to use, but assume there must be some standard practice. So if there is a different symbol that is appropriate, I'd like to know that too. Thanks @cfr . – Bryan M-H Feb 5 '18 at 17:30
1

You can use a “flexible” definition:

\documentclass{article}
\usepackage{amsmath}

\makeatletter
\newcommand{\between}[1]{\bryan@between#1\@nil}
\def\bryan@between#1|#2|#3\@nil{%
  {#1}\bryan@sep{#2}\bryan@sep{#3}%
}
\newcommand{\bryan@sep}{\text{--}}
\makeatother

\begin{document}

The fact that the point $P$ is \emph{between}
the points $A$ and $B$ is denoted by
$\between{A|P|B}$. Therefore
$\overline{AB} = \{ A \} \cup \{ B\} \cup
\{ P \mid \between{A|P|B}\}$.

The separator is distinguishable from a minus sign,
compare
\[
A-B \quad \between{A|P'|B}
\]

\end{document}

You can easily change your mind about the separator.

enter image description here

  • I will play with both versions for a while to see if I prefer always to put in the uprights and assure proper separation, or want to use the braces only when I need them. Getting to see the development of @cfr's code and then your massaging it was very helpful to me! – Bryan M-H Feb 6 '18 at 22:25
2

Do you want something like this? Minuses on the left; differently-spaced minuses on the right.

minuses and dashes

The advantage of sticking to maths fonts is that you will always get the character from the maths fonts, even if that differs from the dash or hyphen in the text fonts. For example, if you used a different set of fonts for maths (or text) but not text (or maths), then switching to text mode will get you the text fonts.

Of course, if that's what you want i.e. you want the text-mode dash/hyphen and not the maths minus, then something like your approach is required. But if you really just want different spacing, the right approach is to use different spacing and not switch to a different font.

\documentclass{article}
\newcommand*{\btwn}{\ensuremath{\mathord{-}}}
\begin{document}
\[
  5-6-2 \qquad A\btwn B\btwn C
\]
\end{document}

EDIT

In the comments, you requested an 'operator', but I think you may want a macro. If so, maybe the following will help.

\documentclass{article}
\newcommand*{\btwn}{\ensuremath{\mathord{-}}}
\newcommand*{\Btwn}[3]{#1\btwn#2\btwn#3}
\makeatletter
\newcommand\b@twn{}
\def\b@twn#1#2#3\@null{#1\btwn#2\btwn#3}
\newcommand*{\BTWN}[1]{\expandafter\b@twn#1\@null}
\makeatother
\begin{document}
\[
5-6-2 \qquad A\btwn B\btwn C \qquad  \Btwn{A}{P}{B} \qquad \BTWN{APB} \quad \BTWN{A{P_1}B}
\]
\end{document}

macro variations

  • This looks good, and the way you defined the newcommand keeps me from having a plethora of dollar signs. Ideally, I was thinking of something more in terms of an operator, but this will definitely work better than what I am doing. If such a solution isn't presented, I will come back and accept this one. Thanks @cfr . – Bryan M-H Feb 5 '18 at 17:36
  • @BryanM-H By 'operator' you mean a macro? Something like \btwn{A}{P}{C}? That would be easy. Or do you want to be able to say \btwn{APC}? That's a bit less easy. Will there always be exactly 3 letters? That is, you'll never want something like A-P'-C or A-P_1-C or A-PP-C? – cfr Feb 5 '18 at 19:12
  • @BryanM-H Please see edit if you do want a macro. Please clarify if you mean something else by 'operator'. – cfr Feb 6 '18 at 0:09
  • There will not always be three letters, so your \BTWN{A{P'}{C'}} is just what I was looking for. – Bryan M-H Feb 6 '18 at 22:21

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.