
嘗試在 LaTeX 原始碼中使用純文字 Unicode(UTF-8 編碼)符號。對有問題的符號做了自己的定義,僅限 ASCII,只是為了證明這個概念。
\documentclass[12pt]{article}
\usepackage[utf8]{inputenc}
\usepackage[verbose]{newunicodechar}
%⋮
% Unicode
\newunicodechar{♢}{<>}
\newunicodechar{⧫}{!}
\newunicodechar{⬠}{(P)}
%⋮
\begin{document}
%⋮
\subsection{Introduction}
♢ ⧫ ⬠
%…
\end{document}
由於沒有任何 \newunicodechar,編譯慘遭失敗:
This is pdfTeX, Version 3.14159265-2.6-1.40.15 (TeX Live 2014/Debian) (preloaded format=latex 2015.4.1) 10 JUL 2017 16:47
entering extended mode
restricted \write18 enabled.
%&-line parsing enabled.
**PP5_tiling.tex
(./PP5_tiling.tex
LaTeX2e <2014/05/01>
⋮
(/usr/share/texlive/texmf-dist/tex/latex/newunicodechar/newunicodechar.sty
Package: newunicodechar 2012/11/12 v1.1 Defining Unicode characters
)
⋮
! Package inputenc Error: Unicode char \u8: not set up for use with LaTeX.
See the inputenc package documentation for explanation.
Type H <return> for immediate help.
...
l.63 ♢
⧫ ⬠
?
Ī̲ 可能做錯什麼?
答案1
錯誤訊息是
! Package inputenc Error: Unicode char (U+202F)
(inputenc) not set up for use with LaTeX.
和 U+202F NARROW NO-BREAK SPACE 沒有任何定義。
如果我為其添加聲明,就沒有問題。
\documentclass[12pt]{article}
\usepackage[T1]{fontenc}
\usepackage[utf8]{inputenc}
\usepackage[verbose]{newunicodechar}
%⋮
% Unicode
\newunicodechar{♢}{<>}
\newunicodechar{⧫}{!}
\newunicodechar{⬠}{(P)}
\newunicodechar{ }{\nolinebreak\hspace{.1em}}
%⋮
\begin{document}
%⋮
\subsection{Introduction}
♢ ⧫ ⬠
%…
\end{document}
請注意 T1 編碼,否則您不會得到<
和>
。
為什麼您會收到不同的錯誤訊息?因為您使用的是三年前的 TeX 發行版。是時候更新了。