LaTeX에서 문법 구문 주위에 프레임을 넣는 방법

LaTeX에서 문법 구문 주위에 프레임을 넣는 방법

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

패키지가 없는 매우 기본적인 접근 방식: a 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}

관련 정보