使用 UTF-8(或至少是德语变音符号)的 Latex 列表

发布于 2024-07-26 12:58:18 字数 412 浏览 9 评论 0原文

尝试使用列表包将源文件包含到我的乳胶文档中,我在代码注释中遇到了德语元音变音的问题。 在源文件中使用

\lstset{
extendedchars=\true,
inputencoding=utf8x
}

变音符号(以 UTF-8 编码,无 BOM)会被处理,但它们会以某种方式移动到它们所包含的单词的开头。 所以

// die Größe muss berücksichtigt werden

在输入源文件中,变成

// die ößGre muss übercksichtigt werden

在输出文件中。

注意:由于我在初始设置中发现了错误,因此我大量编辑了这个问题

Trying to include a source-file into my latex document using the listings package, i got problems with german umlauts inside of the comments in the code.
Using

\lstset{
extendedchars=\true,
inputencoding=utf8x
}

Umlauts in the source files (encoded in UTF-8 without BOM) are processed, but they are somehow moved to the beginning of the word they are contained in.
So

// die Größe muss berücksichtigt werden

in the input source file, becomes

// die ößGre muss übercksichtigt werden

in the output file.

NOTE: since i found errors in my initial setup, i heavily edited this question

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(25

不如归去 2024-08-02 12:58:18

我找到了一种更简单的方法,对我有用:

\usepackage{lstings}

\lstset{
  listerate={ö}{{\"o}}1
            {ä}{{\"a}}1
            {ü}{{\"u}}1
}

I found a simpler approach, which works for me:

\usepackage{lstings}

\lstset{
  listerate={ö}{{\"o}}1
            {ä}{{\"a}}1
            {ü}{{\"u}}1
}
千纸鹤带着心事 2024-08-02 12:58:18

对于仅注释,您可以使用texcl选项:

\lstset{language=C++,texcl=true}

您的注释将变成Latex,并且您可以使用“特殊”字符

\begin{lstlisting}
int iLink = 0x01; // Paramètre entrée
\end{lstlisting}

For comments only, you can use the texcl option:

\lstset{language=C++,texcl=true}

Than your comments become Latex and you can use "special" characters

\begin{lstlisting}
int iLink = 0x01; // Paramètre entrée
\end{lstlisting}
沧笙踏歌 2024-08-02 12:58:18

这也适用于其他语言(西班牙语、丹麦语):

\documentclass[
a4paper, %% defines the paper size: a4paper (default), a5paper, letterpaper, ...
12pt %% set default font size to 12 point
]{scrartcl} %% article, see KOMA documentation (scrguide.dvi)

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage{listings}

\lstset{language=Pascal}
\lstset{literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}2
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
}

\begin{document}

[Latex: kann man Umlaute in lstlisting verwenden?]
\begin{lstlisting}
Test für Umlaut äöü ÄÖÜ ß So geht es
\end{lstlisting}

\end{document} 

This should work for other languages (Spanish, Danish) as well:

\documentclass[
a4paper, %% defines the paper size: a4paper (default), a5paper, letterpaper, ...
12pt %% set default font size to 12 point
]{scrartcl} %% article, see KOMA documentation (scrguide.dvi)

\usepackage[utf8]{inputenc}

\usepackage[T1]{fontenc}
\usepackage{listings}

\lstset{language=Pascal}
\lstset{literate=%
{Ö}{{\"O}}1
{Ä}{{\"A}}1
{Ü}{{\"U}}1
{ß}{{\ss}}2
{ü}{{\"u}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
}

\begin{document}

[Latex: kann man Umlaute in lstlisting verwenden?]
\begin{lstlisting}
Test für Umlaut äöü ÄÖÜ ß So geht es
\end{lstlisting}

\end{document} 
别闹i 2024-08-02 12:58:18

我对捷克语的贡献。

\lstset{
    inputencoding=utf8,
    extendedchars=true,
    literate=%
    {á}{{\'a}}1
    {č}{{\v{c}}}1
    {ď}{{\v{d}}}1
    {é}{{\'e}}1
    {ě}{{\v{e}}}1
    {í}{{\'i}}1
    {ň}{{\v{n}}}1
    {ó}{{\'o}}1
    {ř}{{\v{r}}}1
    {š}{{\v{s}}}1
    {ť}{{\v{t}}}1
    {ú}{{\'u}}1
    {ů}{{\r{u}}}1
    {ý}{{\'y}}1
    {ž}{{\v{z}}}1
    {Á}{{\'A}}1
    {Č}{{\v{C}}}1
    {Ď}{{\v{D}}}1
    {É}{{\'E}}1
    {Ě}{{\v{E}}}1
    {Í}{{\'I}}1
    {Ň}{{\v{N}}}1
    {Ó}{{\'O}}1
    {Ř}{{\v{R}}}1
    {Š}{{\v{S}}}1
    {Ť}{{\v{T}}}1
    {Ú}{{\'U}}1
    {Ů}{{\r{U}}}1
    {Ý}{{\'Y}}1
    {Ž}{{\v{Z}}}1
}

My contribution for Czech language.

\lstset{
    inputencoding=utf8,
    extendedchars=true,
    literate=%
    {á}{{\'a}}1
    {č}{{\v{c}}}1
    {ď}{{\v{d}}}1
    {é}{{\'e}}1
    {ě}{{\v{e}}}1
    {í}{{\'i}}1
    {ň}{{\v{n}}}1
    {ó}{{\'o}}1
    {ř}{{\v{r}}}1
    {š}{{\v{s}}}1
    {ť}{{\v{t}}}1
    {ú}{{\'u}}1
    {ů}{{\r{u}}}1
    {ý}{{\'y}}1
    {ž}{{\v{z}}}1
    {Á}{{\'A}}1
    {Č}{{\v{C}}}1
    {Ď}{{\v{D}}}1
    {É}{{\'E}}1
    {Ě}{{\v{E}}}1
    {Í}{{\'I}}1
    {Ň}{{\v{N}}}1
    {Ó}{{\'O}}1
    {Ř}{{\v{R}}}1
    {Š}{{\v{S}}}1
    {Ť}{{\v{T}}}1
    {Ú}{{\'U}}1
    {Ů}{{\r{U}}}1
    {Ý}{{\'Y}}1
    {Ž}{{\v{Z}}}1
}
半步萧音过轻尘 2024-08-02 12:58:18

我对巴西葡萄牙语的贡献。

\lstset{%
        inputencoding=utf8,
        extendedchars=true,
        literate=%
        {é}{{\'{e}}}1
        {è}{{\`{e}}}1
        {ê}{{\^{e}}}1
        {ë}{{\¨{e}}}1
        {É}{{\'{E}}}1
        {Ê}{{\^{E}}}1
        {û}{{\^{u}}}1
        {ù}{{\`{u}}}1
        {ú}{{\'{u}}}1
        {â}{{\^{a}}}1
        {à}{{\`{a}}}1
        {á}{{\'{a}}}1
        {ã}{{\~{a}}}1
        {Á}{{\'{A}}}1
        {Â}{{\^{A}}}1
        {Ã}{{\~{A}}}1
        {ç}{{\c{c}}}1
        {Ç}{{\c{C}}}1
        {õ}{{\~{o}}}1
        {ó}{{\'{o}}}1
        {ô}{{\^{o}}}1
        {Õ}{{\~{O}}}1
        {Ó}{{\'{O}}}1
        {Ô}{{\^{O}}}1
        {î}{{\^{i}}}1
        {Î}{{\^{I}}}1
        {í}{{\'{i}}}1
        {Í}{{\~{Í}}}1
}

My contribution for brazilian portuguese.

\lstset{%
        inputencoding=utf8,
        extendedchars=true,
        literate=%
        {é}{{\'{e}}}1
        {è}{{\`{e}}}1
        {ê}{{\^{e}}}1
        {ë}{{\¨{e}}}1
        {É}{{\'{E}}}1
        {Ê}{{\^{E}}}1
        {û}{{\^{u}}}1
        {ù}{{\`{u}}}1
        {ú}{{\'{u}}}1
        {â}{{\^{a}}}1
        {à}{{\`{a}}}1
        {á}{{\'{a}}}1
        {ã}{{\~{a}}}1
        {Á}{{\'{A}}}1
        {Â}{{\^{A}}}1
        {Ã}{{\~{A}}}1
        {ç}{{\c{c}}}1
        {Ç}{{\c{C}}}1
        {õ}{{\~{o}}}1
        {ó}{{\'{o}}}1
        {ô}{{\^{o}}}1
        {Õ}{{\~{O}}}1
        {Ó}{{\'{O}}}1
        {Ô}{{\^{O}}}1
        {î}{{\^{i}}}1
        {Î}{{\^{I}}}1
        {í}{{\'{i}}}1
        {Í}{{\~{Í}}}1
}

好的,现在找到了一种解决方法:

  1. 使用listingsutf8代替listings包

    \usepackage{listingsutf8}

  2. 将listings.sty复制到文档所在的文件夹

  3. 找到以下几行

    <前>\lst@CCPutMacro
    \lst@ProcessOther {"23}\#
    \lst@ProcessLetter{"24}\textdollar
    \lst@ProcessOther {"25}\%
    \lst@ProcessOther {"26}\&

  4. 在其中输入以下行(每行“注册”一个元音变音)

    \lst@ProcessLetter{"E4}{\"a} 
      \lst@ProcessLetter{"F6}{\"o} 
      \lst@ProcessLetter{"FC}{\"u} 
      \lst@ProcessLetter{"C4}{\"A} 
      \lst@ProcessLetter{"D6}{\"O} 
      \lst@ProcessLetter{"DC}{\"U} 
      \lst@ProcessLetter{"DF}{\ss{}}
  5. 保存文件

  6. 使用

    <前>\lstset{
    扩展字符=\true,
    输入编码=utf8/latin1
    }

启用 utf8 字符到 latin1 字符的映射

  1. 将源文件的行结尾从 windows (\r\n) 转换为 unix (\n)
  2. 享受

我知道这在很多方面都很丑陋,但它是唯一的解决方案到目前为止这对我有用。

ok, found kinda workaround now:

  1. instead of listings package, use listingsutf8

    \usepackage{listingsutf8}

  2. copy listings.sty to the folder the document resides

  3. find the following lines

    \lst@CCPutMacro
        \lst@ProcessOther {"23}\#
        \lst@ProcessLetter{"24}\textdollar
        \lst@ProcessOther {"25}\%
        \lst@ProcessOther {"26}\&
  4. Enter there the following lines (each "registers" one umlaut)

    \lst@ProcessLetter{"E4}{\"a}
    \lst@ProcessLetter{"F6}{\"o}
    \lst@ProcessLetter{"FC}{\"u}
    \lst@ProcessLetter{"C4}{\"A}
    \lst@ProcessLetter{"D6}{\"O}
    \lst@ProcessLetter{"DC}{\"U}
    \lst@ProcessLetter{"DF}{\ss{}}
  5. Save the file

  6. Use

    \lstset{
        extendedchars=\true,
        inputencoding=utf8/latin1
    }

to enable utf8 character to latin1 character mapping

  1. Convert line endings of your source file from windows (\r\n) to unix (\n)
  2. enjoy

I know this is ugly in many way, but its the only solution that works for me so far.

人心善变 2024-08-02 12:58:18

适用于大多数 iso 角色。 (包括我需要的瑞典语 åäöÅäÖ)

\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{literate=
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\EUR}}1 {£}{{\pounds}}1
}

来源: http://en.wikibooks.org /wiki/LaTeX/Source_Code_Listings#Encoding_issue

Works for most iso-characters. (including swedish åäöÅÄÖ which is what I needed)

\usepackage[utf8]{inputenc}
\usepackage{listings}
\lstset{literate=
  {á}{{\'a}}1 {é}{{\'e}}1 {í}{{\'i}}1 {ó}{{\'o}}1 {ú}{{\'u}}1
  {Á}{{\'A}}1 {É}{{\'E}}1 {Í}{{\'I}}1 {Ó}{{\'O}}1 {Ú}{{\'U}}1
  {à}{{\`a}}1 {è}{{\`e}}1 {ì}{{\`i}}1 {ò}{{\`o}}1 {ù}{{\`u}}1
  {À}{{\`A}}1 {È}{{\'E}}1 {Ì}{{\`I}}1 {Ò}{{\`O}}1 {Ù}{{\`U}}1
  {ä}{{\"a}}1 {ë}{{\"e}}1 {ï}{{\"i}}1 {ö}{{\"o}}1 {ü}{{\"u}}1
  {Ä}{{\"A}}1 {Ë}{{\"E}}1 {Ï}{{\"I}}1 {Ö}{{\"O}}1 {Ü}{{\"U}}1
  {â}{{\^a}}1 {ê}{{\^e}}1 {î}{{\^i}}1 {ô}{{\^o}}1 {û}{{\^u}}1
  {Â}{{\^A}}1 {Ê}{{\^E}}1 {Î}{{\^I}}1 {Ô}{{\^O}}1 {Û}{{\^U}}1
  {œ}{{\oe}}1 {Œ}{{\OE}}1 {æ}{{\ae}}1 {Æ}{{\AE}}1 {ß}{{\ss}}1
  {ç}{{\c c}}1 {Ç}{{\c C}}1 {ø}{{\o}}1 {å}{{\r a}}1 {Å}{{\r A}}1
  {€}{{\EUR}}1 {£}{{\pounds}}1
}

source: http://en.wikibooks.org/wiki/LaTeX/Source_Code_Listings#Encoding_issue

审判长 2024-08-02 12:58:18

法语更简单的方法。

\documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage[francais]{babel}
    \usepackage[T1]{fontenc}
    \usepackage{listings}
    \lstloadlanguages{R}
    \lstset{language=R}
    \lstset{%
        inputencoding=utf8,
            extendedchars=true,
            literate=%
            {é}{{\'{e}}}1
            {è}{{\`{e}}}1
            {ê}{{\^{e}}}1
            {ë}{{\¨{e}}}1
            {û}{{\^{u}}}1
            {ù}{{\`{u}}}1
            {â}{{\^{a}}}1
            {à}{{\`{a}}}1
            {î}{{\^{i}}}1
            {ô}{{\^{o}}}1
            {ç}{{\c{c}}}1
            {Ç}{{\c{C}}}1
            {É}{{\'{E}}}1
            {Ê}{{\^{E}}}1
            {À}{{\`{A}}}1
            {Â}{{\^{A}}}1
            {Î}{{\^{I}}}1
    }

    \begin{document}
    \begin{lstlisting}
    # Est-ce que ça marche : é ê è à Â Ê É Î ç Ç
    x<-rnorm(100,0,10)
    plot(density(x))
    \end{lstlisting}
    \end{document}

Simpler approach for french.

\documentclass{article}
    \usepackage[utf8]{inputenc}
    \usepackage[francais]{babel}
    \usepackage[T1]{fontenc}
    \usepackage{listings}
    \lstloadlanguages{R}
    \lstset{language=R}
    \lstset{%
        inputencoding=utf8,
            extendedchars=true,
            literate=%
            {é}{{\'{e}}}1
            {è}{{\`{e}}}1
            {ê}{{\^{e}}}1
            {ë}{{\¨{e}}}1
            {û}{{\^{u}}}1
            {ù}{{\`{u}}}1
            {â}{{\^{a}}}1
            {à}{{\`{a}}}1
            {î}{{\^{i}}}1
            {ô}{{\^{o}}}1
            {ç}{{\c{c}}}1
            {Ç}{{\c{C}}}1
            {É}{{\'{E}}}1
            {Ê}{{\^{E}}}1
            {À}{{\`{A}}}1
            {Â}{{\^{A}}}1
            {Î}{{\^{I}}}1
    }

    \begin{document}
    \begin{lstlisting}
    # Est-ce que ça marche : é ê è à Â Ê É Î ç Ç
    x<-rnorm(100,0,10)
    plot(density(x))
    \end{lstlisting}
    \end{document}
燃情 2024-08-02 12:58:18

对我来说效果很好!

我给法国队2分钱:

\lst@ProcessOther {"C0}{\`{A}}
\lst@ProcessOther {"C1}{\'{A}}
\lst@ProcessOther {"C2}{\^{A}}
\lst@ProcessOther {"C4}{\"{A}}
\lst@ProcessOther {"C7}{\c{C}}
\lst@ProcessOther {"C8}{\`{E}}
\lst@ProcessOther {"C9}{\'{E}}
\lst@ProcessOther {"CA}{\^{E}}
\lst@ProcessOther {"CB}{\"{E}}
\lst@ProcessOther {"CE}{\^{I}}
\lst@ProcessOther {"CF}{\"{I}}
\lst@ProcessOther {"D4}{\^{O}}
\lst@ProcessOther {"D6}{\"{O}}
\lst@ProcessOther {"D9}{\`{U}}
\lst@ProcessOther {"DB}{\^{U}}
\lst@ProcessOther {"E0}{\`{a}}
\lst@ProcessOther {"E1}{\'{a}}
\lst@ProcessOther {"E2}{\^{a}}
\lst@ProcessOther {"E4}{\"{a}}
\lst@ProcessOther {"E7}{\c{c}}
\lst@ProcessOther {"E8}{\`{e}}
\lst@ProcessOther {"E9}{\'{e}}
\lst@ProcessOther {"EA}{\^{e}}
\lst@ProcessOther {"EB}{\"{e}}
\lst@ProcessOther {"EE}{\^{\i}}
\lst@ProcessOther {"EF}{\"{\i}}
\lst@ProcessOther {"F4}{\^{o}}
\lst@ProcessOther {"F6}{\"{o}}
\lst@ProcessOther {"F9}{\`{u}}
\lst@ProcessOther {"FB}{\^{u}}

Works fine for me!

My 2 cents for the French side:

\lst@ProcessOther {"C0}{\`{A}}
\lst@ProcessOther {"C1}{\'{A}}
\lst@ProcessOther {"C2}{\^{A}}
\lst@ProcessOther {"C4}{\"{A}}
\lst@ProcessOther {"C7}{\c{C}}
\lst@ProcessOther {"C8}{\`{E}}
\lst@ProcessOther {"C9}{\'{E}}
\lst@ProcessOther {"CA}{\^{E}}
\lst@ProcessOther {"CB}{\"{E}}
\lst@ProcessOther {"CE}{\^{I}}
\lst@ProcessOther {"CF}{\"{I}}
\lst@ProcessOther {"D4}{\^{O}}
\lst@ProcessOther {"D6}{\"{O}}
\lst@ProcessOther {"D9}{\`{U}}
\lst@ProcessOther {"DB}{\^{U}}
\lst@ProcessOther {"E0}{\`{a}}
\lst@ProcessOther {"E1}{\'{a}}
\lst@ProcessOther {"E2}{\^{a}}
\lst@ProcessOther {"E4}{\"{a}}
\lst@ProcessOther {"E7}{\c{c}}
\lst@ProcessOther {"E8}{\`{e}}
\lst@ProcessOther {"E9}{\'{e}}
\lst@ProcessOther {"EA}{\^{e}}
\lst@ProcessOther {"EB}{\"{e}}
\lst@ProcessOther {"EE}{\^{\i}}
\lst@ProcessOther {"EF}{\"{\i}}
\lst@ProcessOther {"F4}{\^{o}}
\lst@ProcessOther {"F6}{\"{o}}
\lst@ProcessOther {"F9}{\`{u}}
\lst@ProcessOther {"FB}{\^{u}}
眼睛会笑 2024-08-02 12:58:18

与之前的帖子(yaxz 和其他人)类似,我为克罗地亚语定义了宏:

% on top
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[croatian]{babel}

% add listings package
\usepackage{listings}

% set font translations
\lstset{inputencoding=utf8}
\lstset{extendedchars=true}
\lstset{
    literate=%
    {ć}{{\'c}}1
    {č}{{\v{c}}}1
    {đ}{{\dj{}}}1
    {š}{{\v{s}}}1
    {ž}{{\v{z}}}1
    {Ć}{{\'C}}1
    {Č}{{\v{C}}}1
    {Đ}{{\DJ{}}}1
    {Š}{{\v{S}}}1
    {Ž}{{\v{Z}}}1
}

我在添加关键字“inače”时仍然遇到“小”问题。 以下不适用于“inače”:

\lstset{morekeywords={ponavljaj, ako, inače, dok}}

关键字“inače”(出现在代码中)不被识别为关键字。 有任何想法吗?

希望这会对某人有所帮助(除了我:))。

Similarly to posts before (yaxz and others) I defined macros for Croatian:

% on top
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage[croatian]{babel}

% add listings package
\usepackage{listings}

% set font translations
\lstset{inputencoding=utf8}
\lstset{extendedchars=true}
\lstset{
    literate=%
    {ć}{{\'c}}1
    {č}{{\v{c}}}1
    {đ}{{\dj{}}}1
    {š}{{\v{s}}}1
    {ž}{{\v{z}}}1
    {Ć}{{\'C}}1
    {Č}{{\v{C}}}1
    {Đ}{{\DJ{}}}1
    {Š}{{\v{S}}}1
    {Ž}{{\v{Z}}}1
}

I still have "little" problem with adding keyword "inače". Following won't work for "inače":

\lstset{morekeywords={ponavljaj, ako, inače, dok}}

Keyword "inače" (that appear in code) is not recognized as keyword. Any ideas?

Hope this will help someone (besides me :)).

别理我 2024-08-02 12:58:18

瑞典语版本:

\lstset{literate=%
{å}{{\r{a}}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{Å}{{\r{A}}}1
{Ä}{{\"A}}1
{Ö}{{\"O}}1
}

The Swedish version:

\lstset{literate=%
{å}{{\r{a}}}1
{ä}{{\"a}}1
{ö}{{\"o}}1
{Å}{{\r{A}}}1
{Ä}{{\"A}}1
{Ö}{{\"O}}1
}
彻夜缠绵 2024-08-02 12:58:18

我对立陶宛语的贡献:

\lstset{%
    literate=%
     {ą}{{\k{a}}}1
     {č}{{\v{c}}}1
     {ę}{{\k{e}}}1
     {ė}{{\.{e}}}1
     {į}{{\k{i}}}1
     {š}{{\v{s}}}1
     {ų}{{\k{u}}}1
     {ū}{{\={u}}}1
     {ž}{{\v{z}}}1
     {Ą}{{\k{A}}}1
     {Č}{{\v{C}}}1
     {Ę}{{\k{E}}}1
     {Ė}{{\.{E}}}1
     {Į}{{\k{I}}}1
     {Š}{{\v{S}}}1
     {Ų}{{\k{U}}}1
     {Ū}{{\={U}}}1
     {Ž}{{\v{Z}}}1
}

My contribution for Lithuanian language:

\lstset{%
    literate=%
     {ą}{{\k{a}}}1
     {č}{{\v{c}}}1
     {ę}{{\k{e}}}1
     {ė}{{\.{e}}}1
     {į}{{\k{i}}}1
     {š}{{\v{s}}}1
     {ų}{{\k{u}}}1
     {ū}{{\={u}}}1
     {ž}{{\v{z}}}1
     {Ą}{{\k{A}}}1
     {Č}{{\v{C}}}1
     {Ę}{{\k{E}}}1
     {Ė}{{\.{E}}}1
     {Į}{{\k{I}}}1
     {Š}{{\v{S}}}1
     {Ų}{{\k{U}}}1
     {Ū}{{\={U}}}1
     {Ž}{{\v{Z}}}1
}
慵挽 2024-08-02 12:58:18

我们都知道 LaTeX 与希腊语的关系不太好。 尽管如此,这是我的贡献,它需要几种解决方法,并且不包括变音符号(但有效!):

\usepackage[greek]{babel}
\usepackage{textgreek}
\usepackage{listings}

% Notice that here it is spelled ‘omikron’, not ‘omicron’,
% and that I use ‘\textmugreek’ instead of ‘\textmu’,
% which are both part of the textgreek package, but the
% ‘normal’ \textmu conflicts with the textcomp package as
% that uses another font for \textmu.
\DeclareUnicodeCharacter{03BF}{\textomikron}
\DeclareUnicodeCharacter{039F}{\textOmikron}
\DeclareUnicodeCharacter{03BC}{\textmugreek}

\lstset{
    inputencoding=utf8,
    extendedchars=true,
    literate=
    {α}{{\textalpha}}1   {Α}{{\textAlpha}}1
    {β}{{\textbeta}}1    {Β}{{\textBeta}}1
    {γ}{{\textgamma}}1   {Γ}{{\textGamma}}1
    {δ}{{\textdelta}}1   {Δ}{{\textDelta}}1
    {ε}{{\textepsilon}}1 {Ε}{{\textEpsilon}}1
    {ζ}{{\textzeta}}1    {Ζ}{{\textZeta}}1
    {η}{{\texteta}}1     {Η}{{\textEta}}1
    {θ}{{\texttheta}}1   {Θ}{{\textTheta}}1
    {ι}{{\textiota}}1    {Ι}{{\textIota}}1
    {κ}{{\textkappa}}1   {Κ}{{\textKappa}}1
    {λ}{{\textlambda}}1  {Λ}{{\textLambda}}1
    {μ}{{\textmugreek}}1 {Μ}{{\textMu}}1
    {ν}{{\textnu}}1      {Ν}{{\textNu}}1
    {ξ}{{\textxi}}1      {Ξ}{{\textXi}}1
    {ο}{{\textomikron}}1 {Ο}{{\textOmikron}}1
    {π}{{\textpi}}1      {Π}{{\textPi}}1
    {ρ}{{\textrho}}1     {Ρ}{{\textRho}}1
    {σ}{{\textsigma}}1   {Σ}{{\textSigma}}1   {ς}{{\textvarsigma}}1
    {τ}{{\texttau}}1     {Τ}{{\textTau}}1
    {υ}{{\textupsilon}}1 {Υ}{{\textUpsilon}}1
    {φ}{{\textphi}}1     {Φ}{{\textPhi}}1
    {χ}{{\textchi}}1     {Χ}{{\textChi}}1
    {ψ}{{\textpsi}}1     {Ψ}{{\textPsi}}1
    {ω}{{\textomega}}1   {Ω}{{\textOmega}}1
}

We all know how LaTeX doesn’t play nice with Greek. Nevertheless, here’s my contribution, which requires several workarounds, and doesn’t include diacritics (but works!):

\usepackage[greek]{babel}
\usepackage{textgreek}
\usepackage{listings}

% Notice that here it is spelled ‘omikron’, not ‘omicron’,
% and that I use ‘\textmugreek’ instead of ‘\textmu’,
% which are both part of the textgreek package, but the
% ‘normal’ \textmu conflicts with the textcomp package as
% that uses another font for \textmu.
\DeclareUnicodeCharacter{03BF}{\textomikron}
\DeclareUnicodeCharacter{039F}{\textOmikron}
\DeclareUnicodeCharacter{03BC}{\textmugreek}

\lstset{
    inputencoding=utf8,
    extendedchars=true,
    literate=
    {α}{{\textalpha}}1   {Α}{{\textAlpha}}1
    {β}{{\textbeta}}1    {Β}{{\textBeta}}1
    {γ}{{\textgamma}}1   {Γ}{{\textGamma}}1
    {δ}{{\textdelta}}1   {Δ}{{\textDelta}}1
    {ε}{{\textepsilon}}1 {Ε}{{\textEpsilon}}1
    {ζ}{{\textzeta}}1    {Ζ}{{\textZeta}}1
    {η}{{\texteta}}1     {Η}{{\textEta}}1
    {θ}{{\texttheta}}1   {Θ}{{\textTheta}}1
    {ι}{{\textiota}}1    {Ι}{{\textIota}}1
    {κ}{{\textkappa}}1   {Κ}{{\textKappa}}1
    {λ}{{\textlambda}}1  {Λ}{{\textLambda}}1
    {μ}{{\textmugreek}}1 {Μ}{{\textMu}}1
    {ν}{{\textnu}}1      {Ν}{{\textNu}}1
    {ξ}{{\textxi}}1      {Ξ}{{\textXi}}1
    {ο}{{\textomikron}}1 {Ο}{{\textOmikron}}1
    {π}{{\textpi}}1      {Π}{{\textPi}}1
    {ρ}{{\textrho}}1     {Ρ}{{\textRho}}1
    {σ}{{\textsigma}}1   {Σ}{{\textSigma}}1   {ς}{{\textvarsigma}}1
    {τ}{{\texttau}}1     {Τ}{{\textTau}}1
    {υ}{{\textupsilon}}1 {Υ}{{\textUpsilon}}1
    {φ}{{\textphi}}1     {Φ}{{\textPhi}}1
    {χ}{{\textchi}}1     {Χ}{{\textChi}}1
    {ψ}{{\textpsi}}1     {Ψ}{{\textPsi}}1
    {ω}{{\textomega}}1   {Ω}{{\textOmega}}1
}
归属感 2024-08-02 12:58:18

对于波兰语:

\lstset{%
literate=%
 {ą}{{\k{a}}}1
 {ę}{{\k{e}}}1
 {Ą}{{\k{A}}}1
 {Ę}{{\k{E}}}1
 {ś}{{\'{s}}}1
 {Ś}{{\'{S}}}1
 {ź}{{\'{z}}}1
 {Ź}{{\'{Z}}}1
 {ń}{{\'{n}}}1
 {Ń}{{\'{N}}}1
 {ć}{{\'{c}}}1
 {Ć}{{\'{C}}}1
 {ó}{{\'{o}}}1
 {Ó}{{\'{O}}}1
 {ż}{{\.{z}}}1
 {Ż}{{\.{Z}}}1
 {ł}{{\l{}}}1
 {Ł}{{\l{}}}1
}

这里是符号列表,以便您可以为您的语言创建它: https://en .wikibooks.org/wiki/LaTeX/Special_Characters

For Polish:

\lstset{%
literate=%
 {ą}{{\k{a}}}1
 {ę}{{\k{e}}}1
 {Ą}{{\k{A}}}1
 {Ę}{{\k{E}}}1
 {ś}{{\'{s}}}1
 {Ś}{{\'{S}}}1
 {ź}{{\'{z}}}1
 {Ź}{{\'{Z}}}1
 {ń}{{\'{n}}}1
 {Ń}{{\'{N}}}1
 {ć}{{\'{c}}}1
 {Ć}{{\'{C}}}1
 {ó}{{\'{o}}}1
 {Ó}{{\'{O}}}1
 {ż}{{\.{z}}}1
 {Ż}{{\.{Z}}}1
 {ł}{{\l{}}}1
 {Ł}{{\l{}}}1
}

And here's list of symbols so you can create it for your language: https://en.wikibooks.org/wiki/LaTeX/Special_Characters

请恋爱 2024-08-02 12:58:18

我可以确认 Janosch 提供的解决方案几乎可以正常工作。

就我而言,我需要使用西班牙语字符:á,é,í,ó,ú,ñ,Á,É,Í,Ó,Ú,并尝试了他的解决方案,但没有结果,直到我用 xelatex 而不是 pdflatex 编译我的文件。

无论如何,您应该在本地副本或直接在公共文件中修改listings.sty并添加以下内容:

\lst@CCPutMacro
    \lst@ProcessOther {"23}\#
    \lst@ProcessLetter{"24}\textdollar
    \lst@ProcessOther {"25}\%
    \lst@ProcessOther {"26}\&
        %spanish letters coded in UTF
    \lst@ProcessOther {"E1}{\'a}
    \lst@ProcessOther {"C1}{\'A}
    \lst@ProcessOther {"E9}{\'e}
    \lst@ProcessOther {"C9}{\'E}
    \lst@ProcessOther {"ED}{\'i}
    \lst@ProcessOther {"CD}{\'I}
    \lst@ProcessOther {"F3}{\'o}
    \lst@ProcessOther {"D3}{\'O}
    \lst@ProcessOther {"FA}{\'u}
    \lst@ProcessOther {"DA}{\'U}
    \lst@ProcessOther {"F1}{ñ}
    \lst@ProcessOther {"D1}{Ñ}

在我的.tex文件中,我使用了以下列表选项:

\usepackage{listingsutf8}
\lstset{
        inputencoding=utf8,
        extendedchars=\true}

希望它可以帮助任何人,也许我们可以构建一个listing.sty包含几乎所有 UTF8 字符...:)

I can confirm that solution provided by Janosch works almost correctly.

In my case I needed to use Spanish characters: á,é,í,ó,ú,ñ,Á,É,Í,Ó,Ú and tried his solution without results until I compiled my file with xelatex instead of pdflatex.

Anyway you should modify listings.sty either in your local copy or directly in the common file and add the following:

\lst@CCPutMacro
    \lst@ProcessOther {"23}\#
    \lst@ProcessLetter{"24}\textdollar
    \lst@ProcessOther {"25}\%
    \lst@ProcessOther {"26}\&
        %spanish letters coded in UTF
    \lst@ProcessOther {"E1}{\'a}
    \lst@ProcessOther {"C1}{\'A}
    \lst@ProcessOther {"E9}{\'e}
    \lst@ProcessOther {"C9}{\'E}
    \lst@ProcessOther {"ED}{\'i}
    \lst@ProcessOther {"CD}{\'I}
    \lst@ProcessOther {"F3}{\'o}
    \lst@ProcessOther {"D3}{\'O}
    \lst@ProcessOther {"FA}{\'u}
    \lst@ProcessOther {"DA}{\'U}
    \lst@ProcessOther {"F1}{ñ}
    \lst@ProcessOther {"D1}{Ñ}

In my .tex file I used the following options for listings:

\usepackage{listingsutf8}
\lstset{
        inputencoding=utf8,
        extendedchars=\true}

Hope it can help anybody and maybe we can construct a listing.sty containing almost every UTF8 char... :)

残龙傲雪 2024-08-02 12:58:18

我对西班牙语的贡献。

经过测试,它工作得很好,既可以导入带有西班牙字符代码的文件,也可以直接将代码片段粘贴到乳胶文档中。

\usepackage[spanish, activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}

\lstset{literate=%
    {ñ}{{\~n}}1
    {Ñ}{{\~N}}1
    {á}{{\'a}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {ó}{{\'o}}1
    {ú}{{\'u}}1
    {Á}{{\'A}}1
    {É}{{\'E}}1
    {Í}{{\'I}}1
    {Ó}{{\'O}}1
    {Ú}{{\'U}}1
}

My contribution for spanish language.

Tested, it works great, both importing files with the code with spanish characters, and pasting snippets of code directly in the latex document.

\usepackage[spanish, activeacute]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{listings}

\lstset{literate=%
    {ñ}{{\~n}}1
    {Ñ}{{\~N}}1
    {á}{{\'a}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {ó}{{\'o}}1
    {ú}{{\'u}}1
    {Á}{{\'A}}1
    {É}{{\'E}}1
    {Í}{{\'I}}1
    {Ó}{{\'O}}1
    {Ú}{{\'U}}1
}
偷得浮生 2024-08-02 12:58:18

包的作者建议使用texcl选项。 有时有帮助,有时没有。

Author of package suggests using texcl option. Sometimes it helps, sometimes doesn't.

高速公鹿 2024-08-02 12:58:18

如果您想使用任何列表包,请不要在 LaTex 中使用 UTF-8。 在文档中使用 latin1 将很好地显示德语变音符号。

我正在使用以下设置用德语写论文:

% Your language, here German
\usepackage[ngerman]{babel} 
% Will work with Umlauts
\usepackage[latin1]{inputenc}
% Euro characters etc.
\usepackage{textcomp}
% Works perfectly with latin1
\usepackage{listings}

Simply don't use UTF-8 in LaTex if you want to use any listings packages. Using latin1 in your documents will display German Umlauts just fine.

I'm writing my thesis in German using this setup:

% Your language, here German
\usepackage[ngerman]{babel} 
% Will work with Umlauts
\usepackage[latin1]{inputenc}
% Euro characters etc.
\usepackage{textcomp}
% Works perfectly with latin1
\usepackage{listings}
红ご颜醉 2024-08-02 12:58:18

最干净的解决方案是使用listings2包: http://www.atscire .de/index.php?nav=products/listings2

只需使用 \usepackage{listings2} 而不是 \usepackage{listings} 即可。

The cleanest solution for this is to use the listings2 package: http://www.atscire.de/index.php?nav=products/listings2

Simply use \usepackage{listings2} instead of \usepackage{listings} and that's it.

洛阳烟雨空心柳 2024-08-02 12:58:18

@Janosch 解决方案中 listings.sty 的挪威字母:

\lst@ProcessLetter{"C5}{\AA}
\lst@ProcessLetter{"C6}{\AE}
\lst@ProcessLetter{"D8}{\O}
\lst@ProcessLetter{"E5}{\aa}
\lst@ProcessLetter{"E6}{\ae}
\lst@ProcessLetter{"F8}{\o}

Norwegian letters for listings.sty in @Janosch's solution:

\lst@ProcessLetter{"C5}{\AA}
\lst@ProcessLetter{"C6}{\AE}
\lst@ProcessLetter{"D8}{\O}
\lst@ProcessLetter{"E5}{\aa}
\lst@ProcessLetter{"E6}{\ae}
\lst@ProcessLetter{"F8}{\o}
秋风の叶未落 2024-08-02 12:58:18

对于越南语:

\usepackage{vntex}
\usepackage[utf8]{inputenc}
\usepackage{listings}  
\usepackage{tipa}

\lstset{columns=fullflexible,literate=
{đ}{{\dj}}1
{â}{{\^a}}1
{ă}{{\u{a}}}1
{ê}{{\^e}}1
{ô}{{\^o}}1
{ơ}{{\ohorn}}1
{ư}{{\uhorn}}1
{á}{{\'a}}1
{à}{{\`a}}1
{ả}{\h{a}}1
{ã}{{\~a}}1
{ạ}{\textsubdot{a}}1
{ấ}{\'{\^a}}1
{ầ}{\`{\^a}}1
{ẩ}{\h{\^a}}1
{ẫ}{\~{\^a}}1
{ậ}{\textsubdot{\^a}}1
{ắ}{\'{\u{a}}}1
{ằ}{\`{\u{a}}}1
{ẳ}{\h{\u{a}}}1
{ẵ}{\~{\u{a}}}1
{ặ}{\textsubdot{\u{a}}}1
{é}{{\'e}}1
{è}{{\`e}}1
{ẻ}{\h{e}}1
{ẽ}{{\~e}}1
{ẹ}{\textsubdot{e}}1
{ế}{\'{\^e}}1
{ề}{\`{\^e}}1
{ể}{\h{\^e}}1
{ễ}{\~{\^e}}1
{ệ}{\textsubdot{\^{e}}}1
{í}{{\'i}}1
{ì}{{\`i}}1
{ỉ}{\h{i}}1
{ĩ}{{\~i}}1
{ị}{\textsubdot{i}}1
{ó}{{\'o}}1
{ò}{{\`o}}1
{ỏ}{\h{o}}1
{õ}{{\~o}}1
{ọ}{\textsubdot{o}}1
{ố}{\'{\^o}}1
{ồ}{\`{\^o}}1
{ổ}{\h{\^o}}1
{ỗ}{\~{\^o}}1
{ộ}{\textsubdot{\^o}}1
{ớ}{\'{\ohorn}}1
{ờ}{\`{\ohorn}}1
{ở}{\h{\ohorn}}1
{ỡ}{\~{\ohorn}}1
{ợ}{\textsubdot{\ohorn}}1
{ú}{{\'u}}1
{ù}{{\`u}}1
{ủ}{\h{u}}1
{ũ}{{\~u}}1
{ụ}{\textsubdot{u}}1
{ứ}{\'{\uhorn}}1
{ừ}{\`{\uhorn}}1
{ử}{\h{\uhorn}}1
{ữ}{\~{\uhorn}}1
{ự}{\textsubdot{\uhorn}}1
{ý}{{\'y}}1
{ỳ}{{\`y}}1
{ỷ}{\h{y}}1
{ỹ}{{\~y}}1
{ỵ}{\textsubdot{y}}1
{Đ}{{\DJ}}1
{Â}{{\^A}}1
{Ă}{{\u{A}}}1
{Ê}{{\^E}}1
{Ô}{{\^O}}1
{Ơ}{{\OHORN}}1
{Ư}{{\UHORN}}1
{Á}{{\'A}}1
{À}{{\`A}}1
{Ả}{\h{A}}1
{Ã}{{\~A}}1
{Ạ}{\textsubdot{A}}1
{Ấ}{\'{\^A}}1
{Ầ}{\`{\^A}}1
{Ẩ}{\h{\^A}}1
{Ẫ}{\~{\^A}}1
{Ậ}{\textsubdot{\^A}}1
{Ắ}{\'{\u{A}}}1
{Ằ}{\`{\u{A}}}1
{Ẳ}{\h{\u{A}}}1
{Ẵ}{\~{\u{A}}}1
{Ặ}{\textsubdot{\u{A}}}1
{É}{{\'E}}1
{È}{{\`E}}1
{Ẻ}{\h{E}}1
{Ẽ}{{\~E}}1
{Ẹ}{\textsubdot{E}}1
{Ế}{\'{\^E}}1
{Ề}{\`{\^E}}1
{Ể}{\h{\^E}}1
{Ễ}{\~{\^E}}1
{Ệ}{\textsubdot{\^{E}}}1
{Í}{{\'I}}1
{Ì}{{\`I}}1
{Ỉ}{\h{I}}1
{Ĩ}{{\~I}}1
{Ị}{\textsubdot{I}}1
{Ó}{{\'O}}1
{Ò}{{\`O}}1
{Ỏ}{\h{O}}1
{Õ}{{\~O}}1
{Ọ}{\textsubdot{O}}1
{Ố}{\'{\^O}}1
{Ồ}{\`{\^O}}1
{Ổ}{\h{\^O}}1
{Ỗ}{\~{\^O}}1
{Ộ}{\textsubdot{\^O}}1
{Ớ}{\'{\OHORN}}1
{Ờ}{\`{\OHORN}}1
{Ở}{\h{\OHORN}}1
{Ỡ}{\~{\OHORN}}1
{Ợ}{\textsubdot{\OHORN}}1
{Ú}{{\'U}}1
{Ù}{{\`U}}1
{Ủ}{\h{U}}1
{Ũ}{{\~U}}1
{Ụ}{\textsubdot{U}}1
{Ứ}{\'{\UHORN}}1
{Ừ}{\`{\UHORN}}1
{Ử}{\h{\UHORN}}1
{Ữ}{\~{\UHORN}}1
{Ự}{\textsubdot{\UHORN}}1
{Ý}{{\'Y}}1
{Ỳ}{{\`Y}}1
{Ỷ}{\h{Y}}1
{Ỹ}{{\~Y}}1
{Ỵ}{\textsubdot{Y}}1
  }

For Vietnamese:

\usepackage{vntex}
\usepackage[utf8]{inputenc}
\usepackage{listings}  
\usepackage{tipa}

\lstset{columns=fullflexible,literate=
{đ}{{\dj}}1
{â}{{\^a}}1
{ă}{{\u{a}}}1
{ê}{{\^e}}1
{ô}{{\^o}}1
{ơ}{{\ohorn}}1
{ư}{{\uhorn}}1
{á}{{\'a}}1
{à}{{\`a}}1
{ả}{\h{a}}1
{ã}{{\~a}}1
{ạ}{\textsubdot{a}}1
{ấ}{\'{\^a}}1
{ầ}{\`{\^a}}1
{ẩ}{\h{\^a}}1
{ẫ}{\~{\^a}}1
{ậ}{\textsubdot{\^a}}1
{ắ}{\'{\u{a}}}1
{ằ}{\`{\u{a}}}1
{ẳ}{\h{\u{a}}}1
{ẵ}{\~{\u{a}}}1
{ặ}{\textsubdot{\u{a}}}1
{é}{{\'e}}1
{è}{{\`e}}1
{ẻ}{\h{e}}1
{ẽ}{{\~e}}1
{ẹ}{\textsubdot{e}}1
{ế}{\'{\^e}}1
{ề}{\`{\^e}}1
{ể}{\h{\^e}}1
{ễ}{\~{\^e}}1
{ệ}{\textsubdot{\^{e}}}1
{í}{{\'i}}1
{ì}{{\`i}}1
{ỉ}{\h{i}}1
{ĩ}{{\~i}}1
{ị}{\textsubdot{i}}1
{ó}{{\'o}}1
{ò}{{\`o}}1
{ỏ}{\h{o}}1
{õ}{{\~o}}1
{ọ}{\textsubdot{o}}1
{ố}{\'{\^o}}1
{ồ}{\`{\^o}}1
{ổ}{\h{\^o}}1
{ỗ}{\~{\^o}}1
{ộ}{\textsubdot{\^o}}1
{ớ}{\'{\ohorn}}1
{ờ}{\`{\ohorn}}1
{ở}{\h{\ohorn}}1
{ỡ}{\~{\ohorn}}1
{ợ}{\textsubdot{\ohorn}}1
{ú}{{\'u}}1
{ù}{{\`u}}1
{ủ}{\h{u}}1
{ũ}{{\~u}}1
{ụ}{\textsubdot{u}}1
{ứ}{\'{\uhorn}}1
{ừ}{\`{\uhorn}}1
{ử}{\h{\uhorn}}1
{ữ}{\~{\uhorn}}1
{ự}{\textsubdot{\uhorn}}1
{ý}{{\'y}}1
{ỳ}{{\`y}}1
{ỷ}{\h{y}}1
{ỹ}{{\~y}}1
{ỵ}{\textsubdot{y}}1
{Đ}{{\DJ}}1
{Â}{{\^A}}1
{Ă}{{\u{A}}}1
{Ê}{{\^E}}1
{Ô}{{\^O}}1
{Ơ}{{\OHORN}}1
{Ư}{{\UHORN}}1
{Á}{{\'A}}1
{À}{{\`A}}1
{Ả}{\h{A}}1
{Ã}{{\~A}}1
{Ạ}{\textsubdot{A}}1
{Ấ}{\'{\^A}}1
{Ầ}{\`{\^A}}1
{Ẩ}{\h{\^A}}1
{Ẫ}{\~{\^A}}1
{Ậ}{\textsubdot{\^A}}1
{Ắ}{\'{\u{A}}}1
{Ằ}{\`{\u{A}}}1
{Ẳ}{\h{\u{A}}}1
{Ẵ}{\~{\u{A}}}1
{Ặ}{\textsubdot{\u{A}}}1
{É}{{\'E}}1
{È}{{\`E}}1
{Ẻ}{\h{E}}1
{Ẽ}{{\~E}}1
{Ẹ}{\textsubdot{E}}1
{Ế}{\'{\^E}}1
{Ề}{\`{\^E}}1
{Ể}{\h{\^E}}1
{Ễ}{\~{\^E}}1
{Ệ}{\textsubdot{\^{E}}}1
{Í}{{\'I}}1
{Ì}{{\`I}}1
{Ỉ}{\h{I}}1
{Ĩ}{{\~I}}1
{Ị}{\textsubdot{I}}1
{Ó}{{\'O}}1
{Ò}{{\`O}}1
{Ỏ}{\h{O}}1
{Õ}{{\~O}}1
{Ọ}{\textsubdot{O}}1
{Ố}{\'{\^O}}1
{Ồ}{\`{\^O}}1
{Ổ}{\h{\^O}}1
{Ỗ}{\~{\^O}}1
{Ộ}{\textsubdot{\^O}}1
{Ớ}{\'{\OHORN}}1
{Ờ}{\`{\OHORN}}1
{Ở}{\h{\OHORN}}1
{Ỡ}{\~{\OHORN}}1
{Ợ}{\textsubdot{\OHORN}}1
{Ú}{{\'U}}1
{Ù}{{\`U}}1
{Ủ}{\h{U}}1
{Ũ}{{\~U}}1
{Ụ}{\textsubdot{U}}1
{Ứ}{\'{\UHORN}}1
{Ừ}{\`{\UHORN}}1
{Ử}{\h{\UHORN}}1
{Ữ}{\~{\UHORN}}1
{Ự}{\textsubdot{\UHORN}}1
{Ý}{{\'Y}}1
{Ỳ}{{\`Y}}1
{Ỷ}{\h{Y}}1
{Ỹ}{{\~Y}}1
{Ỵ}{\textsubdot{Y}}1
  }
云柯 2024-08-02 12:58:18

对于冰岛语:

\lstset{
  literate=%
    {Á}{{\'A}}1
    {á}{{\'a}}1
    {Ð}{{\dh}}1
    {ð}{{\dh}}1
    {É}{{\'E}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {Í}{{\'I}}1
    {Ó}{{\'O}}1
    {ó}{{\'o}}1
    {Ú}{{\'U}}1
    {ú}{{\'u}}1
    {Ý}{{\'Y}}1
    {ý}{{\'y}}1
    {Þ}{{\TH}}1
    {þ}{{\th}}1
    {Æ}{{\AE}}1
    {æ}{{\ae}}1
    {Ö}{{\"O}}1
    {ö}{{\"o}}1
}

For Icelandic:

\lstset{
  literate=%
    {Á}{{\'A}}1
    {á}{{\'a}}1
    {Ð}{{\dh}}1
    {ð}{{\dh}}1
    {É}{{\'E}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {Í}{{\'I}}1
    {Ó}{{\'O}}1
    {ó}{{\'o}}1
    {Ú}{{\'U}}1
    {ú}{{\'u}}1
    {Ý}{{\'Y}}1
    {ý}{{\'y}}1
    {Þ}{{\TH}}1
    {þ}{{\th}}1
    {Æ}{{\AE}}1
    {æ}{{\ae}}1
    {Ö}{{\"O}}1
    {ö}{{\"o}}1
}
静水深流 2024-08-02 12:58:18

我对斯洛伐克语的贡献。

\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[slovak,english]{babel}

\lstset{
  extendedchars=true,
  literate=
    {á}{{\'a}}1
    {ä}{{\"a}}1
    {č}{{\v{c}}}1
    {ď}{{\v{d}}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {ĺ}{{\'l}}1
    {ľ}{{\v{l}}}1
    {ň}{{\v{n}}}1
    {ó}{{\'o}}1
    {ô}{{\^o}}1
    {ŕ}{{\'{r}}}1
    {š}{{\v{s}}}1
    {ť}{{\v{t}}}1
    {ú}{{\'u}}1
    {ý}{{\'y}}1
    {ž}{{\v{z}}}1
    {Á}{{\'A}}1
    {Ä}{{\""A}}1
    {Č}{{\v{C}}}1
    {Ď}{{\v{C}}}1
    {É}{{\'E}}1
    {Í}{{\'I}}1
    {Ĺ}{{\'L}}1
    {Ľ}{{\v{L}}}1
    {Ň}{{\v{N}}}1
    {Ó}{{\'O}}1
    {Ô}{{\^O}}1
    {Ŕ}{{\'{R}}}1
    {Š}{{\v{S}}}1
    {Ť}{{\v{T}}}1
    {Ú}{{\'U}}1
    {Ý}{{\'Y}}1
    {Ž}{{\v{Z}}}1
}

My contribution for Slovak language.

\usepackage{listings}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[slovak,english]{babel}

\lstset{
  extendedchars=true,
  literate=
    {á}{{\'a}}1
    {ä}{{\"a}}1
    {č}{{\v{c}}}1
    {ď}{{\v{d}}}1
    {é}{{\'e}}1
    {í}{{\'i}}1
    {ĺ}{{\'l}}1
    {ľ}{{\v{l}}}1
    {ň}{{\v{n}}}1
    {ó}{{\'o}}1
    {ô}{{\^o}}1
    {ŕ}{{\'{r}}}1
    {š}{{\v{s}}}1
    {ť}{{\v{t}}}1
    {ú}{{\'u}}1
    {ý}{{\'y}}1
    {ž}{{\v{z}}}1
    {Á}{{\'A}}1
    {Ä}{{\""A}}1
    {Č}{{\v{C}}}1
    {Ď}{{\v{C}}}1
    {É}{{\'E}}1
    {Í}{{\'I}}1
    {Ĺ}{{\'L}}1
    {Ľ}{{\v{L}}}1
    {Ň}{{\v{N}}}1
    {Ó}{{\'O}}1
    {Ô}{{\^O}}1
    {Ŕ}{{\'{R}}}1
    {Š}{{\v{S}}}1
    {Ť}{{\v{T}}}1
    {Ú}{{\'U}}1
    {Ý}{{\'Y}}1
    {Ž}{{\v{Z}}}1
}
对岸观火 2024-08-02 12:58:18

要向 listings 添加版权支持,请添加以下内容:

\lstset{
    %you may add line below to existed config
    literate={©}{{\copyright}}{4}
}

To add copyright support to listings, add this:

\lstset{
    %you may add line below to existed config
    literate={©}{{\copyright}}{4}
}
゛时过境迁 2024-08-02 12:58:18

您可能还需要将文档的输入编码设置为 UTF-8。 有一个 comp.text.tex 线程 讨论如何做到这一点。 以下在 GNU/Linux 上的 TeXLive 中完成此操作:

\usepackage[utf8]{inputenc}

You might need to set the document's input encoding to also be UTF-8. There's a comp.text.tex thread discussing how to do this. The following accomplishes this in TeXLive on GNU/Linux:

\usepackage[utf8]{inputenc}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文