我使用lstlistings
代码,可以使用 显示许多特殊字符literate
。请参阅我的 MWE
\documentclass{scrartcl}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings,textcomp,eurosym}
\begin{document}
\lstset{extendedchars=true,language=java,basicstyle=\ttfamily,showspaces=false,showstringspaces=false,literate=%
{€}{\euro}1%
{§}{\S}1%
{°}{\textdegree{}}1%
{ä}{{\"a}}1%
{ö}{{\"o}}1%
{ü}{{\"u}}1%
{ß}{{\ss}}1%
{Ä}{{\"A}}1%
{Ö}{{\"O}}1%
{Ü}{{\"U}}1%
{µ}{\textmu}1%
}
\begin{lstlisting}[language=Java]
// only for demonstration purposes
public class keystrokes {
public static void main(String[] args) {
System.out.println("keystrokes on a German keyboard: €§°äöüßÄÖܵ");
}
}
\end{lstlisting}
\end{document}
但我不知道如何识读以下字符:¹²³¼½¢
答案1
我觉得没什么奇怪的
\lstset{
extendedchars=true,
language=java,
basicstyle=\ttfamily,
showspaces=false,
showstringspaces=false,
literate=%
{€}{\euro}1%
{§}{\S}1%
{°}{\textdegree{}}1%
{ä}{{\"a}}1%
{ö}{{\"o}}1%
{ü}{{\"u}}1%
{ß}{{\ss}}1%
{Ä}{{\"A}}1%
{Ö}{{\"O}}1%
{Ü}{{\"U}}1%
{µ}{\textmu}1%
{¹}{{\textsuperscript{1}}}1%
{²}{{\textsuperscript{2}}}1%
{³}{{\textsuperscript{3}}}1%
{¼}{\textonequarter}1%
{½}{\textonehalf}1%
{¢}{\textcent}1%
}
输入
\begin{lstlisting}[language=Java]
// only for demonstration purposes
public class keystrokes {
public static void main(String[] args) {
System.out.println("keystrokes on a German
keyboard: €§°äöüßÄÖܵ¹²³¼½¢");
}
}
\end{lstlisting}
生产