
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
沒有包包的非常基本的方法: aminipage
和 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}