Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F104946144
mpbuild
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Thu, Mar 13, 14:21
Size
2 KB
Mime Type
text/x-tex
Expires
Sat, Mar 15, 14:21 (1 d, 23 h)
Engine
blob
Format
Raw Data
Handle
24884998
Attached To
R2653 epfl
mpbuild
View Options
function usage {
echo "Usage:"
echo " $0 TARGET file[.tex] [destination]"
echo ""
exit
}
function set_target {
# here goes the backslash madness in sed...
sed -i "/\\\\multipub{.*}/ d" "$TEX_FILE"
sed -i "
/\\\\input{.*multipub}/ a\
\\\\\multipub{$1}
" "$TEX_FILE"
}
if [[ $# -lt 2 ]]; then
usage
fi
# file to compile; add extension if needed
TEX_FILE="$2"
if [ ${TEX_FILE: -4} != ".tex" ] ; then
TEX_FILE="$TEX_FILE.tex"
fi
BASE_FILE=${TEX_FILE%.tex}
TEX_DIR=$(dirname "${TEX_FILE}")
if [ "$TEX_DIR" == "." ] ; then
TEX_DIR="$(pwd)"
fi
# this only applies to HTML output
DEST_DIR="."
if [ ! -z "$3" ] ; then
DEST_DIR="$3"
fi
AUTHOR="$(sed -n 's/\\author{\(.*\)}/\1/p' "$TEX_FILE")"
# this is where the script lives; we derive the location of
# the multipub style file and additional CSS files
SCRIPT_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
TEXMF_DIR="$SCRIPT_DIR/../tex/"
CSS_DIR="$SCRIPT_DIR/../css/"
CSS=""
EPUB_TMP="epub_tmp"
case "$1" in
-h | --help) usage
;;
PRINT|KINDLE) set_target $1
# depending on the TeX distribution, one of the path options will pass
export TEXINPUTS=$TEXINPUTS:.:"$TEXMF_DIR"
latex --include-directory="$TEXMF_DIR" "$TEX_FILE"
dvips "$BASE_FILE.dvi"
if [ $1 == KINDLE ] ; then
ps2pdf "$BASE_FILE.ps" "$BASE_FILE-KINDLE.pdf"
else
ps2pdf "$BASE_FILE.ps"
fi
;;
#
HTML | EPUB) set_target $1
read -p "Rebuild images? [y] " REPLY
if [ -z "$REPLY" ] || [ "$REPLY" == "y" ]; then
cd $SCRIPT_DIR
python pstf.py renderall "$TEX_DIR"
cd -
fi
latexml --includestyles --path="$TEXMF_DIR" --dest="$BASE_FILE.xml" "$TEX_FILE"
if [ -e "$BASE_FILE.css" ] ; then
CSS="--css=$BASE_FILE.css"
fi
;;
#
*) usage
;;
esac
case "$1" in
HTML) latexmlpost --format=xhtml --dest="$DEST_DIR/$BASE_FILE.xhtml" --pmml --splitat=chapter $CSS --css="$CSS_DIR/html.css" "$BASE_FILE.xml"
;;
#
EPUB) mkdir "$EPUB_TMP"
latexmlpost --format=xhtml --dest="$EPUB_TMP/$BASE_FILE.xhtml" --pmml --splitat=chapter $CSS --css="$CSS_DIR/epub.css" "$BASE_FILE.xml"
ebook-convert "$EPUB_TMP/$BASE_FILE.xhtml" "$BASE_FILE.epub" --dont-split-on-page-breaks --toc-threshold=0 --use-auto-toc --no-default-epub-cover --pubdate="$(date)" --authors="$AUTHOR"
#
;;
#
*) ;;
esac
Event Timeline
Log In to Comment