如何在 Windows 上的 \include 指令中使用 cjk 路徑?

如何在 Windows 上的 \include 指令中使用 cjk 路徑?

我想使用 \input 或 \include 命令來包含一個以 cjk 字元命名的檔案。

\documentclass[UTF8]{ctexart}
\title{input with cjk path}
\begin{document}
\maketitle
\input{中文}
\end{document}

中文.tex 是

hello, world

我試過utf8編碼、gbk編碼,但xelatex顯示相同的錯誤

LaTeX Error: File `涓枃.tex' not found.

作業系統是windows,我用xelatex指令:

xelatex a.tex

我嘗試更改代碼頁,但仍然無法正常工作:

chcp 65001
xelatex a.tex

和a.log顯示

This is XeTeX, Version 3.14159265-2.6-0.99998 (TeX Live 2017/W32TeX)(preloaded format=xelatex 2017.6.21)  3 JUL 2017 20:55
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**./a.tex
(./a.tex
LaTeX2e <2017-04-15>
...
...
...
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <8> on input line 4.
LaTeX Font Info:    External font `cmex10' loaded for size
(Font)              <6> on input line 4.


LaTeX Warning: No \author given.


! LaTeX Error: File `中文.tex' not found.

Type X to quit or <RETURN> to proceed,
or enter new name. (Default extension: tex)

Enter file name: X

)
(\end occurred when \ifx on line 5 was incomplete)
(\end occurred when \ifx on line 5 was incomplete) 
Here is how much of TeX's memory you used:
 19344 strings out of 493005
 406504 string characters out of 6131656
 441240 words of memory out of 5000000
 23197 multiletter control sequences out of 15000+600000
 6602 words of font info for 39 fonts, out of 8000000 for 9000
 1348 hyphenation exceptions out of 8191
 57i,6n,68p,10436b,270s stack positions out of 5000i,500n,10000p,200000b,80000s

No pages of output.

答案1

如果我產生中文.texhello world 文件,並將主文件儲存為 UTF-8,它適用於 Windows 10(和 texlive 2017 cygwin tex)

在此輸入影像描述

如果我然後以 gbk 編碼重新保存主文件,我會收到文件未找到錯誤在我的情況下,我得到

! LaTeX Error: File `����.tex' not found.

所有字符都被 U+fffd“替換字符”替換,而不是像您的示例中那樣顯示錯誤的字符,但 utf-8 解碼的詳細信息可能取決於您擁有的 xetex 版本。

相關內容