
我想將 TeX Gyre 字體(尤其是 Pagella 和 Pagella Math)與 LaTeX+dvips+ps2pdf 一起使用。將來我想將其用於 PSTricks,但首先我必須解決我的字體問題。
我將此程式碼用於 LaTeX+dvips+ps2pdf
\documentclass{article}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{tgpagella}
\begin{document}
Test in Pagella
\[\sum_{k=1}^n k=\frac{n(n+1)}{2}\]
\end{document}
它會產生一個 PDF 文件,其中包含 TeX Gyre Pagella 中的文字但現代計算機中的數學(見截圖)
當將程式碼變更為以下內容時
\documentclass{article}
\usepackage{fontenc,unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\setmathfont[Ligatures=TeX]{TeX Gyre Pagella Math}
\begin{document}
Test in Pagella
\[\sum_{k=1}^n k=\frac{n(n+1)}{2}\]
\end{document}
在 DVI 模式下用 LuaLaTeX 處理它效果很好。但dvips
之後運行會出現以下錯誤
This is dvips(k) 5.992 Copyright 2012 Radical Eye Software (www.radicaleye.com)
' LuaTeX output 2013.04.01:1811' -> template-pstricks.ps
kpathsea: Invalid fontname `name:TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep;', contains ':'
dvips: Font name:TeXGyrePagella:mode=node;script=latn;language=DFLT;+tlig;+trep; not found; using cmr10
</usr/local/texlive/2012/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk>kpathsea: Invalid fontname `name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1;', contains ':'
dvips: Font name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1; not found; using cmr10
</usr/local/texlive/2012/texmf-dist/fonts/pk/ljfour/public/cm/dpi600/cmr10.pk>
dvips: ! invalid char 119899 from font name:TeXGyrePagellaMath:mode=base;script=math;language=DFLT;+tlig;+trep;+ssty=1;
我知道 dvips 無法處理 OpenType 字體,但如何將 TeX Gyre Pagella 尤其是 TeX Gyre Pagella Math 與 PSTricks 一起使用? LaTeX 或 LuaLaTeX 解決方案都會有很大幫助。
答案1
auto-pst-pdf
我現在已經透過添加程式碼解決了問題
\documentclass{article}
\usepackage{auto-pst-pdf}
\usepackage{fontenc,unicode-math}
\setmainfont[Ligatures=TeX]{TeX Gyre Pagella}
\setmathfont[Ligatures=TeX]{TeX Gyre Pagella Math}
\begin{document}
Test in Pagella
\[\sum_{k=1}^n k=\frac{n(n+1)}{2}\]
\end{document}
編譯它lualatex -shell-escape file.tex
會產生以下輸出,其中僅包含 TeX Gyre Pagella 和 TeX Gyre Pagella Math。
非常感謝@egreg 提供這個提示。
由於 @Ulrike Fischer 的評論而有所改進
顯然沒有辦法按照我想要的方式解決問題,所以我再次編輯了我的程式碼
\documentclass{article}
\usepackage{pstricks}
\usepackage{xltxtra}
\usepackage{xunicode}
\usepackage{fontenc}
\usepackage{unicode-math}
\setromanfont[Ligatures=TeX]{texgyrepagella-regular.otf}
\setmathfont[Ligatures=TeX]{texgyrepagella-math.otf}
\begin{document}
Test in Pagella
\[\sum_{k=1}^n k=\frac{n(n+1)}{2}\]
\begin{pspicture}(3,3)
\psline{->}(1,1)(3,2)
\psline{->}(1,1)(3,1)
\rput(2,2){$x$}
\end{pspicture}
\end{document}
對其進行處理xelatex file.tex
會產生所需的 PDF 文件,其中包含 TeX Gyre Pagella 和 Pagella Math
感謝@egreg 和@Ulrike Fischer 的提示。歡迎更多改進,我認為我需要學習很多東西。