% Converted from RTF format using rtf2LaTeX
% Comments and bugs to Erwin Wechtl
%                      Woertg. 2/18
%                      A-2500 Baden
%
\documentstyle{article}
\pagestyle{myheadings}
\newlength{\defaultparindent}
\setlength{\defaultparindent}{\parindent}
 
% heading 1 will be translated as section
% heading 2 will be translated as subsection
% heading 3 will be translated as subsection
% heading 4 will be ignored
%*****************************************************************%
\begin{document}
\section{Some documentation of the rtf2LaTeX filter}



\setlength{\parskip}{0pt}The filter rtf2LaTeX consists of two 
modules, the reader (just called reader) and the writer (called 
rtf2LaTeX), and needs two files, one with the extension ``code`` 
and the other with ``land``. (see later on)

\subsection{The reader }

\setlength{\parskip}{0pt}is written by Paul DuBois and consists 
except besides some initialition stuff of two major parts: The 
procedures RTFReadToken  and  RTFRouteToken. RTFReadToken reads 
unformatted text, ``control words``, ``control symbols`` and 
``groups`` from an rtf-file and creates tokens depending on what 
it has read. 



Tokens are associated with up to three classification numbers:



Class number: Broadest (least detailed) breakdown.

Major/minor numbers: Within their class, tokens have a major 
number, and may also have a minor number to further distinguish 
tokens with the same major number.

Tokens that can't be classified are put in the ``unknown`` class. 
For these tokens, the major and minor numbers are meaningless, 
although rtfTextBuf may be of interest then.

Text tokens are a single character, and the major number indicates 
the character value (note: can be non-ascii, i.e., greater than 
127). There is no minor number.

Control symbols may have a parameter value, which will be found 
in rtfParam.  If no parameter was given, rtfParam = rtfNoParam.

for further details see the includefile ``rtf.h``.



The RTFRouteToken calls a procedure depending  on the class of 
the token and the last call of RTFSetClassCallback. These procedures 
are in the writer, so the reader can be used by any  filter, 
which reads an rtf-file.

\subsection{Changes from the distribution 1.06a2}

\setlength{\parskip}{0pt}I have made some change in the following 
procedures of the reader:

\underline{RTFGetToken:}

Not only newlines and carriage returns, but also NULL characters, 
which can appear by some transports, will be silently discarded.

\underline{ReadStyleSheet:}

In some German versions of WORD the Normale style is called Standard 
style!

And there are some RTF control-words which aren't described in 
the RTF-Specification I have, but nevertheless appear in RTF-files 
which are created by the versions of WINWORD  and Macintosh's 
WORD I use. So I have created a few new RTFKeys, which are shown 
in the following table:

\begin{tabular}{p{50.4pt}p{50.4pt}p{50.4pt}p{50.4pt}}
rtfKMajor & rtfKMinor & rtfKStr & rtfKHash\\
(major number) & (minor number) & (symbol name) & (symbol name 
hash value)\\
rtfDestination, & rtfIVerscomm, & verscomm, & 0\\
rtfTblAttr, & rtfClshdng, & clshdng, & 0\\
\end{tabular}
  
for $\backslash$makebackup I have taken the same RTFKey as 
it is taken for makeback (rtfMakeBackup), and for $\backslash$cs 
and $\backslash$ds the same as for $\backslash$s (rtfStyleNum)

\subsection{In rtf2LaTeX  }

\setlength{\parskip}{0pt}there are the following procedures:

UnknownClass, GroupClass, ControlClass for the rtf-classes with 
the same name.

start\_para for the text-class at the beginning of each paragraph, 
and TextClass elsewhere.

The procedure UnknownClass deals as the name implies with unknown 
rtf-control-words.

GroupClass handles with groups. ( Groups are built both in rtf 
and LaTeX  with $\{$$\}$)

In the procedure ControlClass a case statement calls some  procedures 
depending on the major-number. In these procedures it is easy 
to add some more lines to make a better version of this filter, 
which handles more rtf-control-words than mine.

(Many keywords aren't dealt with, e.g. the two rtf-control-words 
$\backslash$clshdng, $\backslash$verscomm, I have added in the 
reader.)



\subsection{The two translation-files}

\setlength{\parskip}{0pt}Two translation-files are need for 
the rtf2LaTeX filter:

The one with the extension ``code`` tells the filter how to treat 
characters above 128.

The other has the extension ``land`` and tells the filter how 
to translate some special WORD styles like footnote, heading 
1, heading 2, ...

\subsubsection{The character translation file}

The default file is mac.code, which is for rtf-files made by 
Macintosh programs. (These files have the rtf-control-word $\backslash$mac 
at the beginning.) You have to use the file ansi.code for rtf-files 
made by DOS or WINDOWS (rtf-control-word $\backslash$ansi)) Both 
of these files comprise the most important characters. If you 
need more, you will be able to add more in a very easy way. You 
can create your own file as follows:



A comment must be written in the first line of the file. Then 
the lines with the characters follow. The rtf-number of the character 
(from 128 to 255) is at the beginning of each line. Then the 
LaTeX command (a string) follows after a single space. A comment 
can be written after the 25th column. You needn't include all 
numbers from 128 to 256. There are no tab-stops allowed.

Here is an example of a file: (for an example of a whole file 
see mac.code)



\begin{tabular}{p{25.2pt}p{126pt}p{126pt}}
nr & LaTeX-command & comment       \\
193 & $\backslash$'$\{$A$\}$ & /* e1  ~    */\\
194 & $\backslash$$^{\wedge}$$\{$A$\}$ & /* e2       */\\
195 & $\backslash$$\sim$$\{$A$\}$ & /* e2       */\\
\end{tabular}
  


\subsubsection{The special WORD style translation file}



Some WORD-styles will be translated in LaTeX-commands (e.g. heading 
1 to section, heading 2 to subsection, ...) Others will be ignored 
(if the flag -d is off), because LaTeX treats them in a better 
way than WORD (e.g. footnote reference, footnote text) The files 
with the extension .land tells the filter how they should be 
translated.

 

The default file is english.land, which is for rtf-files made 
by the English versions of WORD and WINWORD. (These files use 
the styles heading 1, heading 2, ... footer, header, footnote 
text, ...) You have to use the file german.land for rtf-files 
made by German versions of WORD and WINWORD. (style names: Gliederung 
1, Fusszeile, ...) Both of these files comprise the most important 
special WORD styles. If you need more, you will be able to add 
more in a very easy way. You can create your own file as follows:



A comment must be written in the first line of the file. Then 
the lines with the styles follow. The name of the style is at 
the beginning of each line (Must be a string of 20 characters). 
It may be followed by the LaTeX-begin-command (a string of 20 
characters) and the LaTeX-end-command (20 characters). (If there 
are no LaTeX commands the style will be ignored.) A comment can 
be written after the 60st column. (This comment will be added 
to the LaTeX output file) There are no tab-stops allowed.

Here is an example of a file: (for an example of a whole file 
see english.land)



\begin{tabular}{p{65.45pt}p{63pt}p{63pt}p{119pt}}
word-name            & latex-begin-command  & latex-end-command 
   & comment \\
heading 1            & $\backslash$section$\{$            & $\}$ 
                   & heading 1 -$>$ $\backslash$section\\
heading 2            & $\backslash$subsection$\{$         & $\}$ 
                   & heading 2 -$>$ $\backslash$subsection \\
heading 4            &                       &               
      & heading 4 ignored\\


\end{tabular}


\end{document}