环境:
\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
- Windows下未测试 ↩