listings
我怎样才能像我们使用的那样在 LaTeX 中为语法语法添加一个框架frame = single
?例如,对于这个语法:
\documentclass{article}
\usepackage{syntax}
\begin{document}
\begin{grammar}
<statement> ::= <ident> `=' <expr>
\alt `for' <ident> `=' <expr> `to' <expr> `do' <statement>
\alt `{' <stat-list> `}'
\alt <empty>
<stat-list> ::= <statement> `;' <stat-list> | <statement>
\end{grammar}
\end{document}
感谢您的任何帮助!
答案1
带包装的一种方法framed
:
\documentclass{article}
\usepackage{syntax}
\usepackage{framed}
\begin{document}
\begin{framed}
\begin{grammar}
<statement> ::= <ident> `=' <expr>
\alt `for' <ident> `=' <expr> `to' <expr> `do' <statement>
\alt `{' <stat-list> `}'
\alt <empty>
<stat-list> ::= <statement> `;' <stat-list> | <statement>
\end{grammar}
\end{framed}
\end{document}
答案2
不使用包的最基本方法:minipage
使用 a \fbox{}
:
\documentclass{article}
\usepackage{syntax}
\begin{document}
\fbox{\begin{minipage}{9cm}
\begin{grammar}
<statement> ::= <ident> `=' <expr>
\alt `for' <ident> `=' <expr> `to' <expr> `do' <statement>
\alt `{' <stat-list> `}'
\alt <empty>
<stat-list> ::= <statement> `;' <stat-list> | <statement>
\end{grammar}
\end{minipage}}
\end{document}