I’m trying to typeset a grammar in org markup, but want to use latex symbols in the grammar:

a ->  hello
   |  $\neg$ world
   |  universe

• Now, without using #+BEGIN_EXAMPLE or : literal-line prefix, the | syntax gets interpreted as a table.

• The issue is that using either solution causes the Math latex statement to no longer be recognized.


  • What are you planning to do with the grammar? If you are planning to export it to LaTeX, maybe replace | by \vert? That should preserve the math, although it will admittedly look ugly in the buffer. Unfortunately, there is no way to escape | AFAIK.
    – NickD
    Oct 3 '20 at 2:37
  • @NickD Thanks so much — that’s a great suggestion. I actually am not trying to print pretty PDFs, I just like nice typesetting in buffer view because that’s where I will be studying from mostly. \vert will work well for PDF time, though! The reason I have to settle with latex in buffer is ... well, there’s no other way to type math in buffer.. might as well, since I’m typing strange stuff like #contained-in anyways...
    – ppp
    Oct 3 '20 at 4:42
  • @NickD i’m new to stack exchange, but I don’t see a way to upvote your comment! I guess I don’t have enough rep. Feel free to post it as the answer and I can accept. best regards
    – ppp
    Oct 3 '20 at 4:43

Unfortunately there is no way to escape |.

The usual suggestion is to use \vert instead of |. That will become a vertical bar in exported PDF output, although it will certainly not look pretty in the buffer itself. But it does solve the problem of Org mode interpreting | as a table starter and it will not affect use of LaTeX fragments in your file. This is also the suggested workaround when you want to include a vertical bar in the text of an entry in a table - see e.g. this question.

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.