Latex设置图片等资源文件和.bib 文件以及输出文件与 .tex文件不在同一目录

环境

\Latex :

xelatex --version
XeTeX 3.14159265-2.6-0.99991 (TeX Live 2014)
bibtex --version
BibTeX 0.99d (TeX Live 2014)

OS:
OS X 10.9.4

目标:

设置图片等资源文件和.bib 文件以及输出文件与 .tex文件不在同一目录

folder
    ├─notes  
    │  ├─sample.tex
    │  ├─sample
    │  │  ├─fig1.jpg
    │  │  └─fig2.jpg
    │  └─output
    │      ├─sample.aux
    │      ├─sample.bbl
    │      ├─sample.blg
    │      ├─sample.log
    │      ├─sample.out
    │      ├─sample.pdf
    │      ├─sample.synctex.gz
    │      └─sample.toc
    └─pdfs
        ├─refarticle.pdf
        └─refarticle.bib
引入图片等资源文件:

如何在编译 .tex 文件的时候找到图片等资源文件,只需要在引入图片的时候指定路径就可以了。如:

\begin{figure}
   \centering
   \includegraphics[scale=0.6]{sample/fig1.jpg}
   \caption{宋赵爽在《周髀算经》注中作的弦图(仿制),该图给出了勾股定理的一个极具对称美的证明。}
   \label{fig:xiantu}
\end{figure}
引用文件 .bib:

对于 .bib 文件可以在\bibliography{path_to_bib_file/bibfile}[1][3],当然如果每个都这样加就比较麻烦,另外一种方式对于 TeXLive 是设置环境变量 BIBINPUTS1 ,如:BIBINPUTS=.:/path-to-bibfile。而 MiKTex 是 bibtex -include-directory=sty -include-directory=bib document.tex[2][4]

输出目录:

使用 xelatex 的 -output-direcotry 选项设置

xelatex -output-directory=output sample.tex
bibtex 找不到 .aux 文件的错误
bibtex: Not writing to <project-path>/src.blg (openout_any = p). 
I couldn't open file name <project-path>/src.blg

修改 texmf.cnf 文件进行解决[5][6],将 openout_any = p 改为 openout_any = a

我的 OS X 10.9.2 位置是

/usr/local/texlive/2014/texmf-dist/web2c/texmf.cnf
/usr/local/texlive/2014/texmf.cnf

经测试,下面那个优先级比较高,需要修改下面那个,这里改为 a

texmf.cnf 里也有说明:

 % Allow Tex \openin, \openout, or \input on filenames starting with `.'
 % (e.g., .rhosts) or outside the current tree (e.g., /etc/passwd)?
 % a (any)        : any file can be opened.
 % r (restricted) : disallow opening "dotfiles".
 % p (paranoid)   : as `r' and disallow going to parent directories, and
 %                  restrict absolute paths to be under $TEXMFOUTPUT.

参考资料:
[1] http://tex.stackexchange.com/questions/120427/where-should-i-put-the-bib-file-to-use-it-directly-in-bibliographybibfile
[2] https://www.tug.org/pipermail/tex-live/2010-May/025698.html
[3] http://tex.stackexchange.com/questions/192917/include-all-bib-files-in-one-directory-to-a-bibliography
[4] http://tex.stackexchange.com/questions/120402/undefined-control-sequence-while-using-bib-file-for-references/120426#120426
[5] http://jansoehlke.com/2012/09/bibtex-going-openout_any-p/
[6] http://tex.stackexchange.com/questions/12686/how-do-i-run-bibtex-after-using-the-output-directory-flag-with-pdflatex-when-f


  1. Windows下未测试
  • 1
    点赞
  • 2
    收藏
    觉得还不错? 一键收藏
  • 2
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值