I happen to author LaTeX code in an environment that makes entering the backslash tedious¹.

Can I somehow tell LaTeX: From now on, treat, | (or another rarely used character) as if it were a \, so that I can write my LaTeX code like

This is a |emph{very} important fact from |cite{some_paper}.

and get the same result as if I had written

This is a \emph{very} important fact from \cite{some_paper}

while normal command with \ still work as before (as they are inserted automatically by the authoring tools in certain places)?

Bonus points if I can use some unicode character (like ✓, which happens to be bound on my keyboard), to reduce the risk of clashes.

¹ Don’t ask why. Oh, you did? Well: I edit in Isabelle/jEdit, which replaces sequences like \c with special unicode characters, which is nice when working on Isabelle theories, but makes writing the documenting TeX code a pain.

  • 2
    The problem is not so much changing the behaviour of | to be the escape char as breaking other places it's used! – Joseph Wright Apr 30 '14 at 8:16
  • Not sure that it’s used so often in my files. Note that I I’d like to enable the translation somewhere in the document; it should not already apply to the preamble, or even included packages. – Joachim Breitner Apr 30 '14 at 8:33
  • If you want to use a Unicode character, you'd probably have to use XeTeX or LuaTeX. You might also consider using Markdown or XML and converting to LaTeX (or using it natively with ConTeXt). – mbork Apr 30 '14 at 8:38
  • I use jEdit as well, but don't have the character substitution you mentioned enable. Surely the easiest solution is to switch this off when writing .tex files (I don't know if there's some clever way to do it automatically, but there should be a keyboard shortcut). I'm on a windows box in work so can't test it right now. – Chris H Apr 30 '14 at 9:43
  • @ChrisH: It’s Isabelle/jEdit, which may be quite a bit different from regular jEdit (I don’t know the details, though). – Joachim Breitner Apr 30 '14 at 10:43

Simply adding

\catcode`\|=0 %

will enable | as an escape character, for example


\catcode`\|=0 %

  \item An itemize



This won't work with for example verbatim material (where \ is 'baked in' to the code).

  • 3
    While this works, it's not risk-free: if your issue is your editor, the 'correct' response seems to be to change the editor! – Joseph Wright Apr 30 '14 at 8:43
  • I know it’s an ugly and horrible hack – but still :-) – Joachim Breitner Apr 30 '14 at 10:48

with xelatex you can choose a character which isn't used in the LaTeX packages (AltGr-4) :

This is a \emph{very} important fact

This is a ¼emph{very} important fact

enter image description here


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.