0

How can I automatically have a space added before \to iff there is a [ before it?

It's just that

$f\colon]a;b[\to[c;d]$

looks awfully bad...

Thanks!

koleygr
  • 20,105
  • I am not sure what you are trying to print.... It is awful anyway for me (not because of distances). May be a draw or something else would help. I can not imagine what you are trying to have as your output – koleygr Jan 26 '18 at 07:47
  • Sorry, maybe I should have been more explicit. I want the definition of \to to include
    $[\to$
    
    

    being automatically printed as

    $[~\to$
    
    –  Jan 26 '18 at 07:49
  • What about a command like : \newcommand\myto{[~\to} or similar? (it has to be inside math or to be defined as \newcommand\myto{$[~\to$} to be in math mode by itself) (Yiu can redefine it to using \def or \renewcommand instead of \newcommand) – koleygr Jan 26 '18 at 07:54
  • I still want my code to be [\to due to readability.... –  Jan 26 '18 at 08:02
  • Do you also want to be able to use "\to" without "[" before of it? – koleygr Jan 26 '18 at 08:10
  • Sure. There should not be a space in cases like ]\to –  Jan 26 '18 at 08:25
  • f\colon\mathopen]a;b\mathclose[\to[c;d] – egreg Jan 26 '18 at 09:05
  • 1
    @egreg so slow:-) – David Carlisle Jan 26 '18 at 09:05
  • You should consider the interval package. – egreg Jan 26 '18 at 09:22

1 Answers1

4

] is a mathclose by default but you need it to be a mathopen:

enter image description here

\documentclass{article}

\begin{document}

$f\colon]a;b[\to[c;d]$

$f\colon\mathopen]a;b\mathclose[\to[c;d]$ \end{document}

David Carlisle
  • 757,742