我正在使用 pdflatex 处理嵌套的 tex 文件(例如:Main.tex+Chapter1.tex+...),由于我的工作文件夹已经很乱了,我想将构建文件放在子目录中。选中 texmaker 中的专用框,因此使用 -output-directory 选项,除了 bibtex 之外,它运行良好。我读过其他主题,尝试了不同的解决方案,但由于嵌套文件而无法正常工作,最后决定编写一个可以在 texmaker 中调用的小型 bash 脚本。
效果很好,bibtex 生成的 bbl 看起来不错,但之后运行 pdflatex 时,似乎根本没有 bbl。我尝试将 bbl 放在构建目录或父目录中,结果同样令人失望。
有人能告诉我 pdflatex 何时以及如何包含该 bbl 文件的内容,以及它可能在哪里查找它?
答案1
所以,感谢 David,它成功了!
对于可能处于相同情况的人,这里是 bash 脚本:
#!/bin/bash
# This is BibMaker.sh, stupid script for stupidier Bibtex.
#
# Set execute permission first.
# To be used to launch bibtex with a build directory for (Pdf)latex. (-output-directory=<builddir>)
# Within TexMaker, call ./BibMaker.sh <builddir> %
if [ -z "$2" ] # 2 mandatory args: 1 build folder, 2 filename
then
echo "Usage: BibMaker.sh <build\ folder> <TeX\ source\ filename> [optional: <unique> xor <chapter> for single or per-chapter bibliography]"
exit 3
fi
if [ -n "$1" ] # test if config file was provided as arg
then
BUILDDIR="$1"
fi
MODE=1
if [ -n "$3" ] # test if 3rd arg: "unique" (default) or "chapter"
then
# if [ "$3" = "unique" -o "$3" = "Unique" ]
# then
# MODE=1
# fi
if [ "$3" = "chapter" -o "$3" = "Chapter" ]
then
MODE=2
fi
BUILDDIR="$1"
fi
EXITSTATUS=0
cd $BUILDDIR
FILES=`ls | grep ".aux"`
if [ "$MODE" -eq 1 ]
then
echo "BibMaker here - mode unique selected."
OUTPUT=`bibtex $2`
EXITSTATUS=$?
echo $OUTPUT
for file in $FILES
do
if [ ! "$2.aux" -ef $file ]
then cp $2.bbl "${file%.*}.bbl"
fi;
done;
fi
if [ "$MODE" -eq 2 ]
then
GLOG="$2.blg"
echo $'\n'"BibMaker here - mode chapter selected." | tee $GLOG
for file in $FILES
do
if [ ! "$2.aux" -ef $file ]
then
echo $'\n '"%%%%%%%%%% bibtex ""${file%.*}"" %%%%%%%%%%%"$' \n' >> $GLOG
OUTPUT=`bibtex "${file%.*}"`
if [ $? -eq 0 ]
then
EXITSTATUS=$?
fi
IFS='_'
echo $OUTPUT | tee -a $GLOG
unset IFS
fi;
done;
fi
cd ..
exit $EXITSTATUS