编译utf8编码的tex文件使用中文truetype

发信人: aickgaven (Michael), 信区: TeX
标 题: 编译utf8编码的tex文件使用中文truetype
发信站: 水木社区 (Fri Apr 21 12:51:50 2006), 站内

要从truetype安装新的中文GBK字体,使用hooklee的xGBKfonts
xGBKfonts -usesys -o c:\Downloads HWXW.ttf xinwei
将产生的文件移到localtexmf相应的位置。然后在updmap.cfg中加入关于type1
信息的map文件
initexmf -u initexmf --mkmaps
这样latex没有问题,dvips可以使用type1字体,dvipdfmx可以使用type1或者直
接使用truetype字体,只要编译使用
dvipdfmx -f cid-x.map *.dvi
就可以,pdflatex可以使用type1字体,若要直接使用truetype,在preamble中
加入\pdfmapfile{=cjk_ttf.map}。但是奇怪的是使用simsun或者华文的ttf编译
通过,使用方正的ttf产生的enc和map就始终出错……而dvipdfmx使用方正的ttf却
没有问题。

倘若tex文件是utf8编码的,也可以使用CJK。需要把
\begin{CJK}{GBK}{kai}
之类的改为
\begin{CJK}{UTF8}{}
当然也可以在最后一个花括号里加入song,kai之类的,但是如果文件中含有其
他语言编码的话会出错,可行的方法是
\begin{CJK}{UTF8}{cyberb}
不过里面的中文字体非常难看,可以在中文的地方改为
\CJKfamily{kai}
之类的。比如下面这个例子
----------------------------------------------------------------------------------------------
\documentclass[a4paper,11pt]{article}
\usepackage{CJK}
%\pdfmapfile{=cyberbit.map}
%\pdfmapfile{=ttf-unixinwei.map}
\begin{document}
\begin{CJK*}{UTF8}{}
\CJKfamily{kai}%中文
机遇与挑战并存,新的世界商务体系对并不成熟的中国服务业提出了新的要求。
当今中国服务业的国际化程度如何?从历史数据中又能否推测出中国服务业发展
国际化怎样的趋势?本文收集了近20年来中国的国际收支平衡表和其它相关数据
进行分析,并借鉴已有的研究成果,来浅谈这个问题。

\CJKfamily{cyberb}
%韩语
일부 시스템에서 Gabest Filter들이 연결되지 않던 문제

%德语
Alle Produkte werden auf einer größtmöglichen Anzahl von Plattformen
(Windows, Mac, Linux, Unix-Varianten, Mainframes) und
Entwicklungsumgebungen (COM, C, C++, Java, Perl, PHP, Python, Cobol,
RPG, and Tcl) angeboten.

%日语
PDFlib GmbH社は、ウェブサーバやデータベースサーバ上でオンデマンドのPDF
処理を可能にする、最先端のソフトウェア開発ツールを提供します。

%法语
Le Centre du cancer Roger Maris à Fargo, Dakota du Nord
\end{CJK*}
\end{document}
-------------------------------------------------------------------------------------
将上面的文件保存为utf8编码,用latex编译可以通过。注意需要有
c70cyberb.fd和c70kai.fd两个文件,如果没有可以参考下面aloft的例子,放在
localtexmf\tex\latex\CJK\UTF8\下
-------------------------------------------------------------------------------------
% This is the file c70kai.fd of the CJK package
% for using Asian logographs (Chinese/Japanese/Korean) with LaTeX2e
%
% created by Aloft <aloft@ctex.org>
%
% Version 4.6.0 (26-Nov-2005)

\def\fileversion{4.6.0}
\def\filedate{2005/11/25}
\ProvidesFile{c70kai.fd}[\filedate\space\fileversion]


% character set: Unicode U+0080 - U+FFFD
% font encoding: Unicode

\DeclareFontFamily{C70}{kai}{\hyphenchar \font\m@ne}

\DeclareFontShape{C70}{kai}{m}{n}{<-> CJK * unikai}{}
\DeclareFontShape{C70}{kai}{bx}{n}{<-> CJKb * unikai}{\CJKbold}
\DeclareFontShape{C70}{kai}{m}{sl}{<-> CJK * unikaisl}{}
\DeclareFontShape{C70}{kai}{bx}{sl}{<-> CJKb * unikaisl}{\CJKbold}
\DeclareFontShape{C70}{kai}{m}{it}{<-> CJK * unikaisl}{}
\DeclareFontShape{C70}{kai}{bx}{it}{<-> CJKb * unikaisl}{\CJKbold}

\endinput
---------------------------------------------------------------------------------
当然还要有tfm文件,一般在\localtexmf\fonts\tfm\bitstrea\cyberbit\和
\localtexmf\fonts\tfm\chinese\unikai(sl)下,如果没有可以参考下文自己产
生。这样产生的dvi文件可以用dvipdfmx编译为pdf,需要在cid-x.map中加入
unikai@Unicode@ UniGB-UTF16-H :0:simkai.ttf
unikaisl@Unicode@ UniGB-UTF16-H :0:simkai.ttf -s .167
cyberb@Unicode@ Identity-H :0:cyberbit.ttf
通过以上步骤就可以编译多语言的utf8 tex文件为pdf。

若要使用pdflatex编译utf8编码tex文件使用truetype字体需要有enc文件。将
\texmf\ttf2tfm\base下的Unicode.sfd以及ttf文件拷贝到
c:\temp
运行ttf2tfm
ttf2tfm simkai.ttf -w unikai@Unicode@
ttf2tfm simkai.ttf -w -s 0.167 unikaisl@Unicode@
ttf2tfm cyberbit.ttf -w cyberb@Unicode@
将产生的*.enc文件放入相应目录,如果没有tfm文件的也把tfm文件放入相应目
录,然后自己创建map文件,比如叫ttf-unikai.map和cyberbit.map,文件中是
类似
unikai00 <unikai00.enc <simkai.ttf
unikai01 <unikai01.enc <simkai.ttf
unikai02 <unikai02.enc <simkai.ttf
unikai03 <unikai03.enc <simkai.ttf
unikai04 <unikai04.enc <simkai.ttf
unikai20 <unikai20.enc <simkai.ttf
unikai21 <unikai21.enc <simkai.ttf
unikai22 <unikai22.enc <simkai.ttf
的内容。在tex文件的preamble中加入
\pdfmapfile{=cyberbit.map}
\pdfmapfile{=ttf-unixinwei.map}
这样就可以使用pdflatex编译了。产生utf8的type1字体没有试过。不知道在linux下怎么样
--

※ 来源:·水木社区 http://newsmth.net·[FROM: 162.105.106.*]
Initial Win CP for (console input, console output, system): (CP936, CP936, CP936) I changed them all to CP936 Rc files read: NONE Latexmk: This is Latexmk, John Collins, 27 Dec. 2024. Version 4.86a. No existing .aux file, so I'll make a simple one, and require run of *latex. Latexmk: applying rule 'pdflatex'... Rule 'pdflatex': Reasons for rerun Category 'other': Rerun of 'pdflatex' forced or previously required: Reason or flag: 'Initial setup' ------------ Run number 1 of rule 'pdflatex' ------------ ------------ Running 'pdflatex -synctex=1 -interaction=nonstopmode -file-line-error -recorder "c:/Users/91643/Downloads/CS_structure/template/document.tex"' ------------ This is pdfTeX, Version 3.141592653-2.6-1.40.27 (TeX Live 2025) (preloaded format=pdflatex) restricted \write18 enabled. entering extended mode (c:/Users/91643/Downloads/CS_structure/template/document.tex LaTeX2e <2024-11-01> patch level 2 L3 programming layer <2025-01-18> (./bistuthesis.cls Document Class: bistuthesis 2024/01/01 BISTU Thesis Template (c:/texlive/2025/texmf-dist/tex/latex/tools/array.sty) (c:/texlive/2025/texmf-dist/tex/latex/arydshln/arydshln.sty) (c:/texlive/2025/texmf-dist/tex/latex/adjustbox/adjustbox.sty (c:/texlive/2025/texmf-dist/tex/latex/xkeyval/xkeyval.sty (c:/texlive/2025/texmf-dist/tex/generic/xkeyval/xkeyval.tex (c:/texlive/2025/texmf-dist/tex/generic/xkeyval/xkvutils.tex (c:/texlive/2025/texmf-dist/tex/generic/xkeyval/keyval.tex)))) (c:/texlive/2025/texmf-dist/tex/latex/adjustbox/adjcalc.sty) (c:/texlive/2025/texmf-dist/tex/latex/adjustbox/trimclip.sty (c:/texlive/2025/texmf-dist/tex/latex/graphics/graphicx.sty (c:/texlive/2025/texmf-dist/tex/latex/graphics/graphics.sty (c:/texlive/2025/texmf-dist/tex/latex/graphics/trig.sty) (c:/texlive/2025/texmf-dist/tex/latex/graphics-cfg/graphics.cfg) (c:/texlive/2025/texmf-dist/tex/latex/graphics-def/pdftex.def))) (c:/texlive/2025/texmf-dist/tex/latex/collectbox/collectbox.sty) (c:/texlive/2025/texmf-dist/tex/latex/adjustbox/tc-pdftex.def)) (c:/texlive/2025/texmf-dist/tex/latex/ifoddpage/ifoddpage.sty) (c:/texlive/2025/texmf-dist/tex/latex/varwidth/varwidth.sty)) (c:/texlive/2025/texmf-dist/tex/latex/tools/tabularx.sty) (c:/texlive/2025/texmf-dist/tex/latex/multirow/multirow.sty) (c:/texlive/2025/texmf-dist/tex/latex/tools/calc.sty) (c:/texlive/2025/texmf-dist/tex/latex/amsfonts/amssymb.sty (c:/texlive/2025/texmf-dist/tex/latex/amsfonts/amsfonts.sty)) (c:/texlive/2025/texmf-dist/tex/latex/ragged2e/ragged2e.sty) (c:/texlive/2025/texmf-dist/tex/latex/fancyhdr/fancyhdr.sty) (c:/texlive/2025/texmf-dist/tex/latex/ctex/ctexbook.cls (c:/texlive/2025/texmf-dist/tex/latex/ctex/config/ctexbackend.cfg) (c:/texlive/2025/texmf-dist/tex/latex/l3kernel/expl3.sty (c:/texlive/2025/texmf-dist/tex/latex/l3backend/l3backend-pdftex.def)) Document Class: ctexbook 2022/07/14 v2.5.10 Chinese adapter for class book (CTEX) (c:/texlive/2025/texmf-dist/tex/latex/ctex/ctexhook.sty) (c:/texlive/2025/texmf-dist/tex/latex/ctex/ctexpatch.sty) (c:/texlive/2025/texmf-dist/tex/latex/base/fix-cm.sty (c:/texlive/2025/texmf-dist/tex/latex/base/ts1enc.def)) (c:/texlive/2025/texmf-dist/tex/latex/ctex/config/ctexopts.cfg) (c:/texlive/2025/texmf-dist/tex/latex/base/book.cls Document Class: book 2024/06/29 v1.4n Standard LaTeX document class (c:/texlive/2025/texmf-dist/tex/latex/base/bk10.clo)) (c:/texlive/2025/texmf-dist/tex/latex/ctex/engine/ctex-engine-pdftex.def (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJKutf8.sty (c:/texlive/2025/texmf-dist/tex/generic/iftex/ifpdf.sty (c:/texlive/2025/texmf-dist/tex/generic/iftex/iftex.sty)) (c:/texlive/2025/texmf-dist/tex/latex/base/inputenc.sty) (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJK.sty (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/mule/MULEenc.sty) (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJK.enc)) (c:/texlive/2025/texmf-dist/tex/latex/base/fontenc.sty)) (c:/texlive/2025/texmf-dist/tex/latex/cjkpunct/CJKpunct.sty (c:/texlive/2025/texmf-dist/tex/latex/cjkpunct/CJKpunct.spa)) (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJKspace.sty) (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/UTF8/UTF8.bdg) (c:/texlive/2025/texmf-dist/tex/latex/ctex/ctexspa.def)) (c:/texlive/2025/texmf-dist/tex/latex/zhnumber/zhnumber.sty (c:/texlive/2025/texmf-dist/tex/latex/zhnumber/zhnumber-utf8.cfg)) (c:/texlive/2025/texmf-dist/tex/latex/ctex/scheme/ctex-scheme-chinese-book.def (c:/texlive/2025/texmf-dist/tex/latex/ctex/config/ctex-name-utf8.cfg)) (c:/texlive/2025/texmf-dist/tex/latex/ctex/ctex-c5size.clo) (c:/texlive/2025/texmf-dist/tex/latex/ctex/fontset/ctex-fontset-windows.def)) (c:/texlive/2025/texmf-dist/tex/latex/ctex/config/ctex.cfg) (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJKfntef.sty (c:/texlive/2025/texmf-dist/tex/latex/cjk/texinput/CJKulem.sty (c:/texlive/2025/texmf-dist/tex/generic/ulem/ulem.sty))) (c:/texlive/2025/texmf-dist/tex/latex/fontspec/fontspec.sty (c:/texlive/2025/texmf-dist/tex/latex/l3packages/xparse/xparse.sty) c:/texlive/2025/texmf-dist/tex/latex/fontspec/fontspec.sty:101: Fatal Package fontspec Error: The fontspec package requires either XeTeX or (fontspec) LuaTeX. (fontspec) (fontspec) You must change your typesetting engine to, (fontspec) e.g., "xelatex" or "lualatex" instead of (fontspec) "latex" or "pdflatex". Type <return> to continue. ... l.101 \msg_fatal:nn {fontspec} {cannot-use-pdftex} Latexmk: Getting log file 'document.log' Latexmk: Examining 'document.fls' Latexmk: Examining 'document.log' Latexmk: Errors, so I did not complete making targets Latexmk: Sometimes, the -f option can be used to get latexmk to try to force complete processing. But normally, you will need to correct the file(s) that caused the error, and then rerun latexmk. In some cases, it is best to clean out generated files before rerunning latexmk after you've corrected the files. Collected error summary (may duplicate other messages): pdflatex: Command for 'pdflatex' gave return code 1 Refer to 'document.log' and/or above output for details C:\texlive\2025\bin\windows\runscript.tlu:922: command failed with exit code 12: perl.exe c:\texlive\2025\texmf-dist\scripts\latexmk\latexmk.pl -synctex=1 -interaction=nonstopmode -file-line-error -pdf -outdir=c:/Users/91643/Downloads/CS_structure/template c:/Users/91643/Downloads/CS_structure/template/document 报错是什么原因?
最新发布
05-31
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值