A shell script for ordinary LaTeX compilation

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
时间: 2024-08-02 03:49:17

A shell script for ordinary LaTeX compilation的相关文章

Shell Script 学习 I

Shell Script I Shell有两种执行命令的方式: 交互式(Interactive):解释执行用户的命令,用户输入一条命令,Shell就解释执行一条. 批处理(Batch):用户事先写一个Shell脚本(Script),其中有很多条命令,让Shell一次把这些命令执行完,而不必一条一条地敲命令 Unix/Linux上常见的Shell脚本解释器有bash.sh.csh.ksh等,习惯上把它们称作一种Shell ,bash是Linux标准默认的shell, sh 是Unix 标准默认的s

Why to Write Shell Script

Why to Write Shell Script ? Shell script can take input from user, file and output them on screen. Useful to create our own commands. Save lots of time. To automate some task of day today life. System Administration part can be also automated.

学习shell script

如果你的想要管理好你的主机,那么就要好好学习自动管理系统的有效工具--hell script!基本上,shell script有点像早期的批处理文件,即将很多命令整合起来一次执行,但是shell script拥有更强大的功能,它可以进行类似程序的编写,并且不需要经过编译就能够执行,非常方便我们对系统进行管理. 今天我们主要通过对一些shell script的习题来加深对脚本知识的学习. 习题1:对成绩进行判断,要求输入一个正整数,以60分,85分为界输出不同的评语. #!/bin/bash #

shell编程 Shell script 的默认变量($0, $1...)

Shell script 的默认变量($0, $1...) 我们知道指令可以带有选项与参数,例如 ls -la 可以察看包含隐藏文件的所有属性与权限.那么 shell script 能不能在脚本文件名后面带有参数呢?很有趣喔!举例来说,如果你想要重新启动系统登录文件的功能,可以这样做: [[email protected] ~]# file /etc/init.d/syslog /etc/init.d/syslog: Bourne-Again shell script text executab

Scheduled Job Running Shell Script Fails With ORA-27369

Scheduled Job Running Shell Script FailsWith ORA-27369 Applies to: Oracle Server - Enterprise Edition -Version: 10.1.0.2 to 10.2.0.4 Oracle Server - Standard Edition -Version: 10.1.0.2 to 10.2.0.4 including Version:11.2.0.4 Sun Solaris SPARC (64-bit)

執行shell script與subshell

兩種方法 喚起新shell再執行shell scripts 在目前shell執行shell scripts 喚起另一個shell來執行的scripts在scripts檔頭最前面前要加 #! /bin/sh 第一種方法是在shell script 文字檔前指出shell scripts解讀的程式在那(也就是 我們的shell)然後把文字檔的執行權限打開,照一般執行可執行檔方式執行或者叫 一個shell來解釋文字檔test.sh. $ test.sh $ /bin/sh test.sh $ ( .

linux shell script: Basic concept01 - String

basic concept01: String本文所有的测试例如无特殊说明,均based on fish shell 就从字符串说起吧,啥是字符串就不用解释了,我们来看几个简单的例子 ?> ~ set param abc ?> ~ echo "string with blank and $param surrounded with double quotation marks" string with blank and abc surrounded with double

SSH防止暴力破解 shell script

这是我的第一个Shell Script,写的乱乱糟糟,试验了一下,还是可用的,目前已经在我自己的WEB服务器上跑起来了!!~~ #!/bin/bash #这个shell script 用来防止SSH暴力破解 #Auther:Aaron Guo #Date:Jan 8 2016 #Version:1.2 # 指定该SHELL的日志文件 logfile="/var/log/blocked_ip" # 获取现在时间,用来grep /var/log/secure. (格式:mm dd HH)

跟鸟哥学Linux之——shell script

从程序员的角度来看,Shell本身是一种用C语言编写的程序,从用户的角度来看,Shell是用户与Linux操作系统沟通的桥梁.用户既可以输入命令执行,又可以利用 Shell脚本编程,完成更加复杂的操作.在系统管理等领域,Shell编程起着不可忽视的作用.前期我对shell编程做了一个初步的认识,现总结如下: 思维导图: 知识分为了两部分: 基本知识: 在基本知识中我将其分为了:执行方法.运算式.变量和判断式四部分.1.执行方法就是在Linux中shell文件执行的命令,用的多了自然会没有问题.2