unicode - 在 Fantasyvrb 的 VerbatimOut 中使用 Unicode

标签 unicode latex verbatim

问题
VerbatimOut “fancyvrb”包中的 UTF-8 字符不能很好地播放。

最小工作示例:

\documentclass{minimal}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{fancyvrb}

\begin{document}
\begin{VerbatimOut}{\jobname.test}
é
\end{VerbatimOut}

\input{\jobname.test}
\end{document}

错误信息

使用 pdflatex mini 编译时,这给出了错误

File ended while scanning use of \UTFviii@three@octets.



当唯一出现 é 时会出现不同的错误以上被其他东西取代,例如é */ :

Package inputenc Error: Unicode char \u8:### not set up for use with LaTeX.



– 表明在这种情况下,LaTeX 成功读取了一个多字节 UTF-8 字符,但不知道如何处理它(即它是错误的字符)。

事实上,当我打开生成的 .test 时手动文件,它包含字符 é , 但采用拉丁 1 编码 !

证明:当我在十六进制编辑器中打开文件时,我得到以下信息:
  • 原文件:C3 A9 (对应于 UTF-8 中带有 ACUTE 的拉丁文小写字母 E)
  • 书面文件:E9 (对应于拉丁语 1 中的 é)



  • 如何设置VerbatimOut正确吗?
    filecontents* (来自“filecontents”)表明它可以工作。不幸的是,我不理解任何一个代码,所以我无法通过手动复制文件内容中的逻辑来修复fancyvrb 的代码。

    我也不能使用 filecontents*而不是 VerbatimOut因为前者在 \newenvironment 中不起作用,而后者是。

    (哦,顺便说一句:vanilla Verbatim 而不是 VerbatimOut 也按预期工作。错误似乎是在写入文件时发生,而不是在读取逐字输入时发生)

    最佳答案

    您的最终目标是逐字书写符号和重音符号吗?因为你可以这样做:

    \documentclass{article}
    \usepackage{fancyvrb}
    \begin{document}
    \begin{Verbatim}[commandchars=\\\{\}]
    \'{e} \~{e} \`{e} \^{e}
    \end{Verbatim}
    \end{document}
    

    commandchars 选项允许 \ { }字符正常工作。

    来源:http://ctan.mirror.garr.it/mirrors/CTAN/macros/latex/contrib/fancyvrb/fancyvrb.pdf

    关于unicode - 在 Fantasyvrb 的 VerbatimOut 中使用 Unicode,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/2132933/

    相关文章:

    bash - 存储在 Bash 变量中的逐字文本

    java - f :verbatim called before form submission 内的 setter/getter

    LaTeX 抑制分页符

    r - Knit 无法编译 PDF : "Error in tools::file_path_as_absolute(output_file)"

    python - u'string' 和 unicode(string) 的区别

    javascript - 如何将混合的 ascii 和 unicode 转换为 javascript 中的字符串?

    arrays - latex NiceMatrix : Error when using large matrices with Block-Command

    latex 逐字 :how to show the file directoy created by tree command?

    python - 允许输入 Unicode 转义作为命令行参数

    mysql - 如果现有数据都是 ASCII,是否需要在 MySQL 中在 Latin1 和 UTF-8 之间进行转储和转换?