TeX Live 2018 找不到字体 Inconsolata

TeX Live 2018 找不到字体 Inconsolata

我第一次安装 Tex Live 。我能够为基本的 LaTeX 文件生成 PDF sample2e.tex,,small2e.textestpage.texnfssfont.tex提到的生成PDF这里

当我尝试使用下面的代码从 R 创建一本书时,我收到这个(非常长的)错误:

>system("xelatex -interaction=batchmode r-packages ")
This is XeTeX, Version 3.14159265-2.6-0.99999 (TeX Live 2018/W32TeX) (preloaded format=xelatex)
 restricted \write18 enabled.
entering extended mode
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata/BI, rootname = Inconsolata/BI, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata/BI.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata/BI.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata/B, rootname = Inconsolata/B, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata/B.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata/B.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata/I, rootname = Inconsolata/I, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata/I.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata/I.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

kpathsea: Running mktexmf Inconsolata.mf

The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm
kpathsea: Appending font creation commands to missfont.log.

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata/BI

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata/B

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata/I

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

kpathsea: Running mktextfm Inconsolata

The command name is C:\texlive\2018\bin\win32\mktextfm

我认为错误消息的相关部分是:

name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!
kpathsea: Running mktexmf Inconsolata.mf
The command name is C:\texlive\2018\bin\win32\mktexmf
Cannot find Inconsolata.mf.
name = Inconsolata, rootname = Inconsolata, pointsize = 
mktexmf: empty or non-existent rootfile!

我尝试运行建议的代码这里,似乎Inconsolata在我的计算机上找到:

C:\Users...>tlmgr search --global --all Inconsolata
  tlmgr.pl: package repository 
  http://ftp.math.purdue.edu/mirrors/ctan.org/systems/texlive/tlnet (not
  verified: gpg unavailable)
  inconsolata - A monospaced font, with support files for use with TeX
  inconsolata:
        texmf-dist/fonts/opentype/public/inconsolata/InconsolataN-Bold.otf
        texmf-dist/fonts/opentype/public/inconsolata/InconsolataN-Regular.otf
        texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Bold.otf
        texmf-dist/fonts/opentype/public/inconsolata/Inconsolatazi4-Regular.otf
        texmf-dist/fonts/type1/public/inconsolata/Inconsolata-zi4b.pfb
        texmf-dist/fonts/type1/public/inconsolata/Inconsolata-zi4r.pfb
        texmf-dist/fonts/type1/public/inconsolata/InconsolataN-Bold.pfb
        texmf-dist/fonts/type1/public/inconsolata/InconsolataN-Regular.pfb
C:\Users...>tlmgr search --global --file Inconsolata.mf
  tlmgr.pl: package repository 
  http://ftp.math.purdue.edu/mirrors/ctan.org/systems/texlive/tlnet (not
  verified: gpg unavailable)
C:\Users...>tlmgr install tlmgr.pl
  tlmgr.pl: package repository 
  http://ftp.math.purdue.edu/mirrors/ctan.org/systems/texlive/tlnet (not
  verified: gpg unavailable)
  tlmgr.pl install: package tlmgr.pl not present in repository.
  tlmgr.pl: action install returned an error; continuing.
  tlmgr.pl: An error has occurred. See above messages. Exiting.

当我运行时,tlmgr-gui.exe它会列出Inconsolata已安装的软件包。那么为什么我会收到错误“找不到 Inconsolata.mf”?谢谢。

答案1

包中有一个 inconsolata.fontspec,当您尝试按名称加载字体时会用到它。但它只在 Windows 上正确工作,如果我用小写的 i 调用字体,用大写的 I 调用字体,就会出现错误消息:

\documentclass{article}

\usepackage{fontspec}
%\setmainfont{Inconsolata} %breaks
\setmainfont{inconsolata}  %works
\begin{document}
abc

\end{document}

答案2

在开始之前,我应该列出我的环境信息。这应该适用于去年流通的 R 和 latex 版本。当然,这是一份针对 Linux 的指南,但经过简单的修改,应该可以移植到其他操作系统

uname -a Linux First-Floor 4.4.0-18362-Microsoft #476-Microsoft 2019 年 11 月 1 日星期五 16:53:00 PST x86_64 x86_64 x86_64 GNU/Linux

latex -v pdfTeX 3.14159265-2.6-1.40.18 (TeX Live 2017/Debian) kpathsea 版本 6.2.3

在继续之前,我应该说,我发现以下帖子非常有用,有助于理解 mktexlsr 或 texhash 如何从 texlive 配置中找到目录树:

https://ipfs-sec.stackexchange.cloudflare-ipfs.com/tex/A/question/20160.html

阅读完该页面后,我们了解到我家里的发行版(windows 子系统 linux,ubuntu 在 /usr/share/texlive/texmf-dist 中有发行版,在 /usr/local/share/texmf 中有本地树,而在工作中,大约两三年前的 CENTOS 7.4 在 /usr/share/texlive/texmf-dist 中有发行版,在 /usr/share/texlive/texmf-local 中有本地树。这看起来很有问题,因为本地树当然应该在 /usr/local/share 中,这样它们就不会被包更新覆盖,但到目前为止一切都很好。这些是我在家里采取的步骤。

  1. 找到你的 tex 发行版的主分支。对于我最近的 texlive,其主分支是 /usr/share/texlive/texmf-dist
  2. 正如上面链接的帖子中提到的,通过查看主发行版 texmf 根目录中的 web2c 子文件夹中的 texmf.cnf 文件来找出本地树的位置。

    cd /usr/share/texlive/texmf-dist/web2c
    less texmf.cnf
    
  3. 就我而言,我们在那里了解到

    % Local additions to the distribution trees.
    TEXMFLOCAL = /usr/local/share/texmf
    
  4. 这就是我们的起点。如果你没有以下子目录,请创建它们

    sudo mkdir -p /usr/local/share/texmf
    sudo mkdir -p /usr/local/share/texmf/doc
    sudo mkdir -p /usr/local/share/texmf/fonts
    sudo mkdir -p /usr/local/share/texmf/tex/latex/inconsolata
    
  5. 下载 inconsolata-zi4.zip 包

    cd ~/Downloads
    wget http://tug.ctan.org/tex-archive/fonts/inconsolata-zi4.zip
    unzip inconsolata-zi4.zip
    
  6. 以 root 身份执行以下命令(第一个命令是成为 root)。注意“MyName”是您的用户主目录的名称

    sudo su -
    cp ~/Downloads/inconsolata/doc /usr/local/share/texmf/doc
    cp -ru ~/Downloads/inconsolata/tex/* /usr/local/share/texmf/tex/latex/inconsolata
    dns="enc map opentype tfm type1"
    for d in $dns; do
      mkdir -p /usr/local/share/texmf/fonts/$d/inconsolata
      cp -ru /home/MyName/Downloads/inconsolata/$d/* /usr/local/share/texmf/fonts/$d/inconsolata
    done
    
  7. 执行 README 文件的“A”块中的某些命令,注意自定义本地 texmf 树的路径。

    sudo echo Map zi4.map >> /usr/local/share/texmf/web2c/updmap.cfg
    sudo mktexlsr
    sudo -H updmap-sys
    

这对我来说效果很好。现在 R CMD 检查 mypkg 是否能够构建手册。

相关内容