병리학적 목록 문제: 각주 \lstinline의 물결표

병리학적 목록 문제: 각주 \lstinline의 물결표

각주에 있는 \lstinline에 물결표를 쓸 수 없는 것 같습니다. 최소한의 작업 예제에서 유일하게 주석 처리된 줄의 주석 처리를 제거하면 무슨 뜻인지 알 수 있습니다.

\documentclass{article}

\usepackage{listings}

\begin{document}
This works:
\begin{lstlisting}
~/path/to/file
\end{lstlisting}

And this works: \lstinline{~/path/to/file}

And this works:\footnote{\lstinline{/path/to/file}}

%But this does \emph{not} work:\footnote{\lstinline{~/path/to/file}}
\end{document}

listings편집: 해당 질문은 매크로 가 아니라 환경 과 관련되어 있기 때문에 링크된 게시물(각주 목록)에서 이에 대한 답변이 상당히 다루어졌는지 잘 모르겠습니다 lstinline.

답변1

\lstinline다른 명령에 대한 인수인 경우 특정 활동을 수행할 수 없기 때문에 제한된 방식으로 작동합니다. \scantokens적어도 에서는 작동하는 으로 시도해 볼 수 있습니다 ~.

\documentclass{article}

\usepackage{listings}

\begin{document}
This works:
\begin{lstlisting}
~/path/to/file
\end{lstlisting}

And this works: \lstinline{~/path/to/file}

And this works:\footnote{A path: \lstinline{/path/to/file}}

But this does \emph{not} work:\footnote{A path: \scantokens{\lstinline{~/path/to/file}\relax}}
\end{document}

여기에 이미지 설명을 입력하세요

관련 정보