以下代码由 LyX 生成。我删减了原始代码以制作 MWE。无论我对此做什么,当文件尝试使用 pdflatex 进行编译时,我都会收到错误消息。
\documentclass[oneside,english,oldfontcommands,oneside, article,
extrafontsizes, 10pt, latin9, utf8, main=american]{memoir}
\usepackage[T1]{fontenc}
\usepackage{babel}
\usepackage[utf8]{inputenc}
\DeclareUnicodeCharacter{200B}{\hspace{0pt}} % This works
%\DeclareUnicodeCharacter{CC}{\"a} % Neither this
\DeclareUnicodeCharacter{00E4}{\"a} % nor this works.
\begin{document}
This is a trägar. Hello world. Goodbye.
\end{document}
如果我知道怎么做的话,我会附上日志。但这是相关部分:
! Package inputenc Error: Unicode char äga (U+CC)
(inputenc) not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.12 This is a träga
r. Hello world. Goodbye.
答案1
此 LyX 文件(复制并粘贴到您最喜欢的文本编辑器中,然后以 utf8 编码保存为 .lyx 文件)
#LyX 2.2 created this file. For more info see http://www.lyx.org/
\lyxformat 508
\begin_document
\begin_header
\textclass memoir
\options article, extrafontsizes, 10pt
\use_default_options true
\language english
\language_package default
\inputencoding utf8
\end_header
\begin_body
\begin_layout Standard
träga
\end_layout
\end_body
\end_document
将产生
\documentclass[oneside,english,oldfontcommands,article, extrafontsizes, 10pt]{memoir}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\setcounter{secnumdepth}{3}
\setcounter{tocdepth}{3}
\usepackage{babel}
\begin{document}
träga
\end{document}
两者都编译得很好,我可以在输出 pdf 中看到 ä。您的额外 documentclass 选项“latin9, utf8...”实际上不属于那里。可以在 LyX>Document>Settings...>Language>Encoding>Other:utf8 中更改输入编码。