
所以,這段程式碼適用於XeLaTeX
\documentclass[12pt]{book}
\pagestyle{plain}
\usepackage[margin=1.8cm]{geometry}
\geometry{a4paper}
\usepackage[parfill]{parskip}
\usepackage{amsmath}
\usepackage{amssymb}
\usepackage{tipa}
\usepackage{fontspec}
%\newfontfamily{\AR}[Script=Arabic]{Scheherazade}
\AtBeginDocument{
\renewcommand\textipa[2][r]{{\fontfamily{cm#1}\tipaencoding #2}}
}
\renewenvironment{IPA}[1][r]
{\fontfamily{cm#1}\tipaencoding}
{}
\begin{document}
%\textipa{\slshape pUK.t\~A}
\textipa{\slshape f@"nEtIks}
\textipa[tt]{f@"nEtIks}
\begin{IPA}f@"nEtIks\end{IPA}
\begin{IPA}[tt]f@"nEtIks\end{IPA}
\begin{IPA}\slshape f@"nEtIks\end{IPA}
\end{document}
但是當我取消註解
%\textipa{\slshape pUK.t\~A}
之後的行時\begin{document}
,它不再編譯。我該如何糾正呢?
答案1
這個答案更多的是對另一種我認為更簡單的方法的建議。由於您已經在使用 Xelatex,因此您可以為文字設定常規字體,並為 IPA 設定專用字體,因此可以直接在編輯器中輸入 IPA。我認為編輯時它比tipa
.
\documentclass{article}
\usepackage{fontspec}
\setmainfont{Century Gothic}
\newfontfamily\ipafont{Charis SIL}
\newcommand\ipa[1]{{\ipafont #1}}
\begin{document}\noindent
This is a paper about Linguistics (IPA: \ipa{lɪŋgwɪstɪks}). And it goes on...
\end{document}
我已將常規字體設定為與預設字體不同的字體,更明顯的字體,因此您可以看到差異。
答案2
經過24小時的搜尋和嘗試,我終於找到了答案。我希望這可以解決所有問題,儘管隨著文件大小的增加,我可能會遇到新的錯誤。