356. LaTeX技巧302:TeXLaTeX宏包冲突集锦

您所在的位置:网站首页 graphicx 356. LaTeX技巧302:TeXLaTeX宏包冲突集锦

356. LaTeX技巧302:TeXLaTeX宏包冲突集锦

#356. LaTeX技巧302:TeXLaTeX宏包冲突集锦| 来源: 网络整理| 查看: 265

Or name \end... illegal, see p.192 of the manual. 【解决方案】 http://www.tex.ac.uk/cgi-bin/texfaq2html?label=alreadydef

Fontspec and Inputenc

如下代码是完全多余的。

\usepackage[utf8]{inputenc}

\usepackage{fontspec}

fontspec宏包需要XeTeX或者XeLaTeX模式下。XeTeX需要UTF8的字符输入。因此指定 inputenc参数完全是多余的。尽管还没发现出现报错信息,据说可能会致使意外的错误。如果你使用fontspec,就不应再使用inputenc 了。如果你坚持使用,需要更明晰的unicode的支持,可以尝试使用xunicode宏包来替代(尽管我发现即使不用,XeTeX还是能理解所输入的 utf8字符的。)

\usepackage{fontspec}

\usepackage{xunicode}

几乎等价于:

\usepackage{xltxtra} % loads graphicx, fontspec, xunicode and others

XeLaTeX and Babel

Babel还不能和XeTeX互相兼容。

如:

\usepackage[german]{babel} \font\wsc="Arno Pro" 会产生如下错误: ! Font \wsc= not loadable: Metric (TFM) file or installed font not found. 主要是由于babel修改了“的含义,使得("o替代了"o). 解决方案是使用fontspec的\setmainfont或者用\fontspec替代\font,近来避免使用引号。 \usepackage[german]{babel} \usepackage{fontspec} \setromanfont{Arno Pro} 复制代码 或使用polyglossia替代babel。且 polyglossia和XeTeX搭配地很好。 \usepackage[german]{polyglossia} \usepackage{fontspec} \setromanfont{Arno Pro} 复制代码

Hyperref and fncychap

【报错讯息】

In the PDF Table of Contents, the link and page number for Appendix 1 points to Chapter 1, even though the name is correct.

【解 决方案】

原因主要是宏包的不兼容。

只需 hyperref放在fncychap后面加载。

\usepackage[PetersLenny]{fncychap} \usepackage[plainpages=false,pdfpagelabels]{hyperref} 复制代码

Fancy Chapters (fncychap) and Polyglossia

我们经常使用 fncychap来修改章标题样式,如下代码:

\usepackage{fncychap} \ChTitleVar{\Huge\bfseries\sffamily} % Use Sans Serif for chapter titles 复制代码 系 统报错如下:

All chapter headers are in sans serif font, except for the table of contents, index and bibliography header, which are still in roman font. 主要是由于polyglossia一个bug所产生的,解决方案是使用babel来替换polyglossia。或者重定义

captionsenglish, captiongerman。

链接盒子太高

【报错讯息】

The border around borders around links, as created by hyperref is too high. This looks bad.

这个错误主要是用于拉丁现代字体导致的,计算机现代字体相对好一些。如图:

David Jones分析了这一问题。结果是拉丁现代字体的字母上半部分和下半部分比计算机现代字体要高一些。不幸的 是,Xdvipdfmx引擎总会计算字体的上半部分和下半部分的盒子高度,而不是字体的线高度或字形高度。

因此 这一问题的解决方案是使用不用的引擎或者使用其他字体来解决。如果没有可选择的,可以修改xdvipdfmx的源代码。

XeTeX 0.996, fontspec and Latin Modern

Error:

Random characters (garbled text) when using the fontspec package.

First of all, make sure you specified fonts for all font families: roman, serif and monospaced:

\usepackage{fontspec} % OpenType/TrueType font support. Requires XeTeX.

% CMU = Computer Modern Unicode, see https://cm-unicode.sourceforge.net/

\defaultfontfeatures{Mapping=tex-text}

\setmainfont{CMU Serif}

\setsansfont{CMU Sans Serif}

\setmonofont{CMU Typewriter Text}

Latin Modern is an extension to the older Computer Modern font set, and is the default font in the fontspec package. However, the naming convention of Latin Modern (lm) changed around the time TexLive 2007 came out. If you use Latin Modern with TexLive 2007, you will get the random characters in the output file. In order to fix this, either use another font, such as Computer Modern Unicode (CMU) or upgrade to a newer version of XeTeX and the fontspec package.

Enable Small Capitals with Fontspec

Error: Latin Modern does not have small capitals. (\textsc{Small Capitals} does not work).

If you use XeTeX and fontspec, you need to specify which font XeTeX uses for small capitals. For Latin Modern Roman, that is Lation Modern Roman Caps, and for Latin Modern Mono, that is Latin Modern Mono Caps. Latin Modern Sans does not have a small capital variant.

\usepackage{fontspec}

\setmainfont[SmallCapsFont={* Caps}]{Latin Modern Roman}

\setsansfont{Latin Modern Sans} % There is no small caps variant

\setmonofont[SmallCapsFont={Latin Modern Mono Caps}]{Latin Modern Mono Light}

Bold Typewriter is Not Bold

Error: \texttt{Typewriter \textbf{Bold}} gives normal (not bold) text.

The standard LaTeX typewriter (Computer Modern) font does not have a distinguishable bold variant. Neither does the replacement font Latin Modern.

See LaTeX Bold Typewriter Font how to solve this.

Output File Removed

If you run XeTeX, and no PDF file is created and the output gives the notice:

Output file removed.

If you see this, you can get more details by splitting the run process in two:

xelatex --no-pdf test

xdvipdfmx test.xdv

or (depending on your default driver):

xelatex --no-pdf test

xdv2pdf test.xdv

The xdvipdfmx or xdv2pdf driver typically gives a more detailed error message. (see next entry.)

Failed to Find Font

Error:

xdv2pdf : can't find font object for font id 2949602.

xdv2pdf : WARNING: Type1 font data returned by OFAStreamPSDownload isn't in the correct format required by the Adobe Type 1Font Format specification.

xdv2pdf : ATSFontGetPostScriptName failed: error -984.

ttf_create_with_id: failed to find font object for id 2949602.

xdv2pdf : WARNING: --font-2949602-6--: missing or invalid font descriptor.

All these errors are caused by xdv2pdf, which is a relative old driver for XeTeX. You are recommended to use the xdvipdfmx driver, which is the default since XeTeX 0.999.7 (present in TexLive 2008 or later). Alternatively, specify the driver explicitly (though you may need to install it first):

xelatex -output-driver=xdvipdfmx test

or:

xelatex --no-pdf test

xdvipdfmx -vv test.xdv

Warning:

WARNING: Type1 font data returned by OFAStreamPSDownload isn't in the correct format required by the Adobe Type 1Font Format specification.

If you only get the above warning, you can safely ignore it, as the output will look good. The cause of this error is yet unknown. The solution according to the XeTeX site is to use a different Font. However, I got the same problem with all sort of fonts.

If you get the other errors about missing fonts, your document will not look good. While at first sight it may look good, I found that some texts are missing in pictures and formulas.

Invalid Font Description

Error:

** WARNING ** Found file "/Library/Fonts/Optima.dfont" for PFB font but it doesn't look like a PFB...

*** ERROR ** Invalid font: -1 (0)

or:

** ERROR ** Cannot proceed without the "native" font: CMUSerif-Roman (CMU Serif Roman)...

If you encounter the above errors, first of all, make sure you use a recent version of XeTeX. I encountered to above errors with version 0.999.6, while version 0.999.7 and higher works fine.

If you still get the errors with XeTeX 0.999.7 or higher, run

xelatex --no-pdf test xdvipdfmx -vv test.xdv

And examine the output and log files. Perhaps a font is not found or could not be loaded.

QQ群:91940767 BBS:http://bbs.chinatex.org http://latexstudio.taobao.com Email:[email protected]


【本文地址】


今日新闻


推荐新闻


CopyRight 2018-2019 办公设备维修网 版权所有 豫ICP备15022753号-3