I am trying to define new commands starting with other symbols instead of the \(backslash) The use of \backslash is not so intuitively for non-experienced LaTeX users. So I would prefer to use ] , [ or / etc. in many cases! For example I prefer =acircum instead of \acircum because = looks like a circumflex symbol(on a) ! I tried to use \active to activate an = or other character.

For example: I tried to define new commands starting with / like /abc and /abd but the following piece of code had no success!

\catcode`/\active \def/abd{abd..}  \def/abc{abc...} Example: /abc  /abd \catcode`/=12 \let/\slash

But TeX complained

Use of / doesn't match its definition.

How one could define such commands? (I hope my question is not already duplicate! )

  • 2
    Also note that \slash already has a special definition. Don't clobber TeX – it will clobber you right back. Oct 31, 2015 at 15:10
  • 2
    Don't do it. Using = instead of backlash as the control char will break all sort keyval arguments and I don't dare to image what is will do to the math input. The slash is used in pathes and normal text too. Oct 31, 2015 at 15:15
  • @UlrikeFischer You are right! I tried to write a code for non mathematicians. So such changes are going to be used locally(inside an invironent). I hope that I will succeed.
    – kornaros
    Oct 31, 2015 at 15:36
  • 1
    Imho you are not doing them a favour. All this special syntax will mean that won't be able to use the internet to find help. Oct 31, 2015 at 15:38
  • 1
    I've recently been designing a language for use in my work – hopefully to be adopted by my coworkers. The keys to a good language include consistency, familiarity, and modularity – you are throwing all of these into the trash. I urge you to reconsider your approach. Oct 31, 2015 at 17:14

4 Answers 4


Do I advise this: No!!!

The catcode of macro escape character is 0, i.e. the catcode of / has to be changed to 0.

I did not test for the literal / however.

You can use /def/foo{blabla} then!

/def/dosomethingstupid{Something not recommended because it looks weird!}


  • ! I tried your idea with success! Thank you! How one could use your idea locally(inside a special enviroment?) In other words, how one could go back to the normal use of / ? Onother simillar question: How one could define new functions like \mycmd/ or [mycmd/ with 2 symbols (where / gives the END of the mycmd?)
    – kornaros
    Oct 31, 2015 at 15:15
  • 1
    @kornaros: Actually: I don't recommend this at all!!!!
    – user31729
    Oct 31, 2015 at 15:28
  • I tried to get back to the normal use of / with \catcode`/=12 but this does not work! Any ideas?
    – kornaros
    Oct 31, 2015 at 18:13
  • To keep it local, try defining an environment: \newenvironment{frontslash}{\catcode/=0}{\catcode/=12}. Anything between \begin{frontslash} and \end{frontslash} will have your forward-slash commands available. Please note that this is still a terrible idea, though, unless you've got a very limited use-case. Oct 31, 2015 at 20:03

An expl3 approach:


\char_set_catcode_escape:N /
\NewDocumentCommand /Abc {} { abc }


As I said: here be dragons!

  • 1
    Of course, \Abc wouldn't be any different from /Abc.
    – egreg
    Oct 31, 2015 at 15:22
  • Yes xparse is very powerfull! Please, let me ask you to generalize your unswer to more comlicated cases like [abc/ where the last charecter could be used to point the end of command. Thank you for your answer!
    – kornaros
    Oct 31, 2015 at 15:27
  • @kornaros There's no need for xparse, here.This is just the same as doing \catcode`/=0
    – egreg
    Oct 31, 2015 at 15:57
  • @kornaros egreg is right; xparse is just what I use to load expl3 (mostly out of habit). You could just as easily use \usepackage{expl3}…\newcommand/abc{abc}…. It's just an alternative approach for new code. Oct 31, 2015 at 16:30
  • @kornaros for the second question you asked here, refer to xparse documentation: \NewDocumentCommand \Abc {u/} { abc(#1) } \Abc hello/ Oct 31, 2015 at 17:10

Rather than redefine / to have the meaning of \, you could use LuaLaTeX and (a) set up a function that changes all instances of / in the text to \ "on the fly" and (b) assign this function to the so-called process_input_buffer callback, which does its work at a very early stage of processing, before (La)TeX does any of its usual work.

Of course, if you do need a forward-slash symbol in your document, you can no longer enter it as /; instead, you'll need to write /slash.

enter image description here

% !TEX TS-program = lualatex
function slash2bslash ( line )
    return line:gsub ( "/", "\\" )
%% add the Lua function to "process_input_buffer" callback:
    ( "process_input_buffer", slash2bslash, "slash2bslash" )}} 

  • Oh my God! So LuaLaTeX has pre-processing capabilities! Fantastic! No worry for any kind of "control" symbols!
    – kornaros
    Oct 31, 2015 at 15:40
  • @kornaros - LuaTeX has opened up TeX's paragraph building process, by providing "callbacks" that operate at various stages of the process. The process_input_buffer callback is one of these callbacks, and it indeed offers all kinds of possibilities for pre-processing.
    – Mico
    Oct 31, 2015 at 15:44
  • @kornaros Just be careful. It's so easy to break things this way – especially if you have no idea what you're actually doing. Oct 31, 2015 at 17:11
  • 1
    @SeanAllred - Note that my answer is "safe" as it does not change the TeX's treatment of /. Because the Lua function is assigned to the process_input_buffer callback, TeX's eyes -- let alone its mouth, stomach, etc -- do not get to see instances of / -- they will all have been converted to `` before TeX starts its own work.
    – Mico
    Oct 31, 2015 at 17:31
  • 1
    @Mico but this is the problem: every slash will be replaced by a backslash. There only need to be a real slash somewhere, e.g. in a graphicspath, or in a math and you get (exactly) the same problems as when you change the catcode of /. Oct 31, 2015 at 17:40

The amstex.tex style file for Plain TeX had @ as “alternative escape” and this was also used in amslatex (the first port of AMS-TeX to LaTeX), but then abandoned when amsmath was issued.

In AMS-TeX one could type @>f>g> for what would be typed \xrightarrow[g]{f} in amsmath (both labels were optional, so @>>> meant a right pointing arrow). The downside was that a literal @ had to be input as @@.

There was no interface for defining “@-commands”, but there is the at package by Mark Wooding that provides it (the documentation can be read with texdoc mdwtools, because this points to the first hit, which is exactly at.sty).

For instance, the package provides by default the @-command @/, whereby

@/some text in italics/

(note the matching slash at the end) is the same as typing

\textit{some text in italics}

Also predefined is @@ for printing an @. Note that @? would be different from \?: if you do

\atdef ?{`?}

the output of @? would be different from \?.

Of course, one could replicate the code for allowing other prefix characters. The big downside is that the prefix character must be made into an active one. If you want to use =-commands, such as your proposed =acircum, then you can't type = in a math formula any more (well, you'd need to be very careful).

When amsmath was released, AMS thought carefully about @-commands and decided to withdraw them and they had very good reasons for. I'm not sure where =acircum could be easier for users than \acircum. I'm inclined to believe that they'll be very confused, actually.

You just need to know that commands should be escaped and that the signal for this escape is \. Remembering different escapes for different commands would be a nightmare. Possibly funny (I'm writing this answer on All Saints' Eve), but definitely not a good user interface.

Other suggested methods such as doing \catcode`/=0 are quite different.

If you do


you can then call /Abc or \Abc and this will produce exactly the same result (unless you also changed the category code of /). Of course, you cannot use / for printing a slash.

There are good reasons for using the backslash as escape. The character is seldom, if ever, used in running text. For the set theory operation there is the semantically meaningful command \setminus (and also the command \backslash for the symbol as an ordinary atom). No other character in the ASCII range is in the same situation; except possibly @ itself (barring its usage in email addresses). Indeed, there is a TeX format that uses @ and not \ as escape: it's texinfo, that's been used for decades for TeXing documentation in GNU info format.

  • And I can vouch that Texinfo is a monstrous beast that has very few of the selling points of 'normal' TeX. Oct 31, 2015 at 17:19

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.