在网上发现了一个和围棋有个的latex包, 名为igo https://ctan.org/tex-archive/fonts/igo

下载下来后不知道如何安装, 使用texlive的包管理器Texlive Manager无法找到包igo,也就无法安装, 在命令行行用

tlmgr install 宏包名

的方式也提示找不到igo, igo.zip解压后的目录结构为:

.
├── 1.txt
├── fonts
│   ├── igo.mf
│   ├── igo10.mf
│   ├── igo11.mf
│   ├── igo12.mf
│   ├── igo15.mf
│   ├── igo20.mf
│   ├── igo5.mf
│   ├── igo6.mf
│   ├── igo7.mf
│   ├── igo8.mf
│   ├── igo9.mf
│   ├── igoblacki.mf
│   ├── igoblacki10.mf
│   ├── igoblacki11.mf
│   ├── igoblacki12.mf
│   ├── igoblacki15.mf
│   ├── igoblacki20.mf
│   ├── igoblacki5.mf
│   ├── igoblacki6.mf
│   ├── igoblacki7.mf
│   ├── igoblacki8.mf
│   ├── igoblacki9.mf
│   ├── igoblackii.mf
│   ├── igoblackii10.mf
│   ├── igoblackii11.mf
│   ├── igoblackii12.mf
│   ├── igoblackii15.mf
│   ├── igoblackii20.mf
│   ├── igoblackii5.mf
│   ├── igoblackii6.mf
│   ├── igoblackii7.mf
│   ├── igoblackii8.mf
│   ├── igoblackii9.mf
│   ├── igoblackiii.mf
│   ├── igoblackiii10.mf
│   ├── igoblackiii11.mf
│   ├── igoblackiii12.mf
│   ├── igoblackiii15.mf
│   ├── igoblackiii20.mf
│   ├── igoblackiii5.mf
│   ├── igoblackiii6.mf
│   ├── igoblackiii7.mf
│   ├── igoblackiii8.mf
│   ├── igoblackiii9.mf
│   ├── igoroman.mf
│   ├── igowhitei.mf
│   ├── igowhitei10.mf
│   ├── igowhitei11.mf
│   ├── igowhitei12.mf
│   ├── igowhitei15.mf
│   ├── igowhitei20.mf
│   ├── igowhitei5.mf
│   ├── igowhitei6.mf
│   ├── igowhitei7.mf
│   ├── igowhitei8.mf
│   ├── igowhitei9.mf
│   ├── igowhiteii.mf
│   ├── igowhiteii10.mf
│   ├── igowhiteii11.mf
│   ├── igowhiteii12.mf
│   ├── igowhiteii15.mf
│   ├── igowhiteii20.mf
│   ├── igowhiteii5.mf
│   ├── igowhiteii6.mf
│   ├── igowhiteii7.mf
│   ├── igowhiteii8.mf
│   ├── igowhiteii9.mf
│   ├── igowhiteiii.mf
│   ├── igowhiteiii10.mf
│   ├── igowhiteiii11.mf
│   ├── igowhiteiii12.mf
│   ├── igowhiteiii15.mf
│   ├── igowhiteiii20.mf
│   ├── igowhiteiii5.mf
│   ├── igowhiteiii6.mf
│   ├── igowhiteiii7.mf
│   ├── igowhiteiii8.mf
│   ├── igowhiteiii9.mf
│   └── makefonts.bat
├── igo.pdf
├── igo.sty
├── igo.tex
├── README
├── repeat.tex
└── russian
    ├── igo-ru.pdf
    └── igo-ru.tex

2 directories, 87 files

在安装的时候按网络上的提示,把igo目录存放到D:\texlive\2019\texmf-dist\tex\latex

然后用命令

texhash

之后,编译例子igo tex文件就可以启动编译了,但是找不到字体文件, 然后把igo中的fonts中的所有文件复制到igo目录中,然后把这个目录拷贝到D:\texlive\2019\texmf-dist\fonts\source\public 发现还是找不到. 继续寻找解决的方法:

按照上面的步骤,把igo直接存放到D:\texlive\texmf-local下是不行的, 需要把fonts目录重命名为igo,拷贝到D:\texlive\texmf-local\fonts\source\local下.

就可以使用这个宏包了.

参考

Manually install a package in MikTeX/TeXLive

https://huang3.github.io/2016/10/26/how-to-manual-pkg-miktex/>

install 3rd Package in MikTex

Firstly, check README files, available documentation of the package, perhaps the beginning of the .dtx file to get installation information.

Installing a package available as dtx/ins bundle:

  • Download the content of the package directory. dtx is the extension of a documented source file, ins is the extension of an installation file.
  • Run LaTeX (or TeX) on the .ins file. This may be done using your editor or at the command prompt (latex packagename.ins). This would usually produce one or more files ending with .sty, perhaps some additional files. As you now have cls or sty files or the like, the remaining steps are the same like in the next alternative way:

Installing sty or cls files:

Create a new directory with the package name in your tex directory structure. With MiKTeX that directory might be

C:\Program Files\MiKTeX 2.8\texmf\tex\latex\packagename\.

Copy the package files (.sty, .cls etc.) into this directory. Make the new package known to MiKTeX: refresh the MiKTeX filename database. To do this, click Start/ Programs/ MiKTeX 2.8/ Maintenance/ Settings (or similar) to get to the MiKTeX options, click the button “Refresh FNDB”. The installation is complete.

If you did not download the documentation already, you could get it by running pdfLaTeX or LaTeX on the .dtx file. Compile twice to get correct references.

Install style/fonts in TexLive on OSX

If yon got a package shipped with tree like this:

../
    - fonts/
    - tex/

You should firstly put the folder in /usr/local/texlive/texmf-local/, there you store the 3rd styles/fonts. Now you need to rebuild the index (perhaps with root permission):

sudo texhash

Then create font maps, e.g.,:

sudo updmap-sys --enable Map=pfr.map

pfr.map is the font map you want your tex system to see. After enabling the maps, you should update your maps again:

sudo updmap-sys

Now your tex system sees the new installed fonts and styles.

Installing TeX fonts

http://www.tug.org/fonts/fontinstall.html

This web page is about installing a font that has already been prepared for use with TeX (typically pdftex and/or dvips). Using a font that did not come with your TeX distribution requires several steps. Before we go into those details, consider these two alternatives:

  • If the font can be made generally available on your computer (e.g., to other word processing programs), you can use XeTeX or LuaTeX to access it directly, without any TeX-specific installation at all.
  • If the font is one of several nonfree families, you can run the getnonfreefonts program. Run getnonfreefonts --lsfonts to see the list of fonts it can install. (This script essentially performs the steps below.)

Also, this web page doesn’t try to cover everything (it’s already plenty complicated). Limitations:

  • This web page is not about the work of preparing the support files. That is a much more complicated job; see the brief list of utilities here and the vast and general Font Installation Guide and Fontinst documentation for starters, if you want to delve into that.
  • This web page is about installing fonts in a system-wide directory. If you don’t have permission or don’t want to do that, you’ll have to use a personal directory (such as TEXMFHOME). Instructions for installing fonts in a personal directory are given separately.

The TUG fonts page has references to fonts commonly used with TeX, and general information on TeX font usage.

1. Destination texmf-local: your local TeX tree

The first step is to determine in what directory the new font will live. You can’t choose just any directory, it has to be part of the TeX hierarchy. The best choice is your “local texmf” tree, which you can determine as follows:

Navigate through the MiKTeX program: Start > Programs > MiKTeX > Maintenance > Roots (or MiKTeX Settings, in older versions). Some paths shown there have a Description such as Install, UserConfig, or UserData. A tree labeledUserConfig (but not any of the others) is an acceptable target for your new fonts, if you have no permission to create a new tree. However, it is better to use a tree without a description, as follows:You can create a new local tree by clicking on Add. The folder must not contain files at its root level or MiKTeX will reject it. Files in the folder must be in subfolders similar to the subfolders in the Install root. (MiKTeX info.)

From a system terminal (aka command prompt, shell window) enter the command kpsewhich --var-value TEXMFLOCAL to see the directory name. The default on Unix is /usr/local/texlive/texmf-local.

If you are not using one of the above TeX distributions, you’ll need to consult other documentation.

2. The TeX Directory Structure: unpacking your archive

After determining your local tree for installation (see previous section), the next step is to copy the new files into subdirectories of that tree. Hopefully, your new font came as a zip or other archive file that is already arranged according to the standard TeX Directory Structure (TDS). If this is the case, you can simply unpack it at the top level of your chosen tree.

You can check by inspecting your archive (with unzip -l yourfile.zip, for example). If it has subdirectories such as fonts/ and tex/, it’s most likely arranged according to the TDS.

If you’re getting a flat list of font files without any directories, then you have to move the files yourself into the appropriate subdirectory. Please read the TeX FAQ entry and TDS document (html, pdf).

Warning: some unzip programs take it upon themselves to create their own top-level directory, usually named after the zip file. You must avoid these programs. The plain unzip program, version 5.52 or thereabouts, which is the usual unzip on MacOSX and other Unix-like systems, works fine; you can run unzip --version to check what you’ve got. The UnZip home page lists working unzip binaries for many systems.

3. The TeX filename database

After getting your new files into their proper location (see previous sections), you must update the so-called “TeX filename database”.

  • MiKTeX

Navigate through the MiKTeX program: Start > Programs > MiKTeX > Maintenance > Settings > General > Refresh FNDB (In older versions of MiKTeX, it may be under a menu called MiKTeX Options instead of Maintenance.) There may also be a Maintenance(Admin) entry if you have administrative privileges; if so, that is usually the better choice. Or, if you prefer a DOS command line: initexmf --update-fndb.

  • MacTeX

Run the command sudo -H mktexlsr. (The -H sets HOME for the sudo environment.)

  • TeX Live

Run the command mktexlsr (the command texhash is a synonym). On Unix-like systems, run sudo -H mktexlsr if you installed your system as root (not recommended).

4. Font map files: telling TeX about the new font

After recording the new files (see the previous sections), the last (and most complicated) step is to update various so-called “map” files with the information about your new font.

The commands below assume your new font comes with a map file. If you have no map file, then it has to be created, and that is not an easy job. See the references at the end.

The commands below use newfont.map for the name of this map file. There are no standard conventions for the name, so it can’t be guessed; check your original archive for the name used.

  • MiKTeX

First, edit the map configuration file updmap.cfg as follows. In a DOS/Command Prompt window, run: initexmf --edit-config-file updmap You’ll want to edit this in a text editor such as Notepad.Second, add this one line to updmap.cfg and save it: Map *newfont.map*Third, back at the DOS prompt, run: initexmf --mkmaps (Ignore any error messages.)

  • TeX Live and MacTeX

Run the command: updmap-sys --force --enable Map=*newfont.map*On MacOSX, this is typically done as system administrator, so: sudo -H updmap-sys ...Again, this page is about installing fonts in a system-wide directory. If you need or want to use a personal directory such asTEXMFHOME, please see the separate page about installing fonts in a personal directory.

After doing this, you should remake the filename database again, as explained above; this is not always necessary, depending on your setup, but should never hurt.

5. Testing and debugging

Once all the above seems to have gone ok, to test if the new font is properly recognized, you can use the standard testfont.tex file, like this (prompts also shown):

$ tex testfont  # or pdftex testfont
...
Name of the font to test = tfmname
...
*\table
*\bye

It is imperative to enter the exact name of a .tfm file that was installed, not a system font name or a PostScript font name or anything else. The only thing TeX will recognize is the .tfm filename. Furthermore, leave off the .tfm extension.

The result of the above run should be a DVI or PDF file, according to whichever tex you invoked, showing the characters in that TFM.

If there are problems, typically dvips or pdftex will try to make bitmaps from the font, perhaps with “missing font” messages. If you get that frustrating result:

  • First, try updating the filename databases and redoing the test.
  • If that doesn’t help, try running (from the command line) kpsewhich *newfont.map*, where newfont.map is the map file you added to the system. It should return the location of the map file; if it doesn’t, somehow it is not visible to TeX. System-level permissions? Remake the filename database?
  • If still no joy, it may be time to turn to the general TeX help resources. Search around for people talking about (La)TeX and your specific font; any given font often has unique issues not addressed here.

Good luck. If you have technical questions or problems with installing fonts, please try writing texhax@tug.org. For corrections to this web page, contact the TUG webmaster (link below).

Latex之安装宏包

<https://www.xuebuyuan.com/1673310.html>

宏包就是Latex发行版(TexLive、MikTex等)的插件功能,通过安装不同的宏包可以获得更多的功能。一般情况下,Latex的发行版都自带了一些宏包(多是CTAN中的),以便于使用者快速的编译。这些宏包默认安装在texmf/tex/latex/下,这里texmf是“Tex and MetaFont”的缩写,指代Latex发行版的目录树。以Windows 7 下MikTex2.9为例,texmf=“D:\Program Files\MiKTeX 2.9\”。宏包的功能可以通过CTAN的搜索功能查询到。

​ 一个宏包往往包含一个文件或多个文件,这些文件利用Tex命令定义了新的命令,用来改变Latex默认的功能。这些文件主要有两种类型:clas文件,以.cls为后缀;类型文件,以.sty为后缀。其它类型的文件多是辅助文件。当编译一篇tex文档时,如果引用某个缺失的宏包时,编译程序会报package missing的错误。当然,这些宏包是可以更新的。一个Latex发行版理论上可以安装任意多的宏包,但是,一篇文档可以使用的宏包数目是受限制的。

​ 虽然Latex发行版自带的宏包已经很多,并且自带的Package Manager也能自动从CTAN上下载和安装宏包。但是,宏包的数量远比CTAN拥有的为多。所以,下面介绍下安装宏包的三种方式:

1. 傻瓜式安装

​ 第一种方式比较简单,就是下载.cls或者.sty格式的文件,直接放在编译的目录下与主文件一起运行。这种方式简单易行,但是每次使用都要复制过去,更新也不易,如果使用几十个宏包,会使得编译目录里文件过多。只适合要使用期刊模板的情况。

2. 自动安装

​ 目前,多数的Latex发行版都带有宏包管理器,如TexLive的tlmgr,MikTex的Package Manager。对于TexLive,可以使用如下命令自动安装:

tlmgr install <package1> <package2> ...
tlmgr remove <package1> <package2> ...

对于MikTex,使用 Start -> All Programs -> MikTex -> Settings(admin),记得使用管理员模式来更改。

3. 手动安装

​ 手动安装相对前两种方式要稍微复杂些。如果你下载的宏包里包含sty等格式的必需文件,说明宏包已经经过编译了,可以直接跳到第三步;如果没有,对于较复杂的包,一般包含五个步骤:

(a)提取文件:在下载的宏包里找到后缀名为.ins格式的文件,然后运行“latex yourfilename.ins”命令或者用Latex发行版打开ins文件进行编译。此步骤可以从dtx格式的文件中提取制定的内容并生成需要的文件。

(b)创建文档:接着利用dtx文件创建说明文档,运行命令“latex yourfilename.dtx”。此步骤可以创建一个dvi格式的说明文档,以说明该宏包的功能。

(c)安装文件:此步是最关键的一步,也是容易出错的一步。此步骤的作用是将生成的必需文件,如cls文件和sty文件放到合适的本地位置,以便Latex发行版能够找到。关键是如何定义合适的本地位置呢?在Tex及其衍生物中,所谓合适的本地位置,就是以TDS(Tex Directory Structure)规则组织的文件夹及其子文件夹,也就是一个自定义的目录。一般情况,这个自定义的目录最上层的名字为texmf-local或者texmf。在不同的发行版本下,具体也不一样:

  • MacTex:Users/username/Library/texmf/.
  • Unix-type Systems:~/texmf.
  • MikTex:任意名字,但是子目录要满足一定的规则,具体规则在这里

TDS定义了不同类型的文件存放的位置不同。比如sty格式文件,一般放在texmf/tex/latex下不同的文件夹下,文件夹的名字即是宏包的名字。下面的表格中给出了文件存放的规则:

Type Directory (under texmf/ or texmf-local/) Description
.afm fonts/afm/foundry/typeface Adobe Font Metrics for Type 1 fonts
.bst bibtex/bst/packagename BibTeX style
.cls tex/latex/base Document class file
.dvi doc package documentation
.enc fonts/enc Font encoding
.fd tex/latex/mfnfss Font Definition files for METAFONT fonts
.fd tex/latex/psnfss Font Definition files for PostScript Type 1 fonts
.map fonts/map/ Font mapping files
.mf fonts/source/public/typeface METAFONT outline
.pdf doc package documentation
.pfb fonts/type1/foundry/typeface PostScript Type 1 outline
.sty tex/latex/packagename Style file: the normal package content
.tex doc TeX source for package documentation
.tex tex/plain/packagename Plain TeX macro files
.tfm fonts/tfm/foundry/typeface TeX Font Metrics for METAFONT and Type 1 fonts
.ttf fonts/truetype/foundry/typeface TrueType font
.vf fonts/vf/foundry/typeface TeX virtual fonts
others tex/latex/packagename other types of file unless instructed otherwise

(d)更新索引:最后更新Latex发行版的索引文件,以便Latex发行版能找到新安装的宏包。不同的发行版使用了不同的索引器:

  • teTeX, TeX Live, fpTeX:texhash.
  • web2c: mktexlsr
  • MacTeX: MacTeX appears to do this for you.
  • MikTeX: initexmf –update-fndb;或者使用GUI,即Start -> All Programs -> MikTex -> Settings(admin)下第一个tab,点击“Refresh FNDB”按钮即可。

(e)更新字体映射图:如果一个宏包还顺带安装了一些字体,还应该更新字体的映射。详细方法参详这里

此外,还有一些老版本的宏包并没有参照TDS格式,因此只能使用前两种方式。

此文参考了Wikibooks Latexstackexchange上的一些讨论。

LaTeX手动安装宏包(package)以及生成帮助文档的整套流程

https://blog.csdn.net/a493823882/article/details/78634537

我使用的是ctex套装,本来已经自带了许多package,但是有时候还是需要使用一些没有预装的宏包,这时就需要自己安装package了。下载package可以从CTAN(Comprehensive TeX Archive Network)下载,网址是https://www.ctan.org/。下载下来的宏包,有的直接包含.sty 文件(.sty文件就是package的最终形式);有的下载下来只包含了.ins, .dtx,以及一个readme文件,这时需要自己编译生成.sty文件,以及生成相应的manual。下面详细介绍生成.sty文件以及帮助文档的步骤。

以下步骤的前提是你已经安装好了ctex,并且MikTex的可执行程序已经加入了系统的环境变量中(PATH),另外我的系统的win 8.1,win 7应该也是一样的。

第一步:下载宏包,解压,不赘述,下载地址https://www.ctan.org/pkg,我下在的一个宏包名称是qrcode,是用来生成二维码的,以这个宏包的编译为例来讲解。

第二步:找到你的解压后安装包地址,在我的电脑上是“E:\LaTeX_package\qrcode”, 然后打开电脑的命令提示符界面,把当前的路径改到这个package所在的文件夹,也就是“E:\LaTeX_package\qrcode”

第三步:生成qrcode.sty,在命令提示符界面输入”latex qrcode.ins”, 经过一段时间编译,qrcode.sty就生成了;然后接着生成帮助文档manual, 在命令提示符界面输入” latex qrcode.dtx”,编译完成以后,会生成一个叫做qrcode.dvi的文件,这个文件也可以用ctex自带的yap程序打开,不过不是很方便,所以最好还是把它转为pdf格式,分为两部,先输入 “dvips qrcode.dvi”,生成qrcode.ps文件,再输入”ps2pdf qrcode.ps”,最终就生成了qrcode.pdf的帮助文档,可以打开查看这个package的基本用法,命令的格式等。最终完成的样子如下

无标题

第四步:生成qrcode.sty文件以后还需要把这个文件放到LaTeX能够识别的路径下,在ctex下,这个路径样子以我的电脑为例,是”D:\Program Files\CTEX\MiKTeX\tex\latex”,你可以在这个路径下建立一个文件夹,譬如qrcode,然后把qrcode.sty放到这里,接着在你的电脑里找到MikTex的settings这个程序,settings有两个,选择后面括号里有admin的那个,打开以后,在general选项卡下有Refresh FNDB按钮,点击,过一会,这个package就会加入MikTex的路径中,然后在你的tex文件中就可以使用这个package了

setimage

利用这个宏包,最后可以生成文本对应的二维码,

代码如下

\documentclass{article} \usepackage{qrcode} \begin{document} This is a qrcode for Google HK. \qrcode{https://www.google.com.hk/} \end{document}

最后生成的二维码如下,其他宏包的安装应该都是类似操作的。