8

Let's say I don't like the way the + symbol is printed inside equation: is there a way to change its appearance without defining a new command?

More generally, is it possible to create a command without the initial backslash?

  • 3
    Welcome to TeX.SE. Please be a bit more specific regarding your dislike for the way the + symbol is printed in math mode. Is it its size, shape, height above the baseline, spacing relative to adjoining symbols, or something else entirely? Separately, which (math) font do you use? – Mico Nov 24 '15 at 16:36
  • Related: http://tex.stackexchange.com/questions/2969/how-do-i-change-the-font-of-a-letter – Chris Chudzicki Nov 24 '15 at 16:39
  • I asked a new question on how to redefine multiple symbols. e.g. minus, plus and plusminus: http://tex.stackexchange.com/questions/361807/how-to-change-the-font-of-math-operators-e-g-plus-and-minus – lblb Apr 02 '17 at 20:28

2 Answers2

17

Yes, of course.

\documentclass{article}

\begingroup \catcode+=\active \gdef+{\mathbin{\mathrm{blurb}}} \endgroup \AtBeginDocument{\mathcode+="8000 }

\begin{document} $x+y$ \end{document}

enter image description here

Of course you can think to better definition for the “math active” +. ;-)


A more general approach where you can also use an equivalent of the character being “redefined”.

\documentclass{article}

\makeatletter \newcommand{\mathactivedef}[3][]{% \begingroup\lccode~=#2\lowercase{\endgroup\def~}{#3}% \if\relax\detokenize{#1}\relax \else @ifdefinable{#1}{\mathchardef#1=\mathcode#2\relax}% \fi \AtBeginDocument{\mathcode#2="8000 }% } @onlypreamble{\mathactivedef} \makeatother

\mathactivedef[\keptplus]{+}{\mathbin{(\mkern-2mu\keptplus\mkern-2mu)}}

\begin{document}

$x+y$

\end{document}

In the optional argument to \mathactivedef you set the equivalent name that you can use in the body of the redefinition.

enter image description here

The previous “blurb” (without keeping the meaning of +) would be

\mathactivedef{+}{\mathbin{blurb}}
egreg
  • 1,121,712
0

I found a really great, more general answer at https://newbedev.com/make-characters-active-via-macro-in-math-mode (at the bottom of the page).