病的なリストの問題: 脚注の \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}

ここに画像の説明を入力してください

関連情報