12

I would like to insert a character such that it has no width.

As a toy example consider \rightarrow\leftarrow In the middle i would like to insert a (say) \bullet, but with no horizontal space.

I know that \rightarrow\!\!\!\bullet\!\!\!\leftarrow roughly does the job, but only for this particular character.

How do you do this construction in the general case?

  • I assume you want the character to actually have width (so you can see it), but so that it wont affect the text on either side? (In other words you want to add a character above the text?) – np8 Nov 15 '13 at 12:39
  • 3
    this question has several votes for closure on the grounds that it's not clear what is being asked. the question is useful, and might benefit from a change in the title. perhaps something like "joining characters in latex with no visible space between them" – barbara beeton Nov 15 '13 at 14:18
  • Title changed according to suggestion. – Mikael Fremling Oct 29 '14 at 10:33
16

The general solution is to use the optional width argument to makebox.

\makebox[0pt]{\textbullet}

However if you do this

\(\leftarrow\makebox[0pt]{\textbullet}\rightarrow\)

you will still get little spaces at the ends of the arrows (because that's what you normally want). So you may still need some negative space, unless you want to adjust the types of the math atoms themselves, like this

\(\mathord{\leftarrow}\makebox[0pt]{\textbullet}\mathord{\rightarrow}\)

If you were trying to make the whole thing into a binary operator you might do something like this

\newcommand\spaceship{\ensuremath
   \mathbin{\mathord{\leftarrow}\makebox[0pt]{\textbullet}\mathord{\rightarrow}}}

\(a\spaceship b\)

enter image description here

Note that the symbols do actually overlap, rather than abut. This is more obvious if you turn the arrows round as you originally had in your example.

\newcommand\spider{\ensuremath
    \mathbin{{\rightarrow}\makebox[0pt]{\textbullet}{\leftarrow}}}

\( a\spaceship b\) and  \( c\spider d\)

enter image description here

As pointed out in the comments, the \mathord command isn't strictly necessary either; you can achieve the same effect simply by surrounding a sub-formula with braces, as shown in the second example.

Note also that the contents of a makebox are set in horizontal mode even when they are in the middle of a maths formula, hence the use of \textbullet rather than \bullet.

  • 1
    In this case you would have to make the arrows ords to see this working e.g. writing \( {\rightarrow}\makebox[0pt]{\textbullet}{\leftarrow} \) – Andrew Swann Nov 15 '13 at 12:46
17

It mostly depends on the place where this should go. If a math symbol like the example you give is wanted, then

\[
\leftarrow\joinrel\mathrel{\bullet}\joinrel\rightarrow
\]

would be sufficient. I'm exploiting the fact that TeX inserts no space between consecutive Rel atoms; \joinrel is a small backspacing considered as a Rel atom (it's used when building long arrows by joining the arrow with minus signs). The whole construction, which probably you want to pack up in a macro, is considered as a relation symbol as far as the spacing around it is concerned. If you need it as a Bin atom, then use it as argument to \mathbin.

enter image description here

It's the same with the arrow pointing to the opposite directions:

\[
\rightarrow\joinrel\mathrel{\bullet}\joinrel\leftarrow
\]

enter image description here

In some cases a judgment on the amount of backing up is necessary. The definition of \joinrel is

\mathrel{\mkern -3mu}

and it's easy to adjust the amount based on this. For instance

\[
\rightarrow\mathrel{\mkern -2mu}\mathrel{\bullet}\mathrel{\mkern -2mu}\leftarrow
\]

would give

enter image description here

The relative shapes must be taken into account, so a general rule cannot be given.

  • Left and right have been swapped in relation to the question. – Andrew Swann Nov 15 '13 at 13:34
  • @AndrewSwann I see! I'll add that. – egreg Nov 15 '13 at 13:35

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.