The following effect is what I want:
And I wrote corresponding code as below
\begin{lstlisting}[mathescape]
\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$
</Document>
\end{lstlisting}
These code do worked, but It can't show italic and bold, the following is its result.
Thanks for your solutions!
Best Answer
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: