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?
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?
Yes, of course.
\documentclass{article}
\begingroup
\catcode+=\active \gdef+{\mathbin{\mathrm{blurb}}} \endgroup \AtBeginDocument{\mathcode+="8000 }
\begin{document}
$x+y$
\end{document}
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.
The previous “blurb” (without keeping the meaning of +) would be
\mathactivedef{+}{\mathbin{blurb}}
+ active part. But can you elaborate on what the \mathcode does and why it must occur \AtBeginDocument?
– Steven B. Segletes
Nov 24 '15 at 16:55
blurb. How about this\ is\ Sparta?
– Gaussler
Jun 24 '21 at 14:08
;-)
– Gaussler
Jul 02 '21 at 16:03
+, but in the pdf it prints as ++.
– antshar
Jul 03 '22 at 09:19
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).
+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