summaryrefslogtreecommitdiff
path: root/support/tab4tex
diff options
context:
space:
mode:
Diffstat (limited to 'support/tab4tex')
-rw-r--r--support/tab4tex/README106
-rw-r--r--support/tab4tex/bin/windows/test1.txt6
-rw-r--r--support/tab4tex/bin/windows/test2.txt7
-rw-r--r--support/tab4tex/docs/tab4tex.pdfbin0 -> 349276 bytes
-rw-r--r--support/tab4tex/docs/tab4tex.tex379
-rw-r--r--support/tab4tex/source/compiler.inc22
-rw-r--r--support/tab4tex/source/newline.inc25
-rw-r--r--support/tab4tex/source/systype.inc16
-rw-r--r--support/tab4tex/source/tab4tex.sno96
-rw-r--r--support/tab4tex/test1.pdfbin0 -> 44370 bytes
-rw-r--r--support/tab4tex/test1.tex22
-rw-r--r--support/tab4tex/test1.txt6
-rw-r--r--support/tab4tex/test2.pdfbin0 -> 32458 bytes
-rw-r--r--support/tab4tex/test2.tex22
-rw-r--r--support/tab4tex/test2.txt7
15 files changed, 714 insertions, 0 deletions
diff --git a/support/tab4tex/README b/support/tab4tex/README
new file mode 100644
index 0000000000..7ea2a4a930
--- /dev/null
+++ b/support/tab4tex/README
@@ -0,0 +1,106 @@
+TEX4TAB
+Version 0.1
+08.03.2007 (08.mar.2007)
+
+Transforms a text file with very simple tagging into a LaTeX table.
+Input file must separate cells with tabs
+
+Contents of this package:
+source Snobol source files, bash scripts and bat files for Windows, test files
+bin/windows Executable files for Windows, with test files in Dos-Windows format
+doc Documentation files in LaTeX and PDF formats.
+
+To install and use this package, please read the documentation file.
+
+Simple formatting aid:
+*cell* produces \texmf{cell}
+!cell! produces \emph{cell}
+^cell^ produces \textsc{cell}
+
+Multicolumns support
+Starting a cell with a tag as "<M2>" --> produces multicolumns{2}
+
+Empty cells
+Use <E> and separate with a tab as with normal cells. The LaTex output will be
+an empty cell. Do not use blanks or double tabs: the results will be a wrong
+LaTeX code.
+
+EXAMPLE
+snobol4 -b tab4tex.sno r=7 a=c b=y h=y c=y <tab.txt >tab.tex
+or, if compiled (Dos-Windows):
+tab4tex r=7 a=c b=y h=y c=y <tab.txt >tab.tex
+a align (center,left,right)
+b vertical bar (y/n)
+c complete LaTeX document (y/n)
+h hline (y/n)
+r rows
+
+EXAMPLE OF INPUT FILE
+See files test1.txt and test2.txt
+* test1 is very simple. The output file is obtained running
+ snobol4 -b tab44tex.sno r=5 a=c b=y h=y c=y <test1.txt>test1.tex
+* test2 is taken from an example found at:
+ http://www.maths.tcd.ie/~dwilkins/LaTeXPrimer/Tables.html
+ --> To read this file with a text editor set your tabs at 12 <--
+ Please notice that some additional features, as double separation lines
+ between cols, can be easily added in the final LaTeX file.
+ The output file is obtained running
+ snobol4 -b tab44tex.sno r=5 a=l b=y h=y c=y <test2.txt>test2.tex
+ Notice a=l in this example (alignment = left)
+
+
+EXAMPLE OF OUTPUT FILE
+See files test1.tex and test2.tex
+
+HOW TO GET SNOBOL
+This program is written in Snobol4, a language very poweful for pattern matching
+and text processing.
+
+Windows-Dos:
+For Windows-Dos a compiled version is provided so you do not need the interpreter.
+The program needs at least a 386 and Windows 95 or more.
+If you are interested, or if you run the program with an older system,
+you can get a freeware version of the Snobol4 interpreter from Catspaw, inc.,
+at <http://www.snobol4.com>
+The EXE file provided here is compiled with Spitbol and should run faster than
+the interpreted file with Snobol4. Spitbol is a professional version of Snobol4
+and is sold by Catspaw (it is not freeware).
+
+Linux and Unix(es)
+A freeware version of Snobol4 (due to Phil Budne) can be downloaded from
+<http://www.snobol4.org>
+Compilation is easy. For any problem, Phil is extremely helpful.
+The interpreter is necessary to run the program under Unix(es).
+
+Mac
+Not tested. There is a Mac version of Snobol (see Catspaw) but with OSX Phil's
+Snobol4 may be compiled, I believe.
+
+TODO
+* Escape sequences for '<E>' and for chars used to format text
+* Better support for multicolumns
+* Use of tabularx and longtable
+* Some more formatting aids.
+
+BUGS
+None known.
+
+LICENCE
+Copyright (C) 2007 Guido Milanese guido.milanese@unicatt.it
+under the terms of the GNU General Public License
+
+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.
+
+If you do not have a copy of the GNU General Public License write to the Free
+Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+If the author of this software was too lazy to include the full GPL text along
+with the code, you can find it at: http://www.gnu.org/copyleft/gpl.html
+
diff --git a/support/tab4tex/bin/windows/test1.txt b/support/tab4tex/bin/windows/test1.txt
new file mode 100644
index 0000000000..f6cf17d0ba
--- /dev/null
+++ b/support/tab4tex/bin/windows/test1.txt
@@ -0,0 +1,6 @@
+<M5>*Animals and friends*
+<E> <M2>!Cats! <M2>!Dogs!
+<E> ^John^ ^Martha^ ^John^ ^Martha^
+*Black* 2 5 5 0
+*White* 4 1 0 5
+*Red* 2 1 <M2>Not known
diff --git a/support/tab4tex/bin/windows/test2.txt b/support/tab4tex/bin/windows/test2.txt
new file mode 100644
index 0000000000..ae99fbe37b
--- /dev/null
+++ b/support/tab4tex/bin/windows/test2.txt
@@ -0,0 +1,7 @@
+<E> <M2>Singular <M2>Plural
+<E> English *Gaeilge* *English* *Gaeilge*
+1st Person at me *agam* at us *againn*
+2nd Person at you *agat* at you *agaibh*
+3rd Person at him *aige* at them *acu*
+<E> at her *aici* <E> <E>
+
diff --git a/support/tab4tex/docs/tab4tex.pdf b/support/tab4tex/docs/tab4tex.pdf
new file mode 100644
index 0000000000..e0e92a6174
--- /dev/null
+++ b/support/tab4tex/docs/tab4tex.pdf
Binary files differ
diff --git a/support/tab4tex/docs/tab4tex.tex b/support/tab4tex/docs/tab4tex.tex
new file mode 100644
index 0000000000..82bb983545
--- /dev/null
+++ b/support/tab4tex/docs/tab4tex.tex
@@ -0,0 +1,379 @@
+% Tab4tex documentation
+% Version 0.1
+% March 2007
+% Guido Milanese - guido.milanese@unicatt.it
+
+\documentclass[a4paper,english]{article}
+\usepackage[T1]{fontenc}
+\usepackage[utf8x]{inputenc}
+\IfFileExists{url.sty}{\usepackage{url}}
+ {\newcommand{\url}{\texttt}}
+\usepackage{babel}
+
+\begin{document}
+
+\title{tab4tex\\
+Version 0.1}
+
+
+\author{Guido Milanese\\
+\url{guido.milanese@unicatt.it}}
+
+
+\thispagestyle{empty}
+\date{March 2007}
+\maketitle
+\begin{abstract}
+\noindent{}This utility helps to prepare tables to be used in
+\LaTeX{}.
+The programs are written in Snobol4; the only requirement is to install the
+interpreter. For Windows, a standalone file compiled with Spitbol is also
+provided, and the programs can be run without the need of an external
+interpreter.
+\end{abstract}
+
+\tableofcontents
+
+\section{The program}
+
+The program \textsf{tab4tex} reads from the standard input a text file and
+outputs a table formatted according to the requirements of the environment
+\textsf{tabular}.
+It is possible to output a table that can be pasted or included in a complete
+\LaTeX{} file or to output a complete standalone \LaTeX{} file.
+
+Some basic formatting aids are provided. Refined features can be added later in
+the \LaTeX{} code.
+
+The program must be run as follows:
+
+\begin{center}
+ \texttt{snobol4 -b tab4tex.sno [options] <inputfile >outputfile}
+\end{center}
+
+\noindent{}If compiled or from a script:
+
+\begin{center}
+ \texttt{tab4tex [options] <inputfile >outputfile}
+\end{center}
+
+Options are:
+
+\begin{description}
+ \item[a] align (center,left,right)
+ \item[r] number of rows
+ \item[b] vertical bar (y/n)
+ \item[c] complete \LaTeX{} document (y/n)
+ \item[h] hline (y/n)
+\end{description}
+
+First and second argument are compulsory, 3rd, 4th and 5th optional (simple y/n
+choice). For example use \texttt{c=y} if you want a complete \LaTeX{} document,
+\textsf{c=n} if you want just a table to include in your document.
+
+
+See the next section for some examples.
+
+\section{Examples and formatting aids}
+\subsection{A simple example}
+This is file \textsf{test1} provided in the package:
+
+\begin{center}
+ \begin{verbatim}
+ <M5>*Animals and friends*
+ <E> <M2>!Cats! <M2>!Dogs!
+ <E> ^John^ ^Martha^ ^John^ ^Martha^
+ *Black* 2 5 5 0
+ *White* 4 1 0 5
+ *Red* 2 1 <M2>Not known
+ \end{verbatim}
+\end{center}
+
+
+These lines are very simple:
+
+\begin{verbatim}
+*Black* 2 5 5 0
+*White* 4 1 0 5
+\end{verbatim}
+
+Each line is a row and cells are separated by tabs. Please notice:
+\emph{tabs}, not empty spaces.
+
+The asterisks are used to produce bold text in the \LaTeX{} output. The program
+provides this simple encoding:
+
+\begin{quote}
+ \begin{tabular}{ll}
+ *cell* & produces \textbf{cell}\\
+ !cell! & produces \emph{cell}\\
+ \^{}cell\^{} & produces \textsc{cell}\\
+ \end{tabular}
+\end{quote}
+
+The third line uses \texttt{<E>}, meaning \emph{empty cell}:
+\begin{center}
+ \begin{verbatim}
+ <E> ^John^ ^Martha^ ^John^ ^Martha^
+ \end{verbatim}
+\end{center}
+
+Empty cells must be separated from the following ones as normal cells are, i.e.
+using a tab. Please notice: \emph{tabs}, not empty spaces. In this line, observe
+the use of \texttt{\^{}} to obtain small caps in the \LaTeX{} output.
+
+The second and the last row are using multicolumns, i.e. the text is expanded in
+two ore more cells:
+
+\begin{center}
+ \begin{verbatim}
+ <E> <M2>!Cats! <M2>!Dogs!
+ *Red* 2 1 <M2>Not known
+ \end{verbatim}
+\end{center}
+
+The program uses a simple encoding to obtain a multicols output: precede the
+string with \texttt{<M[number]>}, as in the above example. Multicols cells must
+be separated from the following ones as normal cells are, i.e. using a tab.
+Please notice: \emph{tabs}, not empty spaces. Observe the use of \texttt{!} to
+obtain italics in the \LaTeX{} output.
+
+This is the final output:
+
+\footnotesize%
+\begin{verbatim}
+\begin{tabular}{|c|c|c|c|c|}
+ \hline
+ \multicolumn{5}{|c|}{\textbf{Animals and friends}} \\
+ \hline
+ & \multicolumn{2}{|c|}{\emph{Cats}} & \multicolumn{2}{|c|}{\emph{Dogs}} \\
+ \hline
+ & \textsc{John} & \textsc{Martha} & \textsc{John} & \textsc{Martha} \\
+ \hline
+ \textbf{Black} & 2 & 5 & 5 & 0 \\
+ \hline
+ \textbf{White} & 4 & 1 & 0 & 5 \\
+ \hline
+ \textbf{Red} & 2 & 1 & \multicolumn{2}{|c|}{Not known} \\
+ \hline
+\end{tabular}
+\end{verbatim}
+\normalsize%
+
+This output was obtained with the following command line:
+
+\begin{center}
+ \begin{verbatim}
+ snobol4 -b tab4tex.sno r=5 a=c b=y h=y c=n <test1.txt >test1.tex
+ \end{verbatim}
+\end{center}
+
+The options used are:
+
+\begin{itemize}
+ \item \texttt{r=5} The number of rows.
+ \item \texttt{a=c} Cells are centered
+ \item \texttt{b=y} Vertical bar
+ \item \texttt{h=y} Horizontal bar
+ \item \texttt{c=n} Do not output a standalone \LaTeX{} file
+\end{itemize}
+
+Please notice that only the first two options must be entered. If you answer
+``no'' to any other option, you can simply omit it.
+
+\subsection{A more complex example}
+
+This example is a bit more complex%
+\footnote{The table is quoted from
+\url{http://www.maths.tcd.ie/~dwilkins/latexprimer/tables.html}. To see the real
+file provided in the package set tabs at 12 or similar values and use a fixed
+font.}. This is the input file:
+
+
+\begin{verbatim}
+<E> <M2>Singular <M2>Plural
+<E> English *Gaeilge* *English* *Gaeilge*
+1st Person at me *agam* at us *againn*
+2nd Person at you *agat* at you *agaibh*
+3rd Person at him *aige* at them *acu*
+<E> at her *aici* <E> <E>
+\end{verbatim}
+
+The file combines empty cells and formatting instructions. This is the output:
+
+\footnotesize%
+\begin{verbatim}
+\begin{tabular}{|l|l|l|l|l|}
+ \hline
+ & \multicolumn{2}{|l|}{Singular} & \multicolumn{2}{|l|}{Plural} \\
+ \hline
+ & English & \textbf{Gaeilge} & \textbf{English} & \textbf{Gaeilge} \\
+ \hline
+ 1st Person & at me & \textbf{agam} & at us & \textbf{againn} \\
+ \hline
+ 2nd Person & at you & \textbf{agat} & at you & \textbf{agaibh} \\
+ \hline
+ 3rd Person & at him & \textbf{aige} & at them & \textbf{acu} \\
+ \hline
+ & at her & \textbf{aici} & & \\
+ \hline
+\end{tabular}
+\end{verbatim}
+\normalsize%
+
+The output was obtained with the following command line:
+\begin{center}
+ \begin{verbatim}
+ snobol4 -b tab4tex.sno r=5 a=l b=y h=y c=n <test2.txt >test2.tex
+ \end{verbatim}
+\end{center}
+
+Notice that this time we have used \texttt{a=l} and not \texttt{a=c}, so cells
+will not be centered but left aligned.
+
+
+\section{Installation}
+
+\subsection{GNU/Linux and other {*}nix systems}
+
+\begin{enumerate}
+ \item Install \textsf{snobol4} from \url{http://www.snobol4.org}. This is Philip Budne's
+ CSNOBOL implementation. You need a \texttt{c} compiler to compile the
+ interpreter; it's normally a very quick and easy process.
+\item Make sure \textsf{snobol4} is in your PATH or make a symbolic link.
+\end{enumerate}
+
+You can now run the program as follows:
+\begin{center}
+ \begin{verbatim}
+ snobol4 -b tab4tex.sno [OPTIONS] <input >output
+ \end{verbatim}
+\end{center}
+
+If you prefer to avoid some typing, write the following line as first line of
+the program:
+
+\begin{center}
+ \begin{verbatim}
+ #!/usr/local/bin/snobol4 -b
+ \end{verbatim}
+\end{center}
+
+Adapt accordingly to your installation, e.g.
+
+\begin{center}
+ \begin{verbatim}
+ #!/usr/bin/snobol4 -b
+ \end{verbatim}
+\end{center}
+
+Make the file \textsf{tab4tex.sno} executable, e.g. \texttt{chmod +x tab4tex.sno}
+
+Run the program as follows:
+ \texttt{./tab4tex.sno [options] <input >output}\\
+If the current directory is in your PATH, you do not need \texttt{./}
+before the program name.
+
+\subsection{Windows}
+
+The package offers an executable file compiled with Spitbol (see
+\url{http://www.snobol4.com}), a powerful commercial Windows version of Snobol.
+Make a directory and copy all the file provided in the \textsf{bin/windows}
+directory. There must be one \texttt{exe} file and two \texttt{test{*}} files.
+
+Run the programs as follows:
+
+\begin{center}
+ \texttt{tab4tex [options] <input >output}\\
+\end{center}
+
+
+\subsection{Windows from source}
+
+Basically, follow the same directions given about GNU/Linux, but make sure to
+use the \texttt{bat} files and to install the Windows version of the interpreter.
+Before using the sources, that are in Unix format, use a script to translate
+from Unix to Dos-Windows format. If you do not have such a script, open the
+files with a text editor and save the sources in Windows-Dos format. This can be
+done reading and saving each file with the DOS \textsf{edit} program, with
+\textsf{vim} or any other editor able to deal with different file formats.
+\subsection{Cygwin}
+
+I suggest to follow the same directions given for GNU/Linux, but the
+EXE files provided for native Windows can be used anyway if preferred.
+
+\subsection{Macintosh}
+Not yet tested (I do not have a Mac right now). It's in the TODO list.
+
+\section{Test files}
+Please test the program on \textsf{test1.txt} and \textsf{test2.txt}.
+
+\section{Reference}
+
+\begin{tabular}{ll}
+\multicolumn{2}{l}{OPTIONS} \\
+a & align (center,left,right) \\
+b & vertical bar (y/n) \\
+c & complete LaTeX document (y/n) \\
+h & hline (y/n) \\
+r & rows \\
+\end{tabular}
+
+\noindent{}\begin{tabular}{lll}
+\multicolumn{3}{l}{FORMATTING CODES} \\
+*cell* & produces \textbf{cell} & bold \\
+!cell! & produces \emph{cell} & italics \\
+\^{}cell\^{} & produces \textsc{cell} & small caps \\
+\end{tabular}
+
+\section{Bugs and TODO}
+
+List of features that I would like to add:
+
+\begin{enumerate}
+ \item Escape sequences for \textsf{<E>} and formatting codes
+ (\textsf{!*\^{}}).
+\item Better support for multicol
+\item Use of tabularx and longtab
+\item Some more formatting aids.
+\end{enumerate}
+
+\section{Acknowledgements}
+My warmest thanks to \textsc{Phil Budne} (\url{phil@ultimate.com}) for making
+his excellent CSNOBOL available. Many thanks to the community of Snobol users,
+particularly to the members of the Yahoo Snobol group
+\url{http://tech.groups.yahoo.com/group/snobol}, and,
+among them, to \textsc{Gordon Peterson} (\url{http://personal.terabites.com/}),
+\textsc{Michael Radow} (\url{mikeradow@yahoo.com}), \textsc{Gregory L. White}
+(\url{glwhite@netconnect.com.au}) and to \textsc{Rafal M. Sulejman}
+(\url{rafal@engelsinfo.de}) whose \textsf{vim} syntax files are a daily
+blessing.
+
+
+\section{Author, copyright, license, disclaimer}
+
+This program is Copyright \copyright{} 2007\\
+Guido Milanese <\url{guido.milanese@unicatt.it}>\\
+under the terms of the GNU General Public License.\\
+
+\footnotesize{}
+ \begin{verbatim}
+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.
+
+If you do not have a copy of the GNU General Public License write to the Free
+Software Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
+
+If the author of this software was too lazy to include the full GPL text along
+with the code, you can find it at: http://www.gnu.org/copyleft/gpl.html.
+\end{verbatim}
+\normalsize{}
+
+\end{document}
+
diff --git a/support/tab4tex/source/compiler.inc b/support/tab4tex/source/compiler.inc
new file mode 100644
index 0000000000..15e0027b65
--- /dev/null
+++ b/support/tab4tex/source/compiler.inc
@@ -0,0 +1,22 @@
+* Compiler.inc
+* Gregory White <glwhite@netconnect.com.au>
+* Posted to the Snobol list (March 2003)
+* and adapted as a function
+
+
+ DEFINE('COMPILER()') :(COMPILER_END)
+
+compiler
+
+IDprocessor :($('COMPILER' SIZE(DATE())))
+
+COMPILER17 compiler = 'SPITBOL' :(return)
+
+COMPILER19 compiler = 'CSNOBOL4' :(return)
+
+COMPILER20 compiler = 'SNOBOL4+' :(return)
+
+compiler_end
+
+* Uses the different size of DATE() to detect the compiler used
+
diff --git a/support/tab4tex/source/newline.inc b/support/tab4tex/source/newline.inc
new file mode 100644
index 0000000000..bb47722f64
--- /dev/null
+++ b/support/tab4tex/source/newline.inc
@@ -0,0 +1,25 @@
+* NEWLINE
+* Checks OS and compiler type to set newline
+* Part of this function uses a function posted by
+* Gregory White <glwhite@netconnect.com.au>
+* on the Snobol list in March 2003
+* Guido Milanese <guido.milanese@unicatt.it>
+
+ define('newline()compiler_type')
+-include "compiler.inc"
+-include "systype.inc"
+ :(newline_end)
+
+newline
+* Compiler being used. If it is Snobol4+, that does not have
+* the HOST() function, assumes that the newline is Dos type
+
+snobol4 (compiler_type = compiler()) ? "SNOBOL4+" :f(other)
+ newline = char(13) char(10) :(return)
+
+* otherwise finds through HOST the OS type and sets newline
+* accordingly
+other newline = systype() :(return)
+newline_end
+
+
diff --git a/support/tab4tex/source/systype.inc b/support/tab4tex/source/systype.inc
new file mode 100644
index 0000000000..2a4d7f81ca
--- /dev/null
+++ b/support/tab4tex/source/systype.inc
@@ -0,0 +1,16 @@
+* SYSTYPE
+* Sets new_line value according to OS
+* Guido Milanese <guido.milanese@unicatt.it>
+* March 2003
+
+ DEFINE('SYSTYPE()os') :(SYSTYPE_END)
+SYSTYPE os = replace(host(),&UCASE,&LCASE)
+UNIX os ? ('nix' | 'nux') :f(DOS)
+ systype = char(10) :(return)
+DOS systype = char(13) char(10) :s(return)
+ :(freturn)
+SYSTYPE_END
+
+* 'os' is the string returned by host().
+* The function does not work under snobol4+, requires Spitbol or CSnobol4.
+
diff --git a/support/tab4tex/source/tab4tex.sno b/support/tab4tex/source/tab4tex.sno
new file mode 100644
index 0000000000..81f71ac071
--- /dev/null
+++ b/support/tab4tex/source/tab4tex.sno
@@ -0,0 +1,96 @@
+* TAB4TEX
+* Guido Milanese 2007 <guido.milanese@unicatt.it>
+*
+* Usage: tab2tex.sno rows, align, vertical_bar, hline, complete
+* First and second argument are compulsory, 3rd, 4th and 5th optional (simple y/n choice)
+* Example: snobol4 -b tab4tex.sno r=7 a=c b=y h=y c=y <tab.txt >tab.tex
+* outputs a table planned for 7 rows, centered, with '|' and hline, as a simple complete LaTeX document
+
+* Sets digits, newline and tabulator
+ digits = '1234567890'
+-include "newline.inc"
+ (~(nl = newline()) (terminal = "Cannot set newline. Abort")) :s(end)
+ tab = char(9)
+*****************************************
+* Internal functions
+*
+* -- FORMAT LINES - Changes '*' and '!' to Bold and Emphasized
+ Define("format(datum)") :(format_end)
+format
+* Bold values
+ ( (datum ? pos(0) '*' = ) (datum ? rpos(1) '*' = )
++ (datum = "\textbf{" datum '}')) :s(format_ret)
+* Emphasized
+ ( (datum ? pos(0) '!' = ) (datum ? rpos(1) '!' = )
++ (datum = "\emph{" datum '}')) :s(format_ret)
+* Small caps
+ ( (datum ? pos(0) '^' = ) (datum ? rpos(1) '^' = )
++ (datum = "\textsc{" datum '}')) :s(format_ret)
+
+format_ret format = datum :(return)
+format_end
+
+****************************************
+
+* Error messages
+ Em = "snobol4 -b tab4tex.sno r=7 a=c b=y h=y c=y <tab.txt >tab.tex"
+ Optmust = "You must set at least (1) number of rows and (2) alignment"
++ nl "e.g.: r=4 a=c. 'r' must be a number and 'a' one of l,r,c (= left, right, centre)"
+* Options:
+* Rows, alignment, separator '|' or empty, hlines or empty, complete LaTeX or not
+ Options = host(0)
+ s_Options = size(Options)
+ (~(gt(s_Options,0)) (terminal = Optmust)) :s(end)
+* Rows
+ (~(Options ? "r=" span(digits) . nrows) (terminal = Optmust)) :s(end)
+* Align
+ (~(Options ? "a=" any("lrcLRC") . align) (terminal = Optmust)) :s(end)
+* Vertical bars (separator)
+ (~((Options ? "b=" any("yY") . sep) (sep = '|') ) (terminal = "No vertical bar required") )
+* Hlines
+ (~((Options ? "h=" any("yY") . hline) (hline = "\hline") (hline = nl hline)) (terminal = "No hline required") )
+* Complete LaTeX?
+ Complete = 'N'
+ (~((Options ? "c=" any("yY") . complete) ) (terminal = "Complete LaTeX document not required") )
+ Complete = replace(Complete,&ucase,&lcase)
+
+* Builds data
+ data1 = sep align ;* separator and alignment
+ data = dupl(data1,nrows) ;* data (e.g. |c|c|c| )
+
+* Complete LaTeX document required?
+ (leq(complete,('y')))
++ (output = "\documentclass{article}" nl "\usepackage[T1]{fontenc}" nl "\begin{document}" nl)
+* Table header
+ output = "\begin{tabular}" '{' data sep '}' tab nl hline
+
+* Main
+MAIN
+read line = trim(input) :f(endenv)
+ line ? (tab | "<M") :f(read)
+ line = line tab
+split line ? break(tab) . cell len(1) rem . line :f(outrow)
+
+* Multicolumn cells (uses function Format)
+ (
++ (cell ? pos(0) ( "<M" (span(digits) . number) '>' ) = )
++ (cell = format(cell))
++ (cell = "\multicolumn" '{' number '}' '{' sep align sep "}{" cell '}')
++ )
+* Normal cells (uses function Format)
+ cell = format(cell)
+
+* Builds row
+ (row = row cell tab '&' tab) :(split)
+* Writes row
+outrow
+ row ? rpos(3) (tab '&' tab) =
+clean row "<E>" = ' ' :s(clean)
+ (output = row tab "\\" tab hline) (row = ) :(read)
+ terminal = row :(read)
+endenv
+ output = "\end{tabular}"
+ (leq(complete,'y')) (output = nl "\end{document}")
+
+end
+
diff --git a/support/tab4tex/test1.pdf b/support/tab4tex/test1.pdf
new file mode 100644
index 0000000000..3966e53879
--- /dev/null
+++ b/support/tab4tex/test1.pdf
Binary files differ
diff --git a/support/tab4tex/test1.tex b/support/tab4tex/test1.tex
new file mode 100644
index 0000000000..3d07c27e03
--- /dev/null
+++ b/support/tab4tex/test1.tex
@@ -0,0 +1,22 @@
+\documentclass{article}
+\usepackage[T1]{fontenc}
+\begin{document}
+
+\begin{tabular}{|c|c|c|c|c|}
+
+\hline
+\multicolumn{5}{|c|}{\textbf{Animals and friends}} \\
+\hline
+ & \multicolumn{2}{|c|}{\emph{Cats}} & \multicolumn{2}{|c|}{\emph{Dogs}} \\
+\hline
+ & \textsc{John} & \textsc{Martha} & \textsc{John} & \textsc{Martha} \\
+\hline
+\textbf{Black} & 2 & 5 & 5 & 0 \\
+\hline
+\textbf{White} & 4 & 1 & 0 & 5 \\
+\hline
+\textbf{Red} & 2 & 1 & \multicolumn{2}{|c|}{Not known} \\
+\hline
+\end{tabular}
+
+\end{document}
diff --git a/support/tab4tex/test1.txt b/support/tab4tex/test1.txt
new file mode 100644
index 0000000000..1a541898b4
--- /dev/null
+++ b/support/tab4tex/test1.txt
@@ -0,0 +1,6 @@
+<M5>*Animals and friends*
+<E> <M2>!Cats! <M2>!Dogs!
+<E> ^John^ ^Martha^ ^John^ ^Martha^
+*Black* 2 5 5 0
+*White* 4 1 0 5
+*Red* 2 1 <M2>Not known
diff --git a/support/tab4tex/test2.pdf b/support/tab4tex/test2.pdf
new file mode 100644
index 0000000000..ed18ee63e8
--- /dev/null
+++ b/support/tab4tex/test2.pdf
Binary files differ
diff --git a/support/tab4tex/test2.tex b/support/tab4tex/test2.tex
new file mode 100644
index 0000000000..2ddfeffe02
--- /dev/null
+++ b/support/tab4tex/test2.tex
@@ -0,0 +1,22 @@
+\documentclass{article}
+\usepackage[T1]{fontenc}
+\begin{document}
+
+\begin{tabular}{|c|c|c|c|c|}
+
+\hline
+ & \multicolumn{2}{|c|}{Singular} & \multicolumn{2}{|c|}{Plural} \\
+\hline
+ & English & \textbf{Gaeilge} & \textbf{English} & \textbf{Gaeilge} \\
+\hline
+1st Person & at me & \textbf{agam} & at us & \textbf{againn} \\
+\hline
+2nd Person & at you & \textbf{agat} & at you & \textbf{agaibh} \\
+\hline
+3rd Person & at him & \textbf{aige} & at them & \textbf{acu} \\
+\hline
+ & at her & \textbf{aici} & & \\
+\hline
+\end{tabular}
+
+\end{document}
diff --git a/support/tab4tex/test2.txt b/support/tab4tex/test2.txt
new file mode 100644
index 0000000000..b4612ae98b
--- /dev/null
+++ b/support/tab4tex/test2.txt
@@ -0,0 +1,7 @@
+<E> <M2>Singular <M2>Plural
+<E> English *Gaeilge* *English* *Gaeilge*
+1st Person at me *agam* at us *againn*
+2nd Person at you *agat* at you *agaibh*
+3rd Person at him *aige* at them *acu*
+<E> at her *aici* <E> <E>
+