########################################################################## # SED script for converting SubML (Substitutionary Markup Language) # into LaTeX2e (Leslie Lamport's macro package for TeX). # # Version 0.97 # # Copyright (C) 2001-2003 Tony R. Kuphaldt # Last updated 01/01/2006 # # This program is free software; you can redistribute it and/or modify # it under the terms of the GNU General Public License as published by # the Free Software Foundation; either version 2 of the License, or # (at your option) any later version. # # This program is distributed in the hope that it will be useful, # but WITHOUT ANY WARRANTY; without even the implied warranty of # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the # GNU General Public License for more details. # # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 # USA # ########################################################################## # # Modified 10/27/2005 (DC) - Added # Modified 10/28/2005 (DC) - Added tag # -See Devel/tutorial.* for documentation of these # Modified 01/01/ 2006 (DC) - Added , tags. # -See Devel/tutorial.sml for usage # # Modified 02/04/2006 (DC) - Changed image tags to float images # - tags added between tags, See Devel/tutorial.sml # -Added tags. See Devel/tutorial.sml # Modified 03/04/2006 (DC) - Added tag to image processing # Modified 02/05/2006 (DC) - Added nonfloating image tags # Modified 02/06/2006 (DC) - Added more Mathmatical tags after angle. # Modified 02/24/2006 (DC) - Added boolean overbar # Modified 03/05/2006 (DC) - Expanded capability of tags # Modified 03/07/2006 (DC) - Added , tags # # ########################################################################## # ########################################################################## # # Modified (DC) 01/01/2006 - added minitoc - minitable of contents # after the chapter title. Adds \\minitoc command to latex output. # This is subsittuted on the end of sml. Also, see # tag where \\usepackage{minitoc} was added # The minitoc package looks for \\minitoc in the latex # and puts a mini-table of contents there. # \\dominitoc was edited into hi.latex # Those commands must be there. Google on minitoc latex for documentation. # # ########################################################################## # Modified 02/22/2006 (DC) - Added tag for non-breaking lintings. # ########################################################################## ########################################################################## # # Deletes all blank lines. This merely reduces the size of the translated # file and hopefully speeds things up, nothing more. # /^$/d ########################################################################## ########################################################################## # Prevents the \ (backslash) symbol from being interpreted as a regular # TeX escape character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING \ # CHARACTERS INTO THE OUTPUT FILE. # s/\\/\$\\backslash$/g ########################################################################## ########################################################################## # Prevents the $ (dollar-sign) symbol from being interpreted as a TeX # math escape character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING $ # CHARACTERS INTO THE OUTPUT FILE. # s/\$/\\$/g ########################################################################## ########################################################################## # Prevents either the { or } characters from being interpreted as # wrappers in TeX. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING { OR } # CHARACTERS INTO THE OUTPUT FILE. # s/{/$\\{$/g s/}/$\\}$/g ########################################################################## ########################################################################## # Prevents the ~ (tilde) symbol from being interpreted as a TeX # unbreakable space character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING ~ # CHARACTERS INTO THE OUTPUT FILE. # s/~/\\~{}/g ########################################################################## ########################################################################## # Prevents the ^ (caret) symbol from being interpreted as a TeX # math superscript character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING ^ # CHARACTERS INTO THE OUTPUT FILE. # s/\^/\\^{}/g ########################################################################## ########################################################################## # Prevents the _ (underscore) symbol from being interpreted as a TeX # math subscript character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING _ # CHARACTERS INTO THE OUTPUT FILE. # s/_/\\_{}/g ########################################################################## ########################################################################## # Prevents the % symbol from being interpreted as a TeX comment character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING % # CHARACTERS INTO THE OUTPUT FILE. # s/%/\\%/g ########################################################################## ########################################################################## # Prevents the & symbol from being interpreted as a TeX alignment # character. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING & # CHARACTERS INTO THE OUTPUT FILE. # s/&/\\&/g ########################################################################## ########################################################################## # Prevents the # symbol from being interpreted as a TeX replacement # symbol. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING # # CHARACTERS INTO THE OUTPUT FILE. # s/#/\\#/g ########################################################################## ########################################################################## # Prevents the | symbol from being interpreted as a TeX "long dash" # symbol. # # THIS SUBSTITUTION MUST PRECEDE ALL OTHER SUBSTITUTIONS INSERTING | # CHARACTERS INTO THE OUTPUT FILE. # s/|/$|$/g ########################################################################## ########################################################################### # These next search-and-replace commands are hacks. Their purpose is to # "fix" all the special markups that are supposed to have certain # "forbidden" TeX characters in them, like the backslash, and certain # foreign character markup codes. # First, the backslash fix: ss you can see, we first replaced all \ # characters with $\backslash$ , then we replaced all $ characters with # \$. This presents a problem for us, in that any fixed backslashes # ($\backslash$) will now look like this: \$\backslash\$ and no longer # work right in TeX. This search-and-replace looks for any # mangled backslashes (\$\backslash\$) and straightens them up again to # look like they should: $\backslash$ # s/\\\$\\backslash\\\$/\$\\backslash\$/g # # Next, fixing any foreign character markups that got mangled by global # search-and-replace operations on characters such as the tilde (~) and # caret (^). # # Fixing characters with a caret: s///g s///g s///g s///g s///g s///g s///g s///g s///g s///g # # Fixing characters with a tilde: s///g s///g s///g s///g s///g s///g # # Now that these have been fixed, later search-and-replace commands # in this script will see the character markups as they were originally # typed by the author, and render them accordingly. # ########################################################################## ########################################################################## # tags: for marking sections of text NOT to be processed # s//% /g s/<\/comment>//g ########################################################################## ########################################################################## # tags: maker for text to insert into .tex, .latex files # Both tags must have their own line, nothing else # deleted from .txt, .html, .groff s/// s/<\/tex>// ########################################################################## ########################################################################## # tags: maker for text to insert into .html file only # Both tags must have their own line, nothing else # deleted from .txt, .tex, .latex, .groff /.*<\/htmlo>/d //,/<\/htmlo>/d ########################################################################## ########################################################################## # /\\documentclass{book} \ \\usepackage{makeidx} \ \\usepackage[dvips]{graphicx} \ \\usepackage{minitoc} \ \\makeindex \ \\usepackage[ \ pdftitle = "{Lessons In Electric Circuits, Volume II -- AC}", \ pdfauthor = "{Tony R. Kuphaldt}", \ dvips = true, \ ps2pdf = true, \ bookmarks = true, \ colorlinks = true, \ hyperindex = true \ ]{hyperref} \ \\begin{document} \ /g # s/<\/book>/\\printindex \ \\end{document} \ \\end{report} \ /g ########################################################################## ########################################################################## # and tags: mark the beginning and end of a # chapter, and mark the title of a chapter, respectively. # modified (DC) 01-01 2006 - Added \\minitoc after chaptertitle # s///g s/<\/chapter>//g s//\\chapter{/g s/<\/chaptertitle>/} \ \\minitoc \ /g ########################################################################## ########################################################################## #
and tags: mark the beginning and end of a # section, and mark the title of a section, respectively. # s/
//g s/<\/section>//g s//\\section{/g s/<\/sectiontitle>/}/g ########################################################################## ########################################################################## # and tags: mark the beginning and end of a # subsection, and mark the title of a subsection, respectively. # s///g s/<\/subsection>//g s//\\subsection{/g s/<\/subsectiontitle>/}/g ########################################################################## ########################################################################## # and tags: mark the beginning and # end of a subsubsection, and mark the title of a subsubsection, # respectively. # s///g s/<\/subsubsection>//g s//\\subsubsection{/g s/<\/subsubsectiontitle>/}/g ########################################################################## ########################################################################## # extended tags #experimental #\href{URL}{TEXT} #http:www.whatever.com[text] #\href{http://www.whatever.com}{\tt{text}} s+\(\)\(.*\)\(\[\)\(.*\)\(\]\)\(\)+\\href{\2}{\\tt{\4}}+g ########################################################################## # tags: mark a phrase as an Internet URL (Uniform Resource Locator). # (Original) will still catch anything without [text] # s//{\\tt (/g s/<\/url>/)}/g ########################################################################## # ######################################################################### # tags jump to local link, to hypertarget #experimental #\hyperlink{HYPERLINK}{TEXT} #http:www.whatever.com[text] #\hyperlink{http://www.whatever.com}{\tt{text}} s+\(\)\(.*\)\(\[\)\(.*\)\(\]\)\(\)+ \ \\hyperlink{\2}{\4}+g ########################################################################## ######################################################################### # tags-- sets a target for #experimental #\hypertarget{TARGET}{TEXT} #UniqueTarget[text] #\hypertarget{http://www.whatever.com}{\tt{text}} s+\(\)\(.*\)\(\[\)\(.*\)\(\]\)\(\)+ \ \\hypertarget{\2}{\4}+g ########################################################################## ########################################################################## # tags: mark the beginning and end of the LaTex # bibliography section. tags mark the bibliography entries. # tags mark the citation link to the bibliography. # s//\\begin{thebibliography}{99}/g s/<\/thebibliography>/\\end{thebibliography}/g s+\(\)\(\[\)\(.*\)\(\]\)\(.*$\)+\\bibitem\{\3\}\5+g s+++g s//\\cite{/g s/<\/cite>/}/g ########################################################################## ########################################################################## # tags: group a section of lines together to form a paragraph. # # A linefeed is inserted in place of either the or tag # so that they may be placed in the same line with the paragraph they # mark and still result in a blank line between paragraphs in the TeX # source file. # s// \ /g s/<\/para>/ \ /g ########################################################################## ########################################################################## # tags: mark a filename to be included as a graphic image in # the final document. HTML-compatible filenames are not modified, but # if converting to TeX or LaTeX output, any three-character filename # extension is replaced with ".eps" # #s/.[a-z][a-z][a-z]<\/image>/.eps}/g # 02/04/2006 (DC) changed above to below ####//s/\.[a-z][a-z][a-z]/.eps}/g 02/10/2006 to below fix caption //s/\.png/.eps}/g //s/\.jpg/.eps}/g ########################################################################## ########################################################################## #scale image #Add image parameters like scale-- anything between optional grackets [ ] #example: [scale=0.5] scales the image in latex. Must use
# s+\(\)\(\[.*\]\)\(.*\.eps}\)\(\)\(\)\(.*$\)+ \ \\begin{figure}[h, t, b, p, !] \ \\centering \ \\includegraphics\2{\3 \ \\caption{\\sl \5 } \ \\label{\8 \ \\end{figure} \ +g ########################################################################## # tags, if auto-labeling is not acceptable. # 12345.png # s+\(\)\(.*\.eps}\)\(\)\(\)\(.*$\)+ \ \\begin{figure}[h, t, b, p, !] \ \\centering \ \\includegraphics{\2 \ \\caption{\\sl \4 } \ \\label{\7 \ \\end{figure} \ +g # most captioned inages will be processed by next section. ########################################################################## # This will caption and float an image if a caption is found # 12345.png # # Auto lebeling-- uses image name as label #centering for images s+\(\)\(.*\.eps}\)\(\)\(.*$\)+ \ \\begin{figure}[h, t, b, p, !] \ \\centering \ \\includegraphics{\2 \ \\caption{\\sl \4 } \ \\label{\2 \ \\end{figure}\ +g # Take care of equation image w/o caption, no centering # was 2nd line below to float\\begin{figure}[h, t, b, p, !] \ # Don't want equation to float s+\(\)\(1.*\.eps}\)\(.*\)+ \ \\includegraphics{\2+g # Take care of art image w/o caption because- # -equation image is already substitiuted s// \ \\begin{figure}[h, t, b, p, !] \ \\centering \ \\includegraphics{/g # This terminates art images with and w/o \)\(.*$\) ########################################################################## # 02/05/2006 (D) Added reference tags for latex. # Only handles one reference per line (paragraph) //s/\.[jp][pn][g]/.eps/g s+\(\)\(.*\.eps\)\(.*\)\(\)+~\\ref{\2}+g ########################################################################## ########################################################################## # 02/04/2006 (DC) Added caption for figures in latex. For examples of #usage see Devel/tutorial. #######not needed anymore delete s/
My figure\)\(.*\)\(My figure\)\(.*\)\(My figure\)\(.*\)\( tags. s/<\/image>/ \ \\end{figure}/g ########################################################################## ########################################################################## # 02/05/2006 (D) nonfloating image //s/\.[jp][pn][g]/.eps}/g s//\\includegraphics{/g s/<\/imagenf>//g ########################################################################## ###sample s+\(\)\(.*\.eps}\)\(.*/\\caption{/g s/<\/caption>/}/g ########################################################################## ########################################################################## # 02/07/2006 (DC) Added nonbreaking table in latex. See Devel/tutorial.sml s//\\begin{table} [h, t, b, p, !]/g # This terminates nonbreaking table. s/<\/table>/\\end{table}/g ########################################################################## ########################################################################## # tags: mark a block of text to be indented as a quotation. # s//\\begin{quotation}/g s/<\/quotation>/\\end{quotation}/g ########################################################################## ########################################################################## # tags: frame a character string marked for inclusion into a # concept index. # # *** PENDING *** # s//\\index{/g s/<\/index>/}/g ########################################################################## ########################################################################## # tags: group a section of items to be included into a bulleted # list. # s//\\begin{itemize}/g s/<\/itemize>/\\end{itemize}/g ########################################################################## ########################################################################## # tags: marks a line of text to become an item in an itemized list. # s//\\item /g s/<\/item>//g ########################################################################## ########################################################################## # These tags mark a character, word, or phrase to be emphasized in a # particular fashion. # s//\\textit{/g s/<\/italic>/}/g # # s//\\textbf{/g s/<\/bold>/}/g # # s//\\underbar{/g s/<\/underline>/}/g # # s//$_{/g s/<\/subscript>/}$/g # # s//$^{/g s/<\/superscript>/}$/g # # #added 10/27/2005 (DC) to do more elaborate sub/super script s//_{/g s/<\/subscript2>/}/g # # #added 10/27/2005 (DC) s//^{/g s/<\/superscript2>/}/g # # #added 10/27/2005 (DC) s//$/g s/<\/math>/$/g # #added 02/24/2006 (DC) overbar s//\\overline{/g s/<\/ob>/}/g # # ##s/<\/literal>/\\endgroup /g s//\\texttt{/g s/<\/typewriter>/}/g ########################################################################## ########################################################################## # tags: mark a block of text to be presented verbatim, in # a fixed-width font. # s//\\begingroup \\vskip\\parskip \\everypar={\\nobreak} \\obeyspaces \\frenchspacing \\tt \\obeylines \\parskip=0pt \\parindent=0pt /g s/<\/literal>/\\endgroup /g ########################################################################## ########################################################################## # tag: produces a rendition of the TeX logo. # tag: produces a rendition of the LaTeX logo. # s//\\TeX{}/g s//\\LaTeX{}/g ########################################################################## ########################################################################## # tag: places a large vertical space in the document. # s//\\bigskip /g ########################################################################## ########################################################################## # tag: Starts a new page # s//\\vfil \\eject /g ########################################################################## ########################################################################## # tag: Creates the copyright symbol. # s//\\copyright{}/g ########################################################################## ########################################################################## #added 10/28/2005 (DC) # tag: inserts space, may be repeated. # s//\~/g ########################################################################## ########################################################################## # Mathematical tags s//\\angle{}/g # s//\$\\int{}\$/g # s//\$\\partial{}\$/g # s//\$\\infty{}\$/g # s//$\\bigtriangledown$/g # s//$\\oplus$/g # s//$\\approx$/g # s//$\\cong$/g # s//$\\neq$/g # s//$\\pm$/g # s//$\\cdot$/g # s//$\\leq$/g # s//$\\geq$/g # s//$\\times$/g # s//\\textcircled { \\tiny R }/g # ########################################################################## ########################################################################## # Special dashes # s//\$-\$/g # s//\$-\$\$-\$/g ########################################################################## ########################################################################## # Greek letter tags # s//\$\\alpha\$/g # s//\$\\beta\$/g # s//\$\\gamma\$/g s//\$\\Gamma\$/g # s//\$\\delta\$/g s//\$\\Delta\$/g # s//\$\\epsilon\$/g s//\$\\varepsilon\$/g # s//\$\\zeta\$/g # s//\$\\eta\$/g # s//\$\\theta\$/g s//\$\\Theta\$/g s//\$\\vartheta\$/g # s//\$\\iota\$/g # s//\$\\kappa\$/g # s//\$\\lambda\$/g s//\$\\Lambda\$/g # s//\$\\mu\$/g # s//\$\\nu\$/g # s//\$\\xi\$/g s//\$\\Xi\$/g # s//\$\\pi\$/g s//\$\\Pi\$/g # s//\$\\rho\$/g s//\$\\varrho\$/g # s//\$\\sigma\$/g s//\$\\Sigma\$/g s//\$\\varsigma\$/g # s//\$\\tau\$/g # s//\$\\upsilon\$/g s//\$\\Upsilon\$/g # s//\$\\phi\$/g s//\$\\Phi\$/g s//\$\\varphi\$/g # s//\$\\chi\$/g # s//\$\\psi\$/g s//\$\\Psi\$/g # s//\$\\omega\$/g s//\$\\Omega\$/g ########################################################################## ########################################################################## # Other foreign character tags # s//\\`a/g s//\\`A/g # s//\\'a/g s//\\'A/g # s//\\^a/g s//\\^A/g # s//\\"a/g s//\\"A/g # s//\\~a/g s//\\~A/g # s//\\aa/g s//\\AA/g # # s//\\c c/g s//\\c C/g # # s//\\`e/g s//\\`E/g # s//\\'e/g s//\\'E/g # s//\\^e/g s//\\^E/g # s//\\"e/g s//\\"E/g # # s//\\`\\i{}/g s//\\`I/g # s//\\'\\i{}/g s//\\'I/g # s//\\^\\i{}/g s//\\^I/g # s//\\"\\i{}/g s//\\"I/g # # s//\\~n/g s//\\~N/g # # s//\\`o/g s//\\`O/g # s//\\'o/g s//\\'O/g # s//\\^o/g s//\\^O/g # s//\\"o/g s//\\"O/g # s//\\~o/g s//\\~O/g # # s//\\`u/g s//\\`U/g # s//\\'u/g s//\\'U/g # s//\\^u/g s//\\^U/g # s//\\"u/g s//\\"U/g # s//?`/g # s//!`/g # ########################################################################## ########################################################################## # and tags: creates < and > symbols, respectively. # # THIS SUBSTITUTION SHOULD FOLLOW ALL OTHER SUBSTITUTIONS, JUST TO BE # PERFECTLY SAFE. # s//$<$/g s//$>$/g ##########################################################################