The following effect is what I want: enter image description here

And I wrote corresponding code as below

\textbf{Document} ::= <Document [\textbf{\emph{documentName}}]$_0^1$  [\textbf{\emph{author}}]$_0^1$ [\textbf{\emph{date}}]$_0^1$>
                           [\textbf{Table}]$_1^n$  [\textbf{Action}]$_0^n$  [\textbf{Comment}]$_0^n$

These code do worked, but It can't show italic and bold, the following is its result. enter image description here

Thanks for your solutions!

  • maybe \lstset{ escapeinside={}} is useful. But I don't know the exact usage. Waite for your answer! – Huang Mao Jun 7 '15 at 7:04

You have already enabled mathescape. This can also be used for executing \textbf, e.g. $\textbf{Table}$.

I would use markup commands, then the code is easier to read and maintain. Also there are other options than a listings. The following example uses a tabbing environment:


  \textless /#1\textgreater
  \textless #1%

  \Element{Document} \IsDefinedAs\ \= \StartTagBegin{Document}
  \> \EndTag{Document}


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.