The "\" in all of the commands requires frequent finger gymnastics of the pinky of the right hand in LaTeX, at least for the touch typist. It occurred to me that although it makes things more readable via syntax highlighting, it certainly slows things down.

So, is there a way to, for certain often used commands, to eliminate the "\"?

For instance to type: textit{some text here}; textbf{some more text here}; quotation{some text here}; item instead of \textit; \textbf; \quotation; \item etc.

Not that I really mind stretching my right pinky frequently.

  • 15
    How should LaTeX know that you mean the word item in context This item is a weird question instead of the command form \item or in your version: item? Or quotation? On a US - Keyboard layout the backslash character is left to the Enter key, so this is not really a finger breaking procedure ;-)
    – user31729
    Commented Dec 18, 2015 at 6:28
  • 2
    One can do this by making everything active (so called 'ActiveTeX'), which has from time to time seemed attractive to various people. Life gets tricky as @ChristianHupfer notes when you get down to the fact that TeX is about typesetting, so we have text as well as code.
    – Joseph Wright
    Commented Dec 18, 2015 at 9:48
  • 10
    I don't recommend this, regardless whether possible or not,but it's my personal opinion, of course
    – user31729
    Commented Dec 18, 2015 at 9:50
  • 1
    You may wish to consider preprocessing your document with pandoc. You can write simple commands in markdown, and still fallback to latex for more sophisticated macros
    – Aditya
    Commented Apr 16, 2016 at 16:10
  • 1
    (remark: I remember reading somewhere that historically Knuth originally intend to use just "special keyword", but then decide against it and use the \. I can't remember where I read it though)
    – user202729
    Commented Jul 8, 2022 at 6:32

4 Answers 4


Escape category code for other character

The escape character, which starts commands is not fixed and can be changed, e.g.:

\catcode`\|=0 % escape category code as the backslash
|textit{some text here}; |textbf{some more text here};

The tricky part is finding the right character, which does not clash with other uses of it. It depends on the keyboard layout and the characters already used in the text.

If _ is used, then the subscript feature in math mode is available via command \sb (or then _sb).


Another way is to post-process the input file with a regular expression, which checks for known command words, ensure that no letter is preceding or following and adds the backslash in front. For example, a simple expression for Perl:

  • The | character is on the same key as `\` so this does not prevent the finger stretching (I know, that this is an example only)
    – user31729
    Commented Dec 18, 2015 at 6:37
  • Yes, this depends on your keyboard layout.
    – Karlo
    Commented Dec 18, 2015 at 7:45
  • 2
    @ChristianHupfer On my keyboard, the | and \ are on opposite sides. It simply depends on the keyboard layout, which differs between languages.
    – Sverre
    Commented Dec 18, 2015 at 8:43
  • @Sverre: As I stated (basically) in my comment below the question: Using a US keyboard layout it's the same key ;-) I use US layout for programming and TeXing and German for mails (in German).
    – user31729
    Commented Dec 18, 2015 at 8:53
  • @ChristianHupfer Your comment below the question does not say that | and \ are on the same key on a US keyboard. It says that \ is left of the Enter key :)
    – Sverre
    Commented Dec 18, 2015 at 8:57

Thinking outside the \box: instead of looking for a TeX solution, look for a general solution. You want to type X for Y. That's what editors excel at. Well, the good ones at least.

The best one is, of course, vi (or vim or gvim), a touch-typist's dream come true. You could, for example, remap the backslash to a key that's more easily reached.

imap # \

Or, if that interferes with other documents you write, selectively use insert-mode abbreviations such as

iabbr textit \textit

It's easy to restrict such mapping to files with a .tex extension only.

  • 7
    +1. Don't change LaTeX, change your editor or keyboard layout. Altering the syntax of the language can bite you in many ways (collaborators, code reuse, copy-and-pasting code to and from other sources...). Especially with a language that is as quirky to parse as LaTeX. Commented Dec 19, 2015 at 10:54
  • This could be the start of a very interesting Vim plugin. Commented Dec 19, 2015 at 15:53
  • If I used vim this would be wonderful. But I use emacs, usually in org-mode, and I am beginner user. I have not explored using emacs as my LaTeX editor though. Will emacs do similar remapping and substitution?
    – A Feldman
    Commented Jan 10, 2016 at 16:41
  • @AFeldman somethin' in the .emacs file I think would do, like (defun (backslash () (interactive) (insert (kbd "\\"))) (global-set-key (kbd ";" ) 'backslash) or whatever
    – doed
    Commented Jun 13, 2016 at 12:59
  • @doed thanks. I love emacs. Unfortunately my current TeX workflow doesn't allow for its use regularly.
    – A Feldman
    Commented Jun 14, 2016 at 12:06

(Edited answer significantly to provide further generality)

Here's a LuaLaTeX-based solution that lets you omit the \ (backslash) character from sectioning commands, \begin{<some environment>}, \end{<some environment>}, \item, and font shape-changing commands such as \textit, \bfseries, \scshape, and \ttfamily. Writing the backslash character is permitted, but not required. Note that no substitute for \ needs to be entered.

There are but a few syntax rules:

  • section and subsection directives must be placed at the start of a line.

  • item instructions must be the first items (pun intended) on a line other than (possibly) whitespace.

  • Finally, if you have created macros ill-advisedly named \bend, \fend, \lend, \send or \tend, they must not take arguments -- so that they can be distinguished from \end! Please don't create macros named, say, \xxtextrm or \zzitshape unless you want to make the Lua code below unfit for use.

% !TEX TS-program = lualatex

function add_backslash ( x )
  -- sectioning commands
  x = string.gsub ( x , "^\\?(section)"          , "\\%1" )
  x = string.gsub ( x , "^\\?(subsection)"       , "\\%1" )
  x = string.gsub ( x , "\\?(subsubsection%s-{)" , "\\%1" )
  x = string.gsub ( x , "\\?(paragraph%s-{)"     , "\\%1" )
  -- \begin and \end of environments
  x = string.gsub ( x , "\\?(begin%s-{)"      , "\\%1" )
  x = string.gsub ( x , "\\?(end%s-{)"        , "\\%1" )
  -- \item 
  x = string.gsub ( x , "^%s-\\?(item)"       , "\\%1" )
  -- \text?? (rm, sf, up, bf, it, ...)
  x = string.gsub ( x , "\\?(text[^e]%l)"     , "\\%1" )
  -- \??shape (it, sc, ...)
  x = string.gsub ( x , "\\?(%l[^e]shape)"    , "\\%1" )
  -- \??series (bf, md, ...)
  x = string.gsub ( x , "\\?(%l%lseries)"     , "\\%1" )
  -- \??family (sf, tt, ...)
  x = string.gsub ( x , "\\?(%l%lfamily)"     , "\\%1" )
return x
luatexbase.add_to_callback("process_input_buffer", add_backslash, "add_backslash")

begin {document} 

subsection {today,}    
 subsubsection   {gone}
   paragraph {tomorrow.}

  item A
   item B
item C

 begin{equation}  1+1=2  end{equation}

    item X is not equal to the following item:
    item Y
    item Z

       a &= b\\
       c &= d

textit{abc}, textsc{def}, textbf{ghi}, textsf {jkl}

{itshape abc}, {scshape def}, {bfseries ghi}, {sffamily jkl}


Note the complete absence of any and all backslash characters after the \end{luacode*} directive. I must confess that this code looks positively spooky to me.

enter image description here

  • What happens if you reshape something after a reply from somebody you texted earlier?
    – cfr
    Commented Dec 19, 2015 at 0:37
  • @cfr - I don't know what to say. Is your comment aimed at something I wrote or did?
    – Mico
    Commented Dec 19, 2015 at 1:50
  • If you typeset my comment in the environment, won't it think that contains two commands? Or have I misunderstood the syntax of Lua's regex expressions?
    – cfr
    Commented Dec 19, 2015 at 2:58
  • @cfr - Ah, now I get it. Let me narrow down the scope of some of the pattern-matching expressions.
    – Mico
    Commented Dec 19, 2015 at 3:40

In the end I found myself agreeing with Federico Poloni and Rmano, that it is better to reassign keys. The \ key on my keyboard is just to the left of the Shift key, so I swapped the / key with the \ key using my ~/.Xmodmap file, using xev to determine the keycode and keysym for each as per Swapping the left Alt and Ctrl keys in Ubuntu 11.10

In ubuntu 14.04, with this http://www.knizefamily.net/russ/blog/wp-content/uploads/2012/01/keyboard-model-m-1.jpg as my keyboard, I added the following to my .Xmodmap file:

keycode 61 = backslash bar

keycode 51 = slash question

Beware though if you use this key for passwords, in a X Window dependent terminal, like gnome terminal, it also remaps the key for that terminal. This might cause a bit of consternation if it happens to be part of your sudo password. This does not happen in a real terminal.

For the Mac user I understand that the same thing can be accomplished with Karabiner.

  • Why don't you simply make use of automatic completion? You would obtain \begin{figure} by typing bfig and pressing esc (in TeXShop, but other editor allow auto completion)
    – Enlico
    Commented Dec 22, 2015 at 20:38
  • esc on my keyboard is even further away than the \ key.
    – A Feldman
    Commented Dec 23, 2015 at 0:04
  • Sure, but you could hit 5 keys (namely "B F I G Esc") to get \begin{figure}. insted of 13+4 keys (B E G I N Alt+Shift+è F I G U R E Alt+Shift++). Maybe you could change the key to get autocompletion, but I don't know every editors..
    – Enlico
    Commented Dec 23, 2015 at 8:59
  • I have never used auto-complete. I think it is because in order to use it you have to look at what it has auto-completed on the screen, make sure that it is right, then push Enter. I realize that this becomes automatic after a while, when you become familiar with your auto-complete items.
    – A Feldman
    Commented Dec 23, 2015 at 18:17
  • As you do, I agree with Federico Poloni and Rmano: leave LaTeX unchanged - reassign keys. Anyway, as you pointed out, the use of auto-completion is just a matter of getting used to, so I suggest you to take advantage of this tool ;)
    – Enlico
    Commented Dec 24, 2015 at 9:11

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .