码迷,mamicode.com
首页 > 系统相关 > 详细

A shell script for ordinary LaTeX compilation

时间:2015-12-07 15:41:30      阅读:147      评论:0      收藏:0      [点我收藏+]

标签:

When using biber I usually follow the order of pdflatex → biber → pdflatex → pdflatex, which is not an available option of many IDEs.

#! /bin/bash
# 
# Author: Luglio
# Date: 07/12/2015
# Version: 0.1.1
# 
# Prerequisites
# LaTeX suite with biber, sam2p
# Settings
#   MODE:   latex, pdf, xe 
#   BIB:    no - no biber/biblatex
#           yes - use biber (will run tex for times)
#   PIC:    no - no picture converted to .eps file
#           yes - run sam2p to convert

MODE="pdf"
BIB="no"
PIC="no"

FILENAME=${1%.*}

if [ "$MODE"x = "latex"x ]
then
    mode="LaTeX"
    prog="latex"
elif [ "$MODE"x = "pdf"x ]
then
    mode="pdfLaTeX"
    prog="pdflatex"
elif [ "$MODE"x = "xe"x ]
then
    mode="XeLaTeX"
    prog="xelatex"
else
    mode="UNKNOWN"
    prog="pdflatex"
fi

if [ "$BIB"x = "no"x ]
then
    bib="out"
elif [ "$BIB"x = "yes"x ]
then
    bib=""
else
    bib="out"
fi

if [ "$PIC"x = "no"x ]
then
    pic=" not"
elif [ "$PIC"x = "yes"x ]
then
    pic=""
else
    pic=" not"
fi

echo "This is LaTeX make."
echo "Run in $mode mode, with$bib biber, pictures are$pic to be converted to .eps files."

# sam2p (from apt-get) 
if [ "$pic"x = ""x ]
then
    for format in .jpg .jpeg .bmp .png; do
        for picture in *${format}; do
            sam2p ${picture} ${picture%.*}.eps
        done
    done
fi

# Biber precondition
if [ "$bib"x = ""x ]
then
    eval "${prog} ${FILENAME}.tex"
    biber ${FILENAME}.tex
    eval "${prog} ${FILENAME}.tex"
fi

# Run TeX
eval "${prog} -synctex=-1 ${FILENAME}.tex"

# dvi -> pdf
if [ "$prog"x = "latex"x ]
then
    dvipdfmx ${FILENAME}.dvi
fi

 

A shell script for ordinary LaTeX compilation

标签:

原文地址:http://www.cnblogs.com/luglio/p/5026039.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!