UTF-8格式的latex文档转pdf书签乱码

pdflatex.sh:

#!/bin/sh usage(){ echo "Usage: pdflatex.sh filename" echo "Author: Yao Wu " echo "Version: 0.1.0" echo "Build date: 2010/08/24" echo "Description: A Program convert LaTex document to PDF document for Simplified Chinese user" echo " Non-English user who use latex to convert LaTex document to PDF document may come across this problem: " echo " The bookmark of a PDF document become irregnizable code." echo " " echo " Convert the .out file to a special UNICODE format can fix this problem." echo " Why? Because AcroRead support it." echo " " echo " There is a program which is 'gbk2uni' can to convert GBK to the special UNICODE," echo " and this program use it convert a LaTex Document to PDF document." echo " " echo " If you just want to do something with the bookmark for a PDF document, please use 'utf2uni.sh'." echo " " echo " Make sure you have 'gbk2uni' which needed by this program." } if [ $# -ne 1 ]; then usage exit 1 fi if [ $1 = "-v" ] || [ $1 = "-h" ] || [ $1 = "-help" ] || [ $1 = "--help" ]; then usage exit 0 fi File=$1.tex OutFile=${1}.out gbk2uni > /dev/null if [ $? -eq 127 ]; then echo "Program gbk2uni no found, abort." exit 1 fi if [ ! -f ${File} ]; then echo "Maybe '${1}' contain suffix, remove it and try again." echo "${File} not found, abort." exit 1 fi if [ -z "`file ${File} |grep LaTeX`" ]; then echo "${File} not like LateX document, abort." exit 1 fi if [ -f ${OutFile} ]; then echo "${OutFile} exists, will rename it to '${OutFile}.backup'." mv ${OutFile} ${OutFile}.backup fi if ! pdflatex ${File} > /dev/null; then echo "Generate ${1}.pdf false for the first time." exit 1 fi if [ ! -z "`file ${OutFile} |grep UTF-8`" ]; then iconv -f utf-8 -t gbk -o ${OutFile} ${OutFile} gbk2uni ${OutFile} > /dev/null else gbk2uni ${OutFile} > /dev/null fi if ! pdflatex ${File} > /dev/null; then echo "Generate ${1}.pdf false for the second time." exit 1 fi #echo "Will delete dump file." rm -rf ${1}.out ${1}.log ${1}.out.bak ${1}.toc ${1}.aux echo "Done."

utf2uni.sh:

#!/bin/sh usage(){ echo "Usage: utf2uni.sh filename" echo "Author: Yao Wu " echo "Version: 0.1.0" echo "Build date: 2010/08/23" echo "Description: A bookmark formatter about LaTex document and PDF document for Simplified Chinese user" echo " Non-English user who use latex to convert LaTex document to PDF document may come across this problem: " echo " The bookmark of a PDF document become irregnizable code." echo " " echo " Convert the .out file to a special UNICODE format can fix this problem." echo " Why? Because AcroRead support it." echo " " echo " There is a program which is 'gbk2uni' can to convert gbk to the special UNICODE," echo " and this program is used to convert UTF-8 format to the special UNICODE format." echo " " echo " If your .out's format is GBK, please just use 'gbk2uni'." echo " " echo " Make sure you have 'gbk2uni' which needed by this program." } if [ $# -ne 1 ]; then usage exit 1 fi if [ $1 = "-v" ] || [ $1 = "-h" ] || [ $1 = "-help" ] || [ $1 = "--help" ]; then usage exit 0 fi gbk2uni > /dev/null if [ $? -eq 127 ]; then echo "Program gbk2uni no found, abort." exit 1 fi if [ ! -f $1 ]; then echo "$1 not found, abort." exit 1 fi if [ -z "`file ${1} |grep UTF-8`" ]; then echo "${1} seem not a UTF-8 file, abort." exit 1 fi cp ${1} ${1}.backup iconv -f utf-8 -t gbk -o ${1} ${1} gbk2uni ${1} mv ${1}.backup ${1}.bak echo "Done. The original file is backed up to '${1}.bak'."

你可能感兴趣的:(UTF-8格式的latex文档转pdf书签乱码)