
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}