[TxMt] smart Latex typesetting
Alain Matthes
alain.matthes at mac.com
Mon May 29 06:17:19 UTC 2006
Le 18 mai 06 à 18:00, Christoph Biela a écrit :
>
> It would be great if someone could help me or send the website
> where this is already posted.
> However, I would also appreciate some helpful comments on how to
> write the script by myself.
Hello
I'm not sure that my answer is right for your question
because i've some difficulties with english language...
example of personal project:
\documentclass[]{prof}
\begin{document}
\input{part1.tex}
\newline
\input{part2.tex}
\end{document}
With my personal class prof.cls, i have a file prof.clg
with all the calls to packages. If you used another class
and if you need packages, it's possible to modify the script.
If i want to compile only part1.tex, i proceed like this
1) Boulot(/Users/ego/Documents/Boulot) is the folder
for all my works and it's declared in texmf.cnf
that simplifies the paths.
2) In Boulot I created a directory "temp" for temporary files.
3) Then In the Shell variable I created :
TM_DIR_FOR_TEMP : /Users/ego/Documents/Boulot/temp
MY_CLASS : prof
and I used a script with this idea :
creation of temporary file : tempfile
which contains part1.tex
like this :
cat >tempfile.tex<<EOF
\documentclass{$MY_CLASS}
\thispagestyle{empty}
\graphicspath{{$DIRtemp/}}
\begin{document}
\input $M
\end{document}
EOF
$M is part1.tex
\graphicspath{{$DIRtemp/}} : i put the graphics files
always in the same directory of part1.tex
==========================================
I don't use latexmkrc !!! so I modified
only a part of the original script :
Latex & View
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
use this script with precaution
!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
==========================================
==========================================
# Source some support functions we need.
. "${TM_SUPPORT_PATH}/lib/html.sh"
V=${TM_LATEX_VIEWER:=html}
# Set up some variables we need.
TEX=${TM_LATEX_COMPILER:=pdflatex}
EL=${TM_LATEX_ERRLVL:=1}
M=${TM_LATEX_MASTER:=$TM_FILEPATH}
# in M : part1.tex
DIRtemp=`dirname "$M"`
# the directory of part1.tex
DIR="/Users/ego/Documents/Boulot/temp"
FILE="tempfile.tex"
cd ${TM_DIR_FOR_TEMP}
cat >tempfile.tex<<EOF
\documentclass{$MY_CLASS}
\thispagestyle{empty}
\graphicspath{{$DIRtemp/}}
\begin{document}
\input $M
\end{document}
EOF
# Switch to the right directory.
cd "$TM_PROJECT_DIRECTORY"
cd "$DIR"
# Prepare output window.
htmlHeader "Compiling LaTeX (file $FILE)"
echo '<h1>Compiling LaTeX...</h1>'
run_tex () {
if [ "$TEX" != latexmk.pl ]
then "$TEX" ${TM_LATEX_OPTIONS:=-interaction=nonstopmode -file-line-
error-style} tempfile.tex
else "$TEX" -f -r "${TM_BUNDLE_SUPPORT}/latexmkrc" "$1"
fi
}
# Compile.
run_tex "$FILE" 2>&1| latexErrWarnHtml.py -v
RC=$?
if [ "$V" == html ]; then
if [ -s "${PDF}" -a "$PDF" -nt "$FILE" ]; then
WEB_LOC="tm-file://${DIR}/${PDF}"
WEB_LOC="${WEB_LOC//\\#/%23}"
if (($RC > $EL)); then
link "${WEB_LOC}" 'Click Here to Preview'
else
redirect "${WEB_LOC}"
fi
else
strong "Error: PDF file not written to disk"
fi
htmlFooter
else
open -a "$V" tempfile.pdf
if (($RC <= $EL)); then closeWindow; fi
fi
echo "Cleaning..."
# Switch to the right directory.
cd ${TM_DIR_FOR_TEMP}
rm -f tempfile.aux
rm -f tempfile.log
echo "Done Cleaning up"
==========================================
==========================================
Greetings
Alain Matthes
Perhaps there is a better way of also doing this
if you can improve this script, I will be very happyU
More information about the textmate
mailing list