# Pathological listings problem: tilde in \lstinline in a footnote [duplicate]

I seem to be unable to write a tilde in a \lstinline in a footnote. If you uncomment the only commented line in my minimal working example, you'll see what I mean:

\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}


edit: I'm not sure if the answer to this was quite covered in the linked post (listings in footnotes) because that question related to the listings environment, not the lstinline macro.

-

## marked as duplicate by Jubobs, Malipivo, ChrisS, Adam Liter, GuidoMay 7 '14 at 23:34

I voted to keep it closed as duplicate as the method suggested by Bruno works like a charm. –  Claudio Fiandrino May 8 '14 at 7:26

When \lstinline is in the argument to another command it works in a limited way, because it can't perform certain activities. You can try with \scantokens, which works, at least with ~.

\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}


-