macos 如何在 OSX 上安装 LaTeX .sty 文件?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1390828/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-10-21 06:23:38  来源:igfitidea点击:

How do I install a LaTeX .sty file on OSX?

macoslatex

提问by James A. Rosen

I have a LaTeX project set up:

我设置了一个 LaTeX 项目:

tex/
  - documents/
      - some_file.tex
  - support/
      - todonotes.sty

where some_file.texuses todonotes:

在哪里some_file.tex使用todonotes

\usepackage[colorinlistoftodos,textwidth=0.9\marginparwidth]{todonotes}

But I get "LaTeX Error: File `todonotes.sty' not found" when I try to build the PDF in TextMate. How do I tell LaTex or TextMate about my .sty file?

但是当我尝试在 TextMate 中构建 PDF 时,我收到“LaTeX 错误:找不到文件`todonotes.sty'”。我如何将我的 .sty 文件告诉 LaTex 或 TextMate?

Later

之后

To be specific, I'm using tetexfrom MacPorts, though given the answers so far, I might try another distribution.

具体来说,我使用的tetex是 MacPorts,尽管到目前为止给出了答案,但我可能会尝试另一个发行版。

采纳答案by felix marin

In Mac OS X (Snow Leopard 10.6.7) put your .styfile in

在 Mac OS X (Snow Leopard 10.6.7) 中,将您的.sty文件放入

/usr/local/texlive/2010basic/texmf-dist/tex/latex/base/

Then, run texhashcommand. Don't forget to stay as a root user (like sudo -s)

然后,运行texhash命令。不要忘记保持 root 用户身份(例如sudo -s

回答by Mica

Or you can just put the style file in the same directory as your document instead of in "support." now... if you're on OS X, you should probably be using texlive 2008. If you are using texlive 2008, pop open a terminal and type:

或者,您可以将样式文件放在与文档相同的目录中,而不是放在“support”中。现在...如果您使用的是 OS X,您可能应该使用 texlive 2008。如果您使用的是 texlive 2008,请打开一个终端并输入:

sudo tlmgr install todonotes

replace "todonotes" with the package name you want to install.

用你要安装的包名替换“todonotes”。

回答by Barry Wark

You can put style files in ~/texmf/tex/and standard LaTeX distributions should find them. If you prefer to install them system-wide, you can put them in the corresponding texmf/texfolder within your LaTeX installation (the location of this installation on OS X varies depending on which LaTeX distribution you used).

您可以将样式文件放入~/texmf/tex/,标准 LaTeX 发行版应该可以找到它们。如果您更喜欢在系统范围内安装它们,您可以将它们放在texmf/texLaTeX 安装中的相应文件夹中(此安装在 OS X 上的位置因您使用的 LaTeX 发行版而异)。

You can use tlmgr confat the command line to list all of the distribution configuration information. The TEXMFHOMEvariable gives the path to your texmf tree.

您可以tlmgr conf在命令行中使用来列出所有分发配置信息。该TEXMFHOME变量给出了 texmf 树的路径。

回答by Frakturfreak

As said before just put the custom .styinto ~/texmf/texor in /usr/share/texmf-texlive/tex/but don't forget to run mktexlsror texhashto update the local package database of LaTeX. Otherwise LaTeX won't find it at all, unless it is in the same directory of the processed file.

如前所述,只需将自定义.sty放入~/texmf/tex或放入,/usr/share/texmf-texlive/tex/但不要忘记运行mktexlsrtexhash更新 LaTeX 的本地包数据库。否则 LaTeX 根本找不到它,除非它在已处理文件的同一目录中。

回答by Mark Rushakoff

This page on LaTeX packagessays you'll need to install the .styfile in the LaTeX installation directory (my installation of Ubuntu seems to be /usr/share/texmf-texlive/tex/latex/), or you need to have a copy of the .styfile in eachfile containing LaTeX source -- i.e. in your tex/documentsfolder, at the very least.

LaTeX 包上的这个页面说你需要.sty在 LaTeX 安装目录中安装文件(我的 Ubuntu 安装似乎是/usr/share/texmf-texlive/tex/latex/),或者你需要.sty每个包含 LaTeX 源的文件中都有一个文件的副本——即在你tex/documents文件夹,至少。

回答by D.Deriso

I had this issue using BasicTex 2015 and none of the above solved it, so I wrote up a solution here

我在使用 BasicTex 2015 时遇到了这个问题,但以上都没有解决它,所以我在这里写了一个解决方案

In short: sudo tlmgr install preprintwill fix it and kpsewhich fullpage.stywill confirm the fix

简而言之:sudo tlmgr install preprint将修复它并kpsewhich fullpage.sty确认修复

回答by Bose

I tried this one it is works for me:

我试过这个对我有用:

sudo apt-get install texlive-full.

sudo apt-get install texlive-full.