mathpartir의 mathpar와 함께 목록 패키지를 사용할 수 있는 방법이 있습니까?

mathpartir의 mathpar와 함께 목록 패키지를 사용할 수 있는 방법이 있습니까?

저는 프로그래밍 언어에 대한 작은 단계 의미론을 조판하려고 합니다. 내 계획은 추론 규칙을 작성하기 위해 mathpartir 패키지를 사용하고 언어 조각을 조판하기 위해 목록 패키지를 사용하는 것이었습니다.

일반 수학 환경에서 두 패키지를 함께 사용하면 다음 이미지의 첫 번째 예에 표시된 것처럼 모든 것이 제대로 작동하는 것 같습니다. 그러나 mathpartir의 mathpar 환경을 사용하려고 하면결과가 오른쪽으로 잘못 이동되었습니다., 두 번째 예에 표시된 것처럼.

mathpartir 환경은 각 줄에 맞는 수만큼 수식을 입력하여 자동으로 수식을 구성하므로 매우 편리합니다.목록 모듈이 mathpar와 함께 작동하도록 하는 몇 가지 해결 방법이 있습니까?그렇지 않다면 적어도 결과가 잘못된 이유를 알아낼 수 있는 방법이 있습니까? 이것이 패키지의 버그라면 어떤 패키지가 책임이 있는지 알 수 없습니다.

MWE

\documentclass{article}
\usepackage{mathpartir}
\usepackage{listings}

\lstset{
  % without this the \hbox is not strictly necessary
  basicstyle={\ttfamily},
}

\begin{document}
% Works fine:
\[
  \infer{A \hbox{\lstinline!a!} A}{B \hbox{\lstinline!a!} B}
\]
% Weird shift:
\begin{mathpar}
  \infer{A \hbox{\lstinline!a!} A}{B \hbox{\lstinline!a!} B}
\end{mathpar}
\end{document}

음

답변1

전부 추적하지는 않았지만 이런 종류의 경우 평소처럼 문제가 있는 코드를 상자에 먼저 설정하는 것이 도움이 됩니다. 여기에 이미지 설명을 입력하세요

\documentclass{article}
\usepackage{mathpartir}
\usepackage{listings}

\lstset{
  % without this the \hbox is not strictly necessary
  basicstyle={\ttfamily},
}

\begin{document}
% Works fine:
\[
  \infer{A \hbox{\lstinline!a!} A}{B \hbox{\lstinline!a!} B}
\]
% Weird shift:
\newbox\bA
\setbox\bA\hbox{\lstinline!a!}
\begin{mathpar}
  \infer{A \usebox\bA{} B}{A \usebox\bA{} B}
\end{mathpar}
\end{document}

실제로 목록이 예상하는 값으로 로컬로 복원하는 것으로 충분하다면 \par(재설정은 취소되지 않으므로 여기에서와 같이 그룹에서만 사용하십시오):

\documentclass{article}
\usepackage{mathpartir}
\usepackage{listings}

\lstset{
  % without this the \hbox is not strictly necessary
  basicstyle={\ttfamily},
}

\begin{document}
% Works fine:
\[
  \infer{A \hbox{\lstinline!a!} A}{B \hbox{\lstinline!a!} B}
\]
% Weird shift:
\newcommand\zlstinline{\let\par\endgraf\lstinline}
\begin{mathpar}
  \infer{A \hbox{\zlstinline!a!} B}{A \hbox{\zlstinline!a!} B}
\end{mathpar}
\end{document}

관련 정보