1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252
|
% $Id: tex4ht-auto-script.tex 182 2016-07-03 23:46:51Z karl $
% This file is not used, the scripts are generated by tex4ht-mkht.tex.
% Copyright (C) Kai-Mikael J\"a\"a-Aro
% Released under the LPPL, any version.
% See tex4ht-cpright.tex for license text.
\documentclass{article}
\immediate\openin15=ProTex.sty
\ifeof15
\immediate\write16{The compilation of this file requires
the packages ProTex.sty and AlProTex.sty available at
http://www.cis.ohio-state.edu/\string~gurari/tpf/}
\def\next{\end{document}}\expandafter\next
\fi
\immediate\closein15
\input ProTex.sty
\AlProTex{txt,<<<>>>,list,title,`}
\begin{document}
%%%%%%%%%%%%%%%%%%
\section{Bash Scripts for TeX4ht}
%%%%%%%%%%%%%%%%%%
\begin{itemize}
\item
Author: Kai-Mikael J\"a\"a-Aro \verb+<kai@popwire.com>+
\item Automatically determine the number of times latex needs to be
called.
\item Remove the extension \verb+.txt+ from the names of the script
files created during the compilation.
\end{itemize}
\AtEndDocument{\OutputCode\<xhlatex\>}
\<xhlatex\><<<
tex4htmk "$1" "$2" "$3" "$4" "$5" ",xhtml" "$6"
>>>
\AtEndDocument{\OutputCode\<xhmlatex\>}
\<xhmlatex\><<<
tex4htmk "$1" "$2" "$3 -cunihtf" "$4" "$5" ",xhtml,mathml" "$6"
>>>
\AtEndDocument{\OutputCode\<uxhlatex\>}
\<uxhlatex\><<<
tex4htmk "$1" "$2" "$3 -cunihtf" "$4" "$5" ",xhtml,uni-html4" "$6"
>>>
\AtEndDocument{\OutputCode\<wlatex\>}
\<wlatex\><<<
tex4htmk "$1" "$2" "$3 -csymhtf" "$4" "$5" ",xhtml,word" "$6"
>>>
\AtEndDocument{\OutputCode\<xhlatex\>}
\<xhlatex\><<<
tex4htmk "$1" "$2" "$3" "$4" "$5" ",xhtml" "$6"
>>>
\AtEndDocument{\OutputCode\<xhmlatex\>}
\<xhmlatex\><<<
tex4htmk "$1" "$2" "$3 -cunihtf" "$4" "$5" ",xhtml,mathml" "$6"
>>>
\AtEndDocument{\OutputCode\<uxhlatex\>}
\<uxhlatex\><<<
tex4htmk "$1" "$2" "$3 -cunihtf" "$4" "$5" ",xhtml,uni-html4" "$6"
>>>
\AtEndDocument{\OutputCode\<wlatex\>}
\<wlatex\><<<
tex4htmk "$1" "$2" "$3 -csymhtf" "$4" "$5" ",xhtml,word" "$6"
>>>
\AtEndDocument{\OutputCode\<tex4htmk\>}
\<tex4htmk\><<<
#!/bin/bash
# This script is a make file for tex4ht. It is written in bash
# but should be simple to translate into csh, perl or whatever your platform
# prefers.
# Original author: Kai-Mikael J-Aro <kai@popwire.com>
#
# This code is placed under the LaTeX Project Public License
# (http://www.latex-project.org/lppl.txt).
#
# Motivation:
# The LaTeX file has to be compiled until the dvi file stabilises.
# We check on auxiliary files to determine if a new compilation will change
# anything or if we are done now.
#
# This script takes seven arguments:
# $1 The LaTeX file
# $2 Files to be included by latex
# $3 Options to tex4ht, of which the first must be a font directory
# $4 Options to t4ht
# $5 Options to latex/tex
# $6 Package inclusions to create the desired type of document
# $7 A user-supplied script which will be executed each time around the loop
# $8 A user-supplied test which should have an exit value of 0 if we need to
# compile the file again.
#
# Sometimes, typically due to moving page references in the text, a file will
# never converge, so there is a checkpoint every TEX4HTLIMIT iterations
# (default 10). If TEX4HTBATCH is set the script will just exit the loop,
# otherwise it asks the user whether to continue. If the output is
# deemed not to have converged, the script will return a status of 1,
# otherwise 0.
file=`basename $1 .tex`
includes=$2
tex4htoptions=$3
t4htoptions=$4
latexoptions=$5
doctype=$6
usercommand=$7
usertest=$8
if [[ $TEX4HTLIMIT ]] ; then : ; else TEX4HTLIMIT=10; fi
exitcode=0
counter=1
while [[ true ]]
do
# There are (rare) instances when the process actually does not converge,
# so we give the users a heads up every few times around the loop, so they
# can decide if they hadn't better check what's going on.
# (I prefer this to a fixed cut-out as tex4ht does not have a known upper
# limit on the number of iterations necessary for unknown input.)
if [[ $(($counter % $TEX4HTLIMIT)) == 0 ]]
then
if [[$TEX4HTBATCH ]]
then
exitcode=1
break
fi
read -p "LaTeX has now run $counter times without the output stabilising."$'\n'"Do you still wish to continue (y/n)? " reply
if [[ $reply==n || $reply==no ]]
then
exitcode=1
break
fi
fi
let counter=$counter+1
tex4htmklatex "$file" "$includes" "$latexoptions" "$doctype"
# Do a BibTeX run if necessary.
grep -q bibdata $file.aux && bibtex $file
# Creating an index may also require several iterations.
if [[ -f $file.idx ]]
then
tex $latexoptions "\def\filename{{$file}{idx}{4dx}{ind}} \input idxmake.4ht"
makeindex -o $file.ind $file.4dx
fi
# Both BibTeX and makeindex are fairly quick operations, so I simply redo
# them every time around the loop, even if it may not be strictly necessary.
# If this is a problem, a more sophisticated check of the contents of the
# idx file can be substituted.
# Perform any user commands
eval $usercommand
# Save copies of the files that transmit information about the need to rerun LaTeX
cp ${file}.4tc ${file}-old.4tc
cp ${file}.xref ${file}-old.xref
cp ${file}.aux ${file}-old.aux
# This is the logic here:
# If LaTeX tells us we need to rerun, we do so without further discussion,
# otherwise we check if any of the .4tc, .xref, .aux files is different from
# the previous version.
# Finally we use the user-supplied test to see if there is anything more to do.
# If none of these tests trigger, we're done.
grep -q 'Rerun to get cross-references right' $file.log && continue
diff ${file}.4tc ${file}-old.4tc > /dev/null || continue
diff ${file}.xref ${file}-old.xref > /dev/null || continue
diff ${file}.aux ${file}-old.aux > /dev/null ||continue
if [[ $usertest ]] ; then `$usertest` && continue; fi
break
done
rm ${file}-old.* # Always clean up after yourself...
tex4ht -f/$file -i~/tex4ht.dir/texmf/tex4ht/ht-fonts/$tex4htoptions
t4ht -f/$file $t4htoptions
exit $exitcode
>>>
\AtEndDocument{\OutputCode\<tex4htmklatex\>}
\<tex4htmklatex\><<<
latex $2 '\makeatletter\def\HCode{\futurelet\HCode\HChar}\def\HChar{\ifx"\HCode\def\HCode"##1"{\Link##1}\expandafter\HCode\else\expandafter\Link\fi}\def\Link#1.a.b.c.{\g@addto@macro\@documentclasshook{\RequirePackage[#1'$3']{tex4ht}}\let\HCode\documentstyle\def\documentstyle{\let\documentstyle\HCode\expandafter\def\csname tex4ht\endcsname{#1'$3'}\def\HCode####1{\documentstyle[tex4ht,}\@ifnextchar[{\HCode}{\documentstyle[tex4ht]}}}\makeatother\HCode '$4'.a.b.c.\input ' $1
>>>
A test file (watch the changes in the .xref file):
\begin{verbatim}
\documentclass{article}
\begin{document}
\begin{tabular}{llllllllll}
\multicolumn{9}{c}{xx}&10\\
1&2&3&4&4&6&7&8&9&10
\end{tabular}
\end{document}
\end{verbatim}
\end{document}
|