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

It's just that


looks awfully bad...


  • 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 7:47
  • Sorry, maybe I should have been more explicit. I want the definition of \to to include $[\to$ being automatically printed as $[~\to$ – user153484 Jan 26 '18 at 7: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 7:54
  • I still want my code to be [\to due to readability.... – user153484 Jan 26 '18 at 8:02
  • 1
    @egreg so slow:-) – David Carlisle Jan 26 '18 at 9:05

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

enter image description here




| improve this answer | |
  • Wouldn't it be better to use f\colon\mathopen]a;b\mathclose[\to[c;d] instead of f\colon\mathopen{]}a;b\mathclose{[}\to[c;d]? (The same thing as in your answer to another question) – user227621 Nov 6 at 9:54
  • 1
    @user227621 you searching the whole site for \mathopen answers?? :-) – David Carlisle Nov 6 at 12:47