开发者

Currency symbols inside lstlisting

开发者 https://www.devze.com 2023-02-12 10:01 出处:网络
I am trying to add a GBP \\pounds symbol inside lstlisting \\begin{lstlisting} Lorem ipsum 3£ \\pounds

I am trying to add a GBP \pounds symbol inside lstlisting

\begin{lstlisting}
Lorem ipsum 3£ \pounds
\end{lstlisting}

However this results in the following line:

Lorem ipsum 3Â \pounds

How do I draw correct GBP 开发者_开发知识库symbol inside lstlisting?

Thank you very much!


This should work even if it is a bit hackish:

\begin{lstlisting}[mathescape=true]
Lorem ipsum 3$\mbox{\pounds}$ \pounds
\end{lstlisting}

Move the question to tex.stackexchange.com and you'll have better answers wrt character encodings.


This even works inside verbatim and using xelatex compiler:

\usepackage{newunicodechar}
\newunicodechar{£}{\textsterling}

\begin{lstlisting}
Lorem ipsum 3£
\end{lstlisting}

\begin{verbatim}
Lorem ipsum 3£
\end{verbatim}
0

精彩评论

暂无评论...
验证码 换一张
取 消