\documentstyle[11pt,wp2latex]{report}

\newcommand{\arrow}{$\rightarrow$}
\renewcommand{\thechapter}{}
\renewcommand{\thesection}{\arabic{section}}
\renewcommand{\thefigure}{\arabic{figure}}

\title{\WPtoLaTeX\\
 \hspace{1cm}\\
       User's Guide}
\author{Jaroslav Fojt\'{\i}k}

\begin{document}

\maketitle

\newpage

\pagenumbering{roman}
\tableofcontents

\newpage

\pagenumpos{\pnbc}
\pagenumbering{arabic}

\section{Introduction}

There is another version of \WPtoLaTeX\ written from scratch
by the original author R. C. Houtepen at TUE-Eindhoven. This version
differs completely from the package in your hand. Please check it on
your nearest CTAN host at:

\begin{verbatim}
    tex-archive/support/wp2latex/*    .
\end{verbatim}

The version there has the disadvantage, that there isn't any source code
available. The source code in the subdirectories is very old. I tried
hardly to contact the author but failed. So I took the latest available
sources (which based on these in the subdirectories mentioned above)
and corrected some errors. I never checked the other version. I apologize
everybody to compare both versions and tell me the conclusion.


\WPtoLaTeX\ was originally designed to translate WordPerfect 5.0 documents
into \LaTeX\ 2.09. Later some code was added to translate also WordPerfect 5.1
documents. Now the preamble is designed for \LaTeX\ 2e (by changing the
preamble by hand it runs also under \LaTeX\ 2.09 of course).

The original programming language used was Turbo Pascal 7.0 and C++. The 
pascal version will be no longer supported from me. Only severe bugs might
be corrected. C++ code has been ported to OS/2, DOS DJGPP and Linux operation
systems.

The projection from one paradigm (WordPerfect = word processing) to another
(\LaTeX\ = typesetting) requires some cooperation on the part of the user.
Because the use of \LaTeX\ is tied to strict rules, one must take these rules
into consideration when using WordPerfect, if the WordPerfect 5.0 document is
to be converted as accurately as possible.  This guide discusses those rules.

\subsection{Some general remarks}

\begin{enumerate}
\item {Don't expect a better looking result only caused by converting text
   from WordPerfect to \LaTeX. You HAVE TO edit the resulting \LaTeX\ files.
   The reason is, that wordprocessors didn't give the structure
   of the text (sections, itemizations, labels, ...) but only
   the formatting (boldface, underline (uurgh), italic, ...).}

\item {See next section for conversion abilities}

\item {Don't expect any miracles from this program.}
\end{enumerate}


\subsection{Authorship history}

\WPtoLaTeX\ was written in Turbo Pascal by R. C. Houtepen at TUE-Eindhoven.
It was converted into C using p2c, and modified, by Glenn Geers (Sydney U).
It was further modified by Michael Covington (U of Georgia).
Modified to be used in unix/linux environment by Claudio Porfiri.
The parsing of formulas was added by Dirk Lellinger (U Halle/Germany).
The splitting of code into several files and the documentation
was done by Andreas Tille.
J Fojtik developed original version from R. C. Houtepen at TUE-Eindhoven
and then tried to give all available versions together.


\newpage

\section{Conversion possibilities}
\label{capabilities}

Because the capabilities of WordPerfect and \LaTeX\ differ strongly, it is
not possible to convert all of WordPerfect's `features'.

\subsection*{
The conversions which are performed by \WPtoLaTeX\ (when converting WP1.x
documents) are:}

\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Endnotes
  \item Extended characters (one charset 256 with chars)
  \item Footnotes
  \item Hard page breaks
  \item Hard returns
  \item Justification :
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item right
      \item center
      \item full
      \end{itemize}
  \item Soft Hyphen
  \item The following Typefaces :
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Superscript
      \item Subscript
      \item Bold
      \item Italic
      \item Underlined (ability to utilize ulem.sty)
    \end{itemize}
\end{itemize}


\subsection*{
The conversions which are performed by \WPtoLaTeX\ (when converting 
WP2,3,4.x MAC documents) are:}

\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Center page
  \item Colors (Only \LaTeX 20e)
  \item Endnotes
  \item Extended characters (one charset 256 with chars)
  \item Flush-right text
  \item Footnotes
  \item Hard page breaks
  \item Headers and footers
  \item Hard returns
  \item Justification :
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item right
      \item center
      \item full
      \end{itemize}
  \item Soft Hyphen
  \item The following Typefaces :
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Bold
		\item Italic
      \item Underlined
      \item Small Capitals
    \end{itemize}
  \item Undo blocks
  \item Widow Orphan ~~ On/Off
\end{itemize}



\subsection*{
The conversions which are performed by \WPtoLaTeX\ (when converting WP4.x
documents) are:}

\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Center page
  \item Comment
  \item Contents
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Mark To Contents
      \item Table of Contents
      \end{itemize}
  \item Date Code
  \item Endnotes
  \item Extended characters (one charset 256 with chars)
  \item Flush-right text
  \item Footnotes
  \item Headers and footers
  \item Hard page breaks
  \item Hard returns
  \item Hyphenation ~~ On/Off
  \item Indenting :
  \item Index
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Mark To Index
      \item Table of Indices (makeindex is required)
      \end{itemize}
  \item Justification :
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item right
      \item center
      \item full
      \end{itemize}
  \item Language
  \item Marks ToContents
  \item Newspaper-style columns (experimental max only 2)
  \item Overstriking
  \item Page number positioning
  \item Page numbers
  \item Page number set
  \item Soft Hyphen
%  \item Tab Settings
  \item The following Typefaces :
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Superscript
      \item Subscript
      \item Bold
		\item Italic
      \item Underlined (ability to utilize ulem.sty)
      \item Double-underlined
      \item RedLine (Only \LaTeX 20e)
    \end{itemize}
  \item Widow Orphan ~~ On/Off
\end{itemize}




\subsection*{
The conversions which are performed by \WPtoLaTeX\ (when converting WP5.x
documents) are:}

\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Abstract
  \item Advances
  \item Center page
  \item Colors (Only \LaTeX 20e)
  \item Comment
  \item Contents
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Mark To Contents
      \item Table of Contents
      \end{itemize}
  \item Cross-references
  \item Date Code
  \item Endnotes
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Endnote items
      \item Endnote placement
      \end{itemize}
  \item Equations (formulas)
  \item Extended characters (foreign language/accented, math, Greek)
  \item Flush-right text
  \item Footnotes
  \item Headers and footers
  \item Hard page breaks
  \item Hard returns
  \item Hyphenation ~~ On/Off
  \item Image boxes ~~~	Images itself should be converted by external utility.
  \item Indenting :
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item left
      \item left and right
    \end{itemize}
  \item Index
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Mark To Index
      \item Table of Indices (makeindex is required)
      \end{itemize}
  \item Justification :
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item left
      \item right
      \item center
      \item full
      \end{itemize}
  \item Labels
  \item Language
  \item Marks ToContents
  \item Newspaper-style columns (using \verb|multicol.sty|)
  \item Outlining
  \item Overstriking ~ (and also attribute changes inside overstrikes)
  \item Page number positioning
  \item Page numbers
  \item Page number set
  \item Soft Hyphen
  \item Tab Settings
  \item Tabs :
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item setting
      \item left tabs
      \item center tabs
      \item right tabs
    \end{itemize}
  \item Tables
  \item Table boxes
  \item Table of contents
  \item Text boxes
  \item The following Typefaces:
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Extra large
      \item Very large
      \item Large
      \item Small
      \item Fine
      \item Superscript
      \item subscript
      \item Bold
      \item Italic
      \item Overstrike
      \item Small caps
      \item Underlined	(ability to utilize ulem.sty)
      \item Double-underlined
      \item RedLine (Only \LaTeX 20e)
    \end{itemize}
  \item Title
  \item Widow Orphan ~~ On/Off
\end{itemize}

\noindent
{\bf Not} converted are :
\begin{itemize}\setlength{\itemsep}{-1mm}
  \item margin settings
  \item top and bottom margins
  \item the calculations in tables
  \item and many other WP features ...
\end{itemize}


\subsection*{
The conversions which are performed by \WPtoLaTeX\ (when converting WP6.x
documents) are:}


\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Center page
  \item Colors (Only \LaTeX 20e)
  \item Comment (also nested ones)
  \item Cross-references
  \item Endnotes
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Endnote counter
      \item Endnote items
      \item Endnote placement
      \end{itemize}
  \item Equations (formulas)
      
  \item Extended characters (foreign language/accented, math, Greek - not linedrawing),
	but some of them badly.
  \item Filename
  \item Flush-right text
  \item Footnotes
  \item Hard page breaks
  \item Hard returns
  \item Headers and footers
  \item Image boxes  ~~~ Images itself should be converted by external utility.
  \item Indenting
  \item Justification:
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item left
      \item right
      \item center
      \item full
      \end{itemize}
  \item Newspaper-style columns (using \verb|multicol.sty|)
  \item Page number set
  \item Page numbers
  \item Tables
  \item Table boxes
  \item Table of contents
  \item Text boxes
  \item Typefaces list follows:
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Extra large
      \item Very large
      \item Large
      \item Small
      \item Fine
      \item Superscript
      \item subscript
      \item Italic
      \item Overstrike
      \item Small caps
      \item Bold
      \item Underlined (ability to utilize ulem.sty)
      \item Double-underlined
      \item RedLine (Only \LaTeX 20e)
      
    \end{itemize}
  \item Undo blocks
  \item Widow Orphan ~~ On/Off  
\end{itemize}

\nwln
\noindent
{\bf Not} converted are all other features for this case.

\nwln
\noindent
Note: WP7.x and WP8.x have the same binary format as WP6.x, so the same subset
of features is converted. WP11.x and WP12.x have a new formula format (MTEFF
same as MS Word) that is also supported by WP6.x module.


\subsection*{
RTF2LaTeX conversion module could convert these RTF (Rich Text File) features:}

\begin{itemize}\setlength{\itemsep}{-1mm}
  \item Colors (Only \LaTeX 20e)
  \item Cross-references
  \item Endnotes
  
  \item Equations (formulas)
 - Only those stored in MTEFF 2.x and MTEFF 3.x
  \item Footnotes
  \item Hard returns
  \item Headers and footers
  \item Justification:
      \begin{itemize}\setlength{\itemsep}{-1mm}
      \item left
      \item right
      \item center
      \item full
      \end{itemize}
  \item Typefaces list follows:
    \begin{itemize}\setlength{\itemsep}{-1mm}
      \item Italic
      \item Small caps
      \item Bold
      \item Underlined (ability to utilize ulem.sty)
      \item Double-underlined
      \item Strike through
    \end{itemize}
  \item Unicode symbols
    
\end{itemize}


\newpage


\section{The program}

\noindent
The program is invoked with the command:

\begin{verbatim}
   WP2LATEX [/? | /-help]
    [WP-filename.WP [TeX-filename.TEX]] [ /i WP-filename.WP] [/o TeX-filename.TEX]
    [/fig-output-dir directory] [ /l Log-filename.TXT ] [ /amssymb ] [ /bbm ]
    [ -configfile filename | -@ filename ] [ /copyright ] [ /cp-codepage ]
    [ /cp-styles ] [ /charset1 | /charsetCZ ] [ /extract-WPG ] [ /fancyhdr ]
    [/force-xxx] [/FORCE-xxx] [ /ignore-tabs ] [ /input-PS ] [/L language] 
    [ /LaTeX2 | /LaTeX3 ] [ /latexsym ] [ /no-amssymb ] [ /no-bbm ] [ /no-columns ] 
    [/no-erase-strip] [ /no-extract-WPG ] [ /no-input-PS ] [ /no-latexsym ]
    [ /no-safemode ] [ /no-texchars ] [ /no-wasy ]  [ /s "password" ] 
    [ /S | /silent] [/safemode] [ /silent ] [ /texchars] [ /ulem ] [ /v ] 
    [ /wasy ]

\end{verbatim}

\bigskip
\noindent
Following Unix-like call style is also possible:

\begin{verbatim}
   WP2LATEX [-? | --help]
    [WP-filename.WP [TeX-filename.TEX]] [ /i WP-filename.WP] [/o TeX-filename.TEX]
    [-fig-output-dir directory] [ -l Log-filename.TXT ] [ -amssymb ] [ -bbm ]
    [ -configfile filename | -@ filename ] [ -copyright ] [ -cp-codepage ] 
    [ -cp-styles ] [ -charset1 | -charsetCZ ] [ -extract-WPG ] [ -fancyhdr ]
    [-force-xxx] [-FORCE-xxx] [ -ignore-tabs ] [ -input-PS ] [-L language] 
    [ -LaTeX2 | -LaTeX3 ] [ -latexsym ] [ -no-amssymb ] [ -no-bbm ] [ -no-columns ]
    [-no-erase-strip] [ -no-extract-WPG ] [ -no-input-PS ] [ -no-latexsym ] 
    [ -no-safemode ] [ -no-texchars ] [ -no-wasy ]  [ -s "password" ] 
    [ -S | -silent] [-safemode] [ -silent ] [ -texchars] [ -ulem ] [ -v ]
    [ -wasy ]
\end{verbatim}

\subsection{Description of command line arguments}

\nwln
The parameter \verb|WP-filename.WP|\footnote{This may be a WordPefect 5.0
document with an extension other than \verb|.WP|} is optional.
The program starts with an opening screen and asks for the WordPerfect
filename.  The default filename is printed inside square brackets
\mbox{(\verb|[ ]|)} and is the parameter which was optionally included in
the initial invocation of \verb|WP2LATEX|\null.  The user can at this point type
in another WordPerfect filename, or he can hit return to choose the default
filename. The program next requests the name of the generated \LaTeX\
document. The default given within brackets is the name of the
WordPerfect file, with the extension \verb|.TEX|\null or
\verb|TeX-filename.TEX| passed as second argument.  Once again the user
may accept this name or enter another\footnote{This may be a file with an
extension other than \verb|.TEX|}.  Once the filenames are given, the 
following error messages may appear :

\begin{itemize}
  \item \uline{File not found :} The given WordPerfect file does not exist.
  \item \uline{Path not found :} An invalid path was given in the name
        of one of the files.
  \item \uline{Not a WordPerfect 5.x document :} The given WordPerfect
	file was not created in WordPerfect 5.x
\end{itemize}

Arguments \verb|/cpXXX| are used for 8. bit \TeX, which is able to process
some of these code pages. WP2LaTeX currently supports these codepages:
"852"(ISO8), "866"(Russ), "895"(Kamenicky), "1250"(Win),
"1251"(WinRuss), "ISO8859-2", "ISO8859\_1", "KOI8R".

The codepage \verb|/cp895| is called as
Kameni\v{c}t\'{\i} and is often used in central Europe. The codepage
\verb|/cp895| (ISO8) is preferred in DOS for central Europe and
the codepage \verb|/cp1250| is designed for central Europe Windows.
Russian people would prefer \verb|/cp1251| (Windows) or \verb|/cp866| or
\verb|/cpKOI8R|.


WP2LaTeX has sophisticated way how to autodetect file format of given document.
Some file formats like WP4.x or WP1.x could not be fully detected. Turning this parameter
on switch to the selected conversion module in the case when autodetection
do not find any appropriate file format. \verb|xxx| stands for conversion module shortcut.
These are WP1.x, WP3.x, WP4.x, WP5.x, WP6.x, HTML, RTF, T602, AbiWord. Type 
\verb|wp2latex -v|
 to obtain list of them. 

Please note that one conversion module converts whole family of fileformat modifications.
WP3.x converts WP2.x MAC, WP3.x MAC and WP4.x MAC. WP6.x convertor converts files
from Word Perfect 6 up to Word Perfect 12.


If you try to convert documents e.g. from WP version 4.x then this program sometimes
says that you have no WP file. The reason is that WP 4.x format gives no chance
for reliable autodetection. If you are sure that you have a WP 4.x file turn
the switch \verb|-force-WP4.x| on. The same approach could apply foe any conversion
module. If you are absolutely sure that you have a binary corrupted fragment
of WP5.x file you could use \verb|-force-WP5.x|. Lowercase \verb|-force-xxx|
uses suggested conversion module only if autodetection fails.

Much more stronger is argument \verb|-FORCE-xxx|. This argument turns off any 
autodetection and enforces using of a given conversion module. Use it only if
you are sure about it and expect troubles, because your file might be corrupted.


There are available several types of coding accented characters
in WP5.x. It is too bad. I guess that coding char set 1 is most common.
Thus switch \verb|/charset1| is default set.
If user wants to switch to the another coding, he should add switch
\verb|/charsetCZ|. But I have no available description of this coding
and only several characters will be converted properly.
This switch has no influence for other conversion modules.


There is a very unclean custom to enhance documents with tabulators (\verb|[Tab]|).
Any attempt to convert these documents into \LaTeX\ would look quite ugly.
That is why \verb|-ignore-tabs| switch was introduced to ignore all tabs inside document.


Switch \verb|/L language| turns on the translation features. These features
are based on the gettext library, which must be properly installed.
This means, that the system variable \verb|LOCALEDIR| should be properly
set. If not, then the program \verb|wp2latex| looks for the file referred in
the \verb|DJGPP| and attempts to find the description of \verb|LOCALEDIR|.
The system variable \verb|LANGUAGE| has same meaning, but the
command line switch has stronger influence.

Switches \verb|-LaTeX2| and \verb|-LaTeX3| are aimed for selecting a LaTeX
dialect. There are some fine nuances between \LaTeX 3 and \LaTeX 2 and slightly
different output is generated. \LaTeX 3 stands for \LaTeX 20e.

Switch \verb|/noerase-strip| is intended for debugging purposes. The program
do not erase all temporary files so you can analyze them later.

If you turn the switch \verb|-safemode| on, you can convert even corrupted WP
wiles which hang WordPerfect well. All internal objects are tested and
corrupted ones are digged out. If you don't want this feature then omit this
switch. Do not expect better conversion from this feature.
In most cases it only slow down a conversion. But if your documents are really
corrupted, the conversion results may be better due to fixing errors.

Use \verb|-silent| switch to reduce output messages. WP2LaTeX normally outputs
a lot of warnings and notes about conversion. These notes could be usefull
for analysing conversion results. This switch could be used to stop message
generation.

Switch \verb|/texchars| allows using WordPerfect as a \TeX\ editor. If this switch
is active, then controlling \TeX\ sequences are not distorted and
you can add for example new equation (in the WP equation editor),
which will be converted. Please look also for the example file
\verb|test\texchars.wp|.

If you want to use some switch very often, it is possible to set a system variable
\verb|wp2latex|. This variable is read before a command line is processed.
For example you may want to set output codepage 895 and language
CS. \verb|wp2latex=-cp985 -L cs|.


\subsection{Program Behaviour}

The conversion takes place in two passes.  In the first pass the WordPerfect
input-file is read in, byte by byte.  On the basis of that are created two
files, \verb|WP-filename.STR| and \verb|WP_filename.TBL|\null.
\verb|WP-filename.STR| contains the characters, tab settings and changes of
typefaces; \verb|WP-filename.TBL| holds information regarding the various
\LaTeX\ environments that must be opened and closed.  In the second pass these
files are assimilated into a single \LaTeX\ file.  After a successful
conversion the files \verb|WP-filename.STR| and \verb|WP-filename.TBL| are
automatically deleted.

%\newpage

Invoking \WPtoLaTeX\ to convert the WordPerfect 3.x, 4.x, 5.x or 6.x - 12.x
document e.g. \verb|C:\WPTEST\TEST.WP5| will cause the following screen to appear:

\begin{verbatim}

>>>WP2LaTeX<<< Conversion program: From Wordperfect to LaTeX Version 3.33
  (c) Made by J.Fojtik  ---- Date : 1996-2006

WordPerfect-filename [ ] :  c:\wptest\test.wp5
LaTeX-filename [c:\wptest\test.TEX] :

Converting ...

First pass :
Converting-percentage : 100%

Second pass :
Converting-percentage : 100%

Conversion completed.

\end{verbatim}

The first line of the generated \LaTeX\ file, in the case of the file
\verb|C:\WPTEST\TEST.TEX|, will look as follows:

\begin{verbatim}
   \documentstyle[11pt,wp2latex]{report}
\end{verbatim}
\nwln

When calling \LaTeX\ to typeset the converted document, the style file
\verb|WP2LATEX.STY| should be in the current directory or in the style-file
directory (e.g., \verb|\PCTEX\TEXINPUT|).
This style file defines a number of macros and environments which are
regularly used in the generated \LaTeX\ files.  Examples include the command
\verb|\nwln| and the \verb|indenting| environment. \verb|\nwln| generates a
hard carriage return after the end of a \LaTeX-environment.  The
\verb|indenting| environment is used in the conversion of WordPerfect's
\verb|[|\arrow\verb|Indent]| command (see \S~\ref{indent}).


\section{How to install WP2LaTeX}

\subsection{Under DOS and OS/2}

You should place properly four files: \verb|wp2latex.exe|, \verb|wp2latex.sty|
\verb|endnotes.sty| and \verb|wp2latex.mo|.

Place the file \verb|wp2latex.exe| somewhere into your path. The good solution
is to place it to \verb|c:\emtex\| etc.

The path for files \verb|wp2latex.sty| and \verb|endnotes.sty| should be
available in the system variable \verb|texinput|. A good solution is to place them
to \verb|c:\emtex\texinput\|.

The last step is not required for proper behaviour of the program \verb|wp2latex|.
It the last file is not placed, then your program will not be able to translate
output messages to your language (if the translation is available of course).

Merge the directory e.g. \verb|c:\gnu\share\locale\| with \verb|doc\locale\|.
Or you may have translations in the directory referred in the system
variable \verb|localedir|.


\subsection{Under Linux}

The installation is very easy. Change to the directory sources.cc and type
\verb|make install|. It is all.


\subsection{Windows}

Windows are meant Windows 95, Windows 98, Windows ME, Windows NT, 
Windows 2000 and Windows XP. (I hope that Windows Vista will work a same way.)
Obsolete Windows 3.1 are not supported. If you have them, use pure DOS or DPMI
command line wp2latex.

Please create this directory structure:
\begin{verbatim}
 |
 +wp2latex           (win_wp2l.exe; wp2latex.chm)
  +-locale
    +-cs
    | +-lc_messages  (wp2latex.mo)
    +-de
      +-lc_messages  (wp2latex.mo)
\end{verbatim}

A root that contains \verb|wp2latex| directory could be
\verb|C:\Program Files\wp2latex| or \verb|C:\wp2latex| or any other 
you decide.

Files \verb|win_wp2l.exe|; \verb|wp2latex.chm| are located in a directory
\verb|win\|. Locale subtree is located in directory \verb|doc\|. If you
have central storage of locale, you could also merge its directory e.g.
\verb|c:\gnu\share\locale\| with \verb|doc\locale\|. Or you may have
translations in the directory referred in the system variable \verb|localedir|.

The path for files \verb|wp2latex.sty| and \verb|endnotes.sty| should be
available in the system variable \verb|texinput|. A good solution is to place them
to \verb|c:\emtex\texinput\|. It depends on your \LaTeX\ distribution.

\nwln

Anyway, you could get first experiences without installing wp2latex.
Just simply execute a file \verb|win_wp2l.exe| from Windows file manager.

\subsubsection{MikTeX}
(Recommended) Install the .sty file with MiKTeX as follows:

* Navigate to the folder where LaTeX packages get installed. If you accepted 
  the default location when you installed MiKTeX, this folder is probably 
  \verb|C:\Program Files\MiKTeX 2.5\tex\latex|. (If you have an older MiKTeX 
  installation, this folder is probably \verb|C:\texmf\tex\latex|.)
* Create a new folder inside this folder and call it wp2latex.
* Save your .sty file into this folder.
* Open the MiKTeX Options program. (You can do this by clicking Start, then All Programs, then MiKTeX, then MiKTeX Options.)
* Click 'Refresh Now' on the window that opens. Now you should be able to use any information in that .sty file in any LaTeX source file.




\newpage

\section{Discussion about conversion reliability}

When I started to contribute to this convertor, I have read that after
conversion somebody must use several filters and special program to make a nice
\LaTeX\ output.
{\footnotesize \sc \it I have translated a huge WP file (about 1MB text) with a lot of
footnotes but no tables and formulas. To get a nice LaTeX format I wrote about 5 C-programs and about
40 sed-lines to convert some ugly formattings. After this I spend some time with manual editing.
At last I wrote a LaTeX-style for a nice looking document.
The whole procedure took me three days.}
It was too bad! I hope, that this is not true with a current release.

So I expect that the conversion should be done better. Thus I started to
improve convertor. Now it is something like AI (Artificial Intelligence)
project and the results are not excellent. Why?

\begin{enumerate}
\item Conversions performed by \WPtoLaTeX\ are only partial and some features
      are ignored.
\item In WordPerfect document are some unwanted
      codes (such as [Tab], [Tab Set], [indent] instead [Tab] etc.) I advise you
      to use [Tab] as small as possible.
\item Word Perfect allow anybody to do some terrible
      thinks which are in \LaTeX\ prohibited. For example
      \verb|\section{Some sect\tableofcontents ion}|. Many of them have been founded
      and fixed but I guess that number of such situations is very big.
\end{enumerate}


But don't worry so much. If your document is simple, you can use converted
\LaTeX\ file immediately with only minor changes. If your document become
complex, then you must check conversion results more carefully.
It is a good idea to print a converted file and compare it with original one.

If you expect, that something is removed from your document you can
try \verb|-l logfile.txt| option to see a list of all WP objects.


\section{Guidelines}

\subsection{Tabbing}

Tab settings allow the exact placement of pieces of text, e.g., for creating
tables. There are two sorts of commands involved here.  First, there is the
setting of tabs; this defines {\em where} subsequent tab-stop commands will
place text. Then there are the tabs themselves, which force a {\em jump} to
one of the previously-defined positions. In \LaTeX , however, tabs
are enabled only within a \verb|tabbing| environment. \WPtoLaTeX\ takes
care of that by invoking a \verb|tabbing| environment only for those lines
where one or more tabs appear.

Within WordPerfect, a line containing tabs must terminate with a hard
carriage return.  If this is not the case, the tab positions in the generated
\LaTeX-document will not be fixed.  \LaTeX\ will incorrectly typeset the
spacing of such lines.

\noindent
The following WordPerfect text will be incorrectly converted:

\begin{verbatim}
   Text1 [Tab] text2 [Tab] text3 [SRt]
   text4 [Tab] text5. [HRt]
\end{verbatim}
\nwln

\noindent
The following is better:

\begin{verbatim}
   Text1 [Tab] text2 [Tab] text3 [HRt]
   text4 [Tab] text5. [HRt]
\end{verbatim}
\nwln

A tab-setting in the middle of a line holds for the entire line in the 
converted document (unlike in WordPerfect).  It is
therefore advisable to set tabs at the beginning of or prior to the
pertinent line.

\medskip\noindent
{\bf Few restrictions:}

\LaTeX\ endows such commands as \verb|\'|, \verb|\`| and \verb|\=| with special
meanings within a \verb|tabbing| environment.  Outside a \verb|tabbing|
environment, these commands are used for the placement of accents; within
one, however, they must be replaced by \verb|\a'|, \verb|\a`| and \verb|\a=|, 
respectively.  \hbox{\WPtoLaTeX} does not perform this replacement, so it is 
left to the user to do it after the conversion.

WordPerfect 5.0 allows up to 40 tabstops to be set.  \LaTeX\ can set at most
14 of them.  As a result, if tabs are to be converted properly, the user may
set no more than 14 tabstops within WordPerfect, either.  If more than 14
tabs are set, processing by \LaTeX\ will result in a number of error messages,
and ultimately one or more tabs may be lost.

% \newpage

\subsection{Indenting}
\label{indent}

Indenting is used to alter the margins of pieces of text (paragraphs).
Possible conversions with regard to indenting commands are :

\medskip\noindent
Examples :

\begin{tabbing}
\verb|   [|\arrow\verb|Indent]|$^*$\verb|  |\=
        \verb|An indented paragraph which [SRt]| \\
     \> \verb|extends over several lines and [SRt]| \\
     \> \verb|is closed with a hard carriage [SRt]| \\
     \> \verb|return. [HRt]| \\
\end{tabbing}
\begin{tabbing}
\verb|   label  [|\arrow\verb|Indent]|$^*$\verb|  |
  \= \verb|We see here the possibility of [SRt]| \\
  \> \verb|placing a `label' in front of [SRt]| \\
  \> \verb|indented text. [HRt]| \\
\end{tabbing}
\begin{tabbing}
\verb|   [|\arrow\verb|Indent]|$^*$\verb|  label  [|
\arrow\verb|Indent]|$^*$\verb|  |
  \= \verb|It is also possible to place [SRt]| \\
  \> \verb|an `indented label' in front [SRt]| \\
  \> \verb|of indented text. [HRt]| \\
\end{tabbing}

\nwln
where \verb|[|\arrow\verb|Indent]|$^*$ indicates one or more 
\verb|[|\arrow\verb|Indent]| commands.

\vspace{1cm}

The indenting consists from three commands:\\
\verb|\testlastline|\\
~~~~~~~	This \TeX command replaces a \verb|\par| command. But
moreover it measure the length of the last paragraph line.

A command \verb|\zerolastline| assumes that the size of the last
paragraph line is zero.

A \LaTeX environment \verb|indenting| is used to indent a text.
In current release the limitation of two indents is broken, but
you cannot combine indents and tabs together.


\subsection{Combinations of tabbing and indenting}

In practice it is evident that tabbing and indenting commands are often
used together.  The effect of that within WordPerfect is often identical:
words come out on the page where one wishes, on the screen as well
as on paper (What You See Is What You Get).

In \LaTeX, however, the difference between tabs and indents is fundamental.
It is important that the WordPerfect-user take this into account.  Thus only
the \verb|[Tab]| command may be used for tabbing and only the 
\verb|[|\arrow\verb|Indent]| command for indenting.  If both tabbing and 
indenting commands are used within a single line, only the type which is 
encountered first will be converted.

\noindent
An example:
\begin{tabbing}
\verb|   [Tab] tom [Tab] dick [|\arrow\verb|Indent] harry [HRt]| \\
\end{tabbing}

The tab command in this line comes before the indenting command.  The
interpretation by \hbox{\WPtoLaTeX} is then:
\begin{tabbing}
\verb|   [Tab] tom [Tab] dick harry [HRt]|
\end{tabbing}

\noindent
The indent-command is eliminated.  The line should instead look as follows:
\begin{tabbing}
\verb|   [Tab] tom [Tab] dick [Tab] harry [HRt]|
\end{tabbing}



\subsection{Page number positioning}

The WordPerfect document is converted to a single-sided document.  This
means that page number positions 4 and 8 are not converted.  The page
number positions which \WPtoLaTeX\ will convert are reproduced in 
figure~\ref{fig:pagnr}.

\begin{figure}[hbt]
\centering
\setlength{\unitlength}{3mm}
\begin{picture}(12,16)
 \thicklines
 \put(0,0){\framebox(12,16)}
 \put(1,14){\makebox(10,1)[l]{1}}
 \put(1,14){\makebox(10,1){2}}
 \put(1,14){\makebox(10,1)[r]{3}}
 \put(1,1){\makebox(10,1)[l]{5}}
 \put(1,1){\makebox(10,1){6}}
 \put(1,1){\makebox(10,1)[r]{7}}
\end{picture}
\caption{page number positions}
\label{fig:pagnr}
\end{figure}

% \newpage

\subsection{WordPerfect default values}

The conversion program generates, independently of the WordPerfect settings,
a \LaTeX\ document with a left margin of 1 inch (2.54cm).  This is because
\LaTeX\ enforces left and top margins of at least 1 inch (see 
figure~\ref{fig:tabs}).  \WPtoLaTeX\ therefore assumes that the margins 
in the WordPerfect document are also set to 1 inch and that they do not 
change.

Tabs are set every inch by default (14 tab stops).  A different default 
tab-setting can be placed at the first line.  If the standard, one-inch 
default settings are not used, however, processing by \LaTeX\ may produce 
error messages.  This has more to do with the manner in which WordPerfect 
positions tab-stops than it does with \LaTeX (see figure~\ref{fig:tabs}). 
\LaTeX\ positions tab stops relative to the left margin, which, as mentioned
above, is a minimum of 1 inch wide.  In WordPerfect the left margin and the
tab settings are independent of each other.

\begin{figure}[hbt]
\centering
\setlength{\unitlength}{1.5mm}
\begin{picture}(60,50)
 \thicklines
 \put(0,0){\framebox(28,35)}
 \put(32,0){\framebox(28,35)}
 \thinlines
 \put(0,37){\makebox(1,3)[l]{WordPerfect}}
 \put(32,37){\makebox(1,3)[l]{\LaTeX}}
 \put(36,31){\line(1,0){21}}
 \put(36,31){\line(0,-1){28}}
 \put(32,31){\vector(1,0){4}}
 \put(36,31){\vector(-1,0){4}}
 \put(36,31){\vector(0,1){4}}
 \put(36,35){\vector(0,-1){4}}
 \put(37,31){\makebox(1,4)[l]{{\small 1"}}}
 \put(32,28){\makebox(4,2){{\small 1"}}}
 \put(36,27){\vector(1,0){3}}
 \put(40,27){\makebox(1,1)[tl]{{\scriptsize tab 1}}}
 \put(36,25){\vector(1,0){6}}
 \put(43,25){\makebox(1,1)[tl]{{\scriptsize tab 2}}}
 \put(36,23){\vector(1,0){9}}
 \put(46,23){\makebox(1,1)[tl]{{\scriptsize tab 3}}}
 \put(4,31){\line(0,-1){28}}
 \put(4,31){\line(1,0){21}}
 \put(0,27){\vector(1,0){7}}
 \put(8,27){\makebox(1,1)[tl]{{\scriptsize tab 1}}}
 \put(0,25){\vector(1,0){10}}
 \put(11,25){\makebox(1,1)[tl]{{\scriptsize tab 2}}}
 \put(0,23){\vector(1,0){13}}
 \put(14,23){\makebox(1,1)[tl]{{\scriptsize tab 3}}}
\end{picture}
\caption{tab settings in WordPerfect and \LaTeX}
\label{fig:tabs}
\end{figure}

\newpage


\subsection{Footnotes \& Endnotes}

Within a footnote only carriage returns and typefaces (see 
\S~\ref{capabilities}) are converted.  A footnote number may 
consist only of numerals.

Footnotes within lines which contain tab settings will not appear at the bottom
of the page; \LaTeX, in contrast to WordPerfect, does not process them.  This
is a limitation (read:  bug) of \LaTeX.

Endnotes are processed similarly as footnotes. Moreover an additional style
\verb|endnotes.sty| must be present in \TeX\ path for styles.
If you don't use endnotes in your WP document, the style
\verb|endnotes.sty| is not required.



\subsection{Formulas}

Because of the philosophy of typing an equations in WP is very similar
to \TeX ~conversion is not so difficult. The Math is written in both cases
in text notation, but in WP is enveloped into the object [Equ Box:nn;;].
This convertor is also able to translate Greek characters, symbols and
matrixes included in equations.

\medskip\noindent
Example (of some simple equation):

\noindent
WP equation string:
\medskip\noindent
"  a= 1/4+\{4\^{}5\} over \{2+x\^{}5\} + 1 over \{2 + 3 over \{4+y\}\}
   5 SQRT \{68+x\^{}e over 5\} \~{} + \~{} NROOT \{r+6\}\{8\} "

\medskip\noindent
\TeX equation string:
" a= 1/4+$\tt\backslash$frac\{\{4\^{}5\}\}\{\{2+x\^{}5\}\} +$\tt\backslash$frac\{1\}\{\{2
  + $\tt\backslash$frac\{3\}\{\{4+y\}\}\}\} - 5 $\tt\backslash$sqrt \{\{68+x\^{}
  $\tt\backslash$frac\{e\}\{5\}\}\} \~{} + \~{} $\tt\backslash$sqrt [ \{r+6\} ] \{ 8\} "


\medskip\noindent
And correctly displayed equation follows:
\begin{displaymath}
a= 1/4+\frac{{4^5}}{{2+x^5}} +\frac{1}{{2 +\frac{3}{{4+y}}}} - 5 \sqrt{{68+x^\frac{e}{5}}}
   ~ +  ~ \sqrt[{r+6}]{8}
\end{displaymath}


\subsubsection{Influence of formula attributes}

The inside part of formulas is nearly same, but interfacing LaTeX environment
depends on setting many attributes.

The simplest output environment is {\bf displaymath}.
It is used for single formulas with anchor type paragraph or page without any caption.
The {\bf eqnarray*} environment is used for multiple formulas in one.

If there is any caption then {\bf displaymath} is changed to {\bf equation}
or {\bf eqnarray}. Only first equation in array is numbered and others
are marked by {\bf nonumber} \LaTeX command.

Environment \$ \$ is used mainly for the character type anchoring.
Don't ask me why. Character anchored equations are usually a part of sentence
and displaymath will distort such sentences like this: $\sqrt 4 + {1 \over 2}$.
It is also used in places where previous environments cannot be typed
(e.g. in the case of tables).

The most complicated case occurs when formula is enclosed in table, figure
or special box. Then correct box is generated and formula is placed inside.

\medskip
Sometimes you must repair converted equations manually.



\subsection{Headers and footers}

Within a header or footer a number of converted features is
reduced (see \S~\ref{capabilities}).

\noindent
One can split a header or footer into three pieces :
\begin{itemize}\setlength{\itemsep}{-1mm}
  \item left-aligned
  \item centered
  \item right-aligned
\end{itemize}
\nwln
These three parts are separated within WordPerfect by using the centering
command (Shift F6) and the flush-right command (Alt F6).

\noindent
The effect of the WordPerfect commands in the header

\begin{verbatim}
   Left[Cntr]Middle[C/A/Flrt][Flsh Rt]Right[C/A/Flrt]
\end{verbatim}
\nwln
will, after conversion to \LaTeX\ format, be interpreted as is shown in
figure~\ref{fig:header}.  Choosing a new setting for the placement
of header or footer text on only even (or only odd) pages does not affect 
the alternate pages' previous setting.

\begin{figure}[hbt]
\centering
\setlength{\unitlength}{3mm}
\begin{picture}(12,16)
 \thicklines
 \put(0,0){\framebox(12,16)}
 \put(1,14){\makebox(10,1)[l]{{\tiny Left}}}
 \put(1,14){\makebox(10,1){{\tiny Middle}}}
 \put(1,14){\makebox(10,1)[r]{{\tiny Right}}}
 \put(1,12){\line(1,0){10}}
 \put(1,11){\line(1,0){10}}
 \put(1,10){\line(1,0){10}}
 \put(1,9){\line(1,0){10}}
 \put(1,8){\line(1,0){10}}
 \put(1,7){\line(1,0){10}}
 \put(1,6){\line(1,0){10}}
 \put(1,5){\line(1,0){10}}
 \put(1,4){\line(1,0){10}}
 \put(1,3){\line(1,0){10}}
 \put(1,2){\line(1,0){10}}
\end{picture}
\caption{headers}
\label{fig:header}
\end{figure}



\subsection{Images}

It is quite difficult to convert text with images without any compromise.
Current version of \WPtoLaTeX{} attempts to ease image conversion as much
as possible. Some images are not converted, but they could be extracted from
WP file by using switch \verb|-extract-WPG|. Then they could be normally converted
by external utility (e.g. ImageMagick http://www.imagemagick.com/
or GraphicMagick http://www.graphicsmagick.org/index.html).
\WPtoLaTeX{} generates a postscript placeholder when it cannot cope with image.
User could replace this placeholder with converted postscript image.
Switch \verb|-extract-WPG| do not influence output \LaTeX\ file.

The image boxes are created in the \LaTeX{} file. There are three different
ways for converting them:

\begin{description}
\item{epsfig} This option is activated by -epsfig switch.
\item{graphicx} This option is activated by -graphicx switch. This is
                a standard package included in \LaTeX{}20e. This option is
                refused when converting into \LaTeX{}2.0.
\item{input-PS} This option is activated by -inputPS switch. InputPS is useful
                package for including postscript files.
\end{description}

\bigskip

\noindent
Example of converted image:

\begin{verbatim}
\begin{figure}[htbp]
\begin{forcewidth}{7.54cm}
 \begin{center}\InputPS{\FigDir/TRAINER.ps} \end{center}
\end{forcewidth}
\caption{Three point attachment to the wall.}
\end{figure}
\end{verbatim}

\medskip

\noindent
This will look like this image:

\begin{figure}[htb]
\centering
\setlength{\unitlength}{3mm}
\begin{picture}(28,20)
 \thicklines
 \put(0,0){\framebox(28,20)}
 \put(1,16){\makebox(28,1)[c]{Please convert an image}}
 \put(1,12){\makebox(28,1)[c]{TRAINER.WPG}}
 \put(1,8){\makebox(28,1){To the postscript}}
 \put(1,3){\makebox(28,1)[c]{manually!}}
\end{picture}
\caption{Three point attachment to the wall.}
\end{figure}

The user could replace dummy image TRAINER.PS by the newly converted one.
It is not necessary to change \LaTeX{} source after replacing images, because
they are stored externally.


If the file contains a lot of images, it is good idea to redirect them into 
separate directory. Use the switch -fig-output-dir for specifying a directory
for storing images. It is good idea to enter relative path like ./images.
Otherwise the \LaTeX file would be not portable.  The relative
path is related to output .tex file. Default value is ".".


\subsection{Spaces}

Because WordPerfect works well as tool for the visual design of a document, 
users often have the tendency to use spaces to produce an acceptable layout.
Multiple spaces within \LaTeX, however, have the same effect as a single 
space.  Therefore, in converting a WordPerfect document, multiple spaces are 
changed into `hard' \LaTeX-spaces.

\noindent
For example:

\begin{tabular}{|l|l|}
\hline
WordPerfect                & \LaTeX \rule[-.5cm]{0cm}{1.5cm} \\
\hline
\verb*|word1    word2|   & \verb*|word1 ~~~word2|\rule[-.5cm]{0cm}{1.5cm} \\
\hline
\end{tabular}
\nwln

When these come at the beginning of a line, however, they have no effect.
Moreover, the layout which existed in the WordPerfect environment will seldom 
be properly achieved in \LaTeX, because of the different typographic rules, 
typefaces and text-spacing that the latter handles.

{\bf Note:} This feature produces typographically incorrect things and
thus it is implicitly turned off. If you want to turn it on, then use switch
\verb|-fix-spaces|.



\subsection{Tables}

The \WPtoLaTeX\ is also able to convert a tables. It converts
style of centering of columns. It do not recognize
all WP features such as special dotted cells, and double lines somewhere.
Thus an line art from tables will not be converted well.
A size of columns is not converted.

\medskip\noindent
Table looking like this in WP:
\begin{verbatim}
[Tbl Def:I;3,5.31cm,5.31cm,5.31cm]
[Row] [Cell] Left Centered  [Cell] Center [Cell] Right Centered
[Row] [Cell] 111 [Cell] 222 [Cell] 333 Centered
[Tbl Off]
\end{verbatim}

\medskip\noindent
Is converted to:
\begin{tabular}
{|l|c|r|} \hline
Left centered & Center & Right centered \\ \hline
111 & 222 & 333 \\ \hline
\end{tabular}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Used Styles}

\WPtoLaTeX\ has its own style named \verb|WP2LATEX.STY|. Features in this style
could be divided into two categories:

\begin{enumerate}
\item Features that I cannot find in any package.
\item Automatically disabled/enabled features that could be found in
      some packages. Packages with those features must precede \verb|WP2LATEX.STY|
      to avoid double definition errors.
\end{enumerate}


Please keep in mind, that you do not need to use all listed packages.
You can disable some of them or all of them and \WPtoLaTeX\ should still
be able to produce \LaTeX\ output. \verb|WP2LATEX.STY| is the only mandatory
style.

\bigskip\noindent
The full list of used packages:

\begin{description}
\item[amssymb]    Style with special math characters.
\item[makeidx]    Style for creating index file.
\item[ulem]       Style for better underlining and striking out text.
\item[wp2latex]   The \WPtoLaTeX\ basic style. This style is mandatory and is
                  used in every documents.
\item[twoside]	  The style for distinguishing odd and even pages mainly
		  for headers and footers.
\item[twocolumn]  Style that supports typesetting in two columns.
\item[multicol]   Style that supports typesetting in two or more columns.
\item[endnotes]   Style that supports endnotes.
\item[cyrillic]   Style with special mainly Russian characters.
\item[graphicx]	Standard style for including postscript graphics in \LaTeX{}2.0e.
\item[InputPS]    Style that supports postscript tricks inside \LaTeX\ files.
                  The newest version could be downloaded from
                  http://wuarchive.wustl.edu/packages/TeX/macros/generic/boxedeps/
\item[wasyfont]   Style with special characters.
\item[textcomp]   Style with special characters.
\item[bbm]        Style with special characters.
\item[mathrsfs]   Style with special characters.
\item[fancyhdr]   Style that supports headers and footers for pages.
\item[fontenc{[T1]}] Style with special characters.
\item[longtable]  Another style for tables.
\item[czech]      Native support for Czech language. Used only if the czech
                  language is autodetected.
\item[german]     Native support for German language. Used only if the czech
                  language is autodetected.
\end{description}


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
\newpage
\section{Advanced features}

\subsection{Understanding log file}

The log file is aimed to better understanding of the contents of binary
objects in the original WordPerfect file. It is similar to reveal codes
in the WordPerfect editor. From this file you could find all objects
that are not converted yet.

Creation of the log file is normally disabled. You could enable it by
option \verb|-l logfilename|. After conversion you can use any text viewer
for analysing this file.

\medskip\noindent
An example of the log file:
\begin{verbatim}
% log file for converted file c:\temp\font8.wp, WP ver 6.0
% conversion program WP2LaTex v. 2.111 from 27 Dec 1999.

Object type: DDh subtype:  Ah length:  16 [!Global on] 
Object type: D1h subtype:  Fh length:  16    
Object type: D1h subtype: 13h length:  12    
Object type: D1h subtype: 11h length: 340    
Object type: D3h subtype:  5h length:  12 [Justification Full] 
Object type: DDh subtype:  Bh length:  11 [!Global off] 
Object type: D4h subtype: 5Fh length:  16    TNR1>>>
Object type: D4h subtype: 1Bh length:  31 [!Font 1.00] 
Object type: D4h subtype: 1Ah length:  31 [!Font Times] <<<Kecy kecy
Object type: CFh subtype:  0h length:   1 [SRt] kecy 
% pass1 finished going to pass2

% pass2 finished
%  There were 0 unconverted characters.
%  There were 25 unrecognized/ignored objects.
\end{verbatim}

On the top of the log file is placed small header. The list of objects
continues. Features \verb|Object type: D4h subtype: 1Ah length:  31| are
WP internals and you do not need to care with them. If the interpretation
of object is known, the bracketed symbol \verb|[Justification Full]| appear.
If the interpretation of object is known, but object cannot be converted,
the exclamation mark '!' appear before object name \verb|[!Font Times]|.
The object name is normal reveal code of recognized symbol.
Normal text is placed after objects.


\subsection{Logging of nested objects}

When WP2LaTeX parses any object nested into a main WP file, different
output might appear. That is why different internal symbol subset
must be used to understand file contents. Symbols from nested objects
are indented for better reading of logs.

\begin{verbatim}
Object type: D2 subtype:  5 length: 128 L    
  {GRtyp#F;len:6;!Start WPG l1}
  {GRtyp#2;len:4;Line Attributes}
  {GRtyp#1;len:2;Fill Attributes}
  {GRtyp#14;len:ae3b;Bitmap l2}
  {GRtyp#10;len:0;!End WPG l1}
Object type: DA subtype:  0 length: 121 L [Figure] 
\end{verbatim}

This is example of WPG graphic included inside WP file. Tho get a full
understanding of symbol meaning you should read WPG file format specification.


\newpage
\section{Warning and Error messages}

This section discusses all warning runtime output messages.

\noindent
Fatal Errors:
\begin{itemize}\setlength{\itemsep}{-1mm}
  \item \uline{Fatal: Code was badly compiled. Check types.h !!!!!}
	This error is quite serious and \WPtoLaTeX\ will not run properly.
	It might occur when \WPtoLaTeX\ is ported to new platform. Do
        suggested operation and recompile your code until this problem occurs.
  \item \uline{Fatal: Program Error. Write full bug report.}
        This error is something like General Protection Fault. Such error
        message should not appear. Please edit your makefile, recompile
        \WPtoLaTeX\ with defined symbol DEBUG (proper switch for gcc is
        -DDEBUG) and run \WPtoLaTeX\ again. Then try to trace out a buggy
        part of code from the file \verb|default.log|.
\end{itemize}


\noindent
Errors:
\begin{itemize}\setlength{\itemsep}{-1mm}
  \item \uline{Error: Bad command in table file:\%c!}
	This is a bug. Please report.
  \item \uline{Error: File \%s not found.}
	The given WordPerfect file does not exist.
  \item \uline{Error: File was badly compiled. Check types.h !}
	You probably port this program to another compiler. Some variables
	must have a unique size and thus you should fix it in the file
	types.h.
  \item \uline{Error: Log file is not completely written.}
	An error occurred while writing a .LOG file. This may be a device
	error e.g. device is full.
  \item \uline{Error: Not a WordPerfect 5.x document.}
	The given WordPerfect file was not created in the WordPerfect 5.x
	or WordPerfect 6.0.
  \item \uline{Error: Object consistency failed. Trying to ignore.}
	There are two possible problems. Either your WordPerfect file is
	corrupted or some object is not recognized correctly. If you are sure
	that your file is healthy report this, it could be a bug.
  \item \uline{Error: Path not found.}
	An invalid path was given in the name of one of the files.
  \item \uline{Error: Program Error.}
	This is a bug. Please report.
\end{itemize}

\noindent
Warnings:
\begin{itemize}\setlength{\itemsep}{-1mm}
  \item \uline{Warning: Cannot open log file \%s ..."}
	The log file cannot be opened. The program will continue normally
	without logging anything.
  \item \uline{Warning: File seems to be encrypted. Conversion may not be possible!!}
        There has been added password to the WP file. Decrypting code is
        implemented only for WP up to WP5.x and it may fail for all WP versions higher
        than WP6.x.
  \item \uline{Warning: Formula \#\%d - missing numeric argument or error in formula grammar!}
  The formula syntax is described by a set of syntax rules. All these rules form
  a formula grammar. Several rules like spacing need numerical argument. There might be
  either corrupted document or some missing rule.	The default value 0 will be emitted.
  For even deeper insight feel free to look at \verb|FmlTranslationArray| in \verb|formulas.cc|.
  \item \uline{Warning: Incorrect line with TABs on end - fixed.}
	This is a problem of your document. Found [Tab] is useless and is
	ruled out.
	\item \uline{Warning: Package "amssymb" should not be used in LaTex 2.09!}
	The package "amssymb" is available only for \LaTeX 2.0e and you want to convert
        into \LaTeX 2.09. Conversion will continue normally, but you may
	expect problems during translating converted \LaTeX\ code.
  \item \uline{Warning: Unknown argument "\%s"!"}
	You passed something wrong on your command line. Read this manual more carefully.
  \item \uline{Warning: Unknown output codepage \%s!}
	You want to use unsupported encoding.
  \item \uline{Warning: WP v 4.0 is forced. No autodetection is possible. ERRORS may occur!!!}
        Because there is no way how to check WP4.x format, you see this message.
        Everything may be OK if you really have file from WP4.x.
\end{itemize}


\newpage

\section{The package}

The \WPtoLaTeX\ package contains the following files :

\begin{description}\setlength{\itemsep}{-1mm}
  \item \verb|MAKEFILE|	    (The root makefile for wp2latex package.)	
  \item \verb|README.1ST|   (The file with basic instructions- abbreviated description of this program.)
  \item \verb|README.TXT|   (The main readme file for advertising this program.)
  \item \verb|WP2LATEX.FAQ| (File with answers to frequently asked questions.)

  \item
  
  \item \verb|STYLES.TEX\BoxedEPSF.TEX| (Additional style for including PS images.)
  \item \verb|STYLES.TEX\ENDNOTES.STY| (Additional style for processing endnotes in \LaTeX\.)
  \item \verb|STYLES.TEX\CYRACC.DEF|   (Additional package for including cyrillic characters
                                        into \LaTeX\ document.)
  \item \verb|STYLES.TEX\CYRILLIC.STY| (Additional style for including cyrillic characters
                                        into \LaTeX\ document - uses CYRACC.DEF.)
  \item \verb|STYLES.TEX\InputPS.STY|  (Additional style for including PS images.)
  \item \verb|STYLES.TEX\WP2LATEX.STY| (Style file needed by \LaTeX\ for processing.)
  \item \verb|STYLES.TEX\WASYFONT.STY| (Additional style for including characters from wasy2 font into \LaTeX\.)

  \item

  \item \verb|SOURCES.CC\|	(The directory with C++ sources.)
  \item \verb|SOURCES.CC\FORMULAS.CC| (Procedures for converting WP5.x and WP6.x formulas.)
  \item \verb|SOURCES.CC\CHARACTR.CC| (Procedures for converting extended WP characters.)
  \item \verb|SOURCES.CC\IGETTEXT.CC| (Procedures for initialize gettext translation features.)
  \item \verb|SOURCES.CC\MAKEFILE| (Makefile for C++ version under both DJGPP and Linux.)
  \item \verb|SOURCES.CC\PASS1.CC| (common procedures needed for all WP convertors during 1st pass.)
  \item \verb|SOURCES.CC\PASS1XML.H| (Prototypes for HTML and XML tags)
  \item \verb|SOURCES.CC\PASS2.CC| (procedures for PASS2)
  \item \verb|SOURCES.CC\WP2LATEX.CC| (main part of \WPtoLaTeX)
  \item \verb|SOURCES.CC\WP2LFUTI.CC| (file related functions for general usage)
  \item \verb|SOURCES.CC\WP2L_LIB.CC| (miscellaneous functions for general usage)
  \item \verb|SOURCES.CC\WP2LATEX.H| (main include file for all components of \WPtoLaTeX.)

  \item \verb|SOURCES.CC\PASS1_3.CC| (conversion module (PASS1) for Macintosh WP version 2.x, 3.x or 4.x)
  \item \verb|SOURCES.CC\PASS1_4.CC| (conversion module for WP version 4.x)
  \item \verb|SOURCES.CC\PASS1_5.CC| (conversion module for WP version 5.x.)
  \item \verb|SOURCES.CC\PASS1_6.CC| (conversion module for WP version 6.x (and also 7.x) )
  \item \verb|SOURCES.CC\PASS1ABI.CC| (conversion module for AbiWord documents)
  \item \verb|SOURCES.CC\PASS1C45.CC| (decrypter for WP4.x and WP5.x encrypted files - does not perform conversion)
  \item \verb|SOURCES.CC\PASS1MTF.CC| (MTEFF equations parser - used in >WP10, RTF and Word documents.)
  \item \verb|SOURCES.CC\PASS1OLE.CC| (procedures for parsing OLE wrapper that might contain WP6x document.)
  \item \verb|SOURCES.CC\PASS1HTM.CC| (conversion module for HTML documents)
  \item \verb|SOURCES.CC\PASS1RTF.CC| (conversion module for RTF documents)
  \item \verb|SOURCES.CC\PASS1WMF.CC| (Attempt to parse Window metafile)
  \item \verb|SOURCES.CC\PASS1WRD.CC| (Attempt to convert Word documents)
  \item \verb|SOURCES.CC\PASS1XML.CC| (Support for HTML and XML tags)
  \item \verb|SOURCES.CC\PASS1602.CC| (conversion module for Text 602 documents)
 
  \item

  \item \verb|SOURCES.CC\ATOMS|	(Additional library with some special C++ stuff like strings, sets, matrices etc.)
  \item \verb|SOURCES.CC\ATOMS\INCLUDE\COMMON.H|  (Include file with some compiler specific commands.)
  \item \verb|SOURCES.CC\ATOMS\LISTS.CC|          (Collection of procedures for operations with lists of text.)
  \item \verb|SOURCES.CC\ATOMS\INCLUDE\LISTS.H|   (The include file for tool LISTS.CC.)
  \item \verb|SOURCES.CC\ATOMS\SETS.CC|           (Collection of procedures for operations with sets.)
  \item \verb|SOURCES.CC\ATOMS\INCLUDE\SETS.H|    (The include file for tool SETS.CC.)
  \item \verb|SOURCES.CC\ATOMS\STRINGS.CC|        (Collection of procedures for operations with strings.)
  \item \verb|SOURCES.CC\ATOMS\INCLUDE\STRINGS.H| (The include file for tool STRINGS.CC.)
  \item \verb|SOURCES.CC\ATOMS\STRUCT.C|          (Procedures for endian conversion of multi-byte numbers.)
  \item \verb|SOURCES.CC\ATOMS\INCLUDE\TYPES.H|   (This include file provides fixed size numbers like BYTE, WORD, DWORD.)

  \item

  \item \verb|SOURCES.CC\CP_LIB|  (Additional library for handling and converting codepages.)
  \item \verb|SOURCES.CC\CP_LIB\WP5.ENC|	(Character positions for WP5.x)
  \item \verb|SOURCES.CC\CP_LIB\WP6.ENC|	(Character positions for WP6.x)
  \item \verb|SOURCES.CC\CP_LIB\UNICODE.ENC|	(Character positions for unicode)

  \item

  \item \verb|SOURCES.PAS\|	(The directory with the original Turbo Pascal 7.0 sources - {\bf obsolete!})
  \item \verb|SOURCES.PAS\COMMON.PAS| (Commonly used procedures)
  \item \verb|SOURCES.PAS\FORMULAS.PAS| (Unit for converting of formulas)
  \item \verb|SOURCES.PAS\PASS1.PAS| (procedures for PASS1)
  \item \verb|SOURCES.PAS\PASS1_6.PAS| (experimental procedures for PASS1 for WP version 6.0)
  \item \verb|SOURCES.PAS\PASS2.PAS| (procedures for PASS2)
  \item \verb|SOURCES.PAS\WP2LATEX.PAS| (main part of \WPtoLaTeX)

  \item

  \item \verb|DOS\WP2LATEX.EXE| (the conversion program DOS executable)
  \item \verb|OS2\WP2LATEX.EXE| (the conversion program OS/2 executable)
  \item \verb|LINUX\WP2LATEX| (the conversion program Linux ELF executable)
  \item \verb|WIN\WP2LATEX.EXE| (the conversion program MS Windows executable)
  \item \verb|WIN\BCC55.BAT| (batch file for compilation with Borland C++ 5.5)
  \item \verb|WIN\BCC55.BAT| (response file for Borland C++ 5.5)

  \item

  \item \verb|DOC\|	(The directory with documentation texts.)
  \item \verb|DOC\BUG.TXT| (The description of known bugs. Please consult this file first before you
			    will report anything.)
  \item \verb|DOC\WP2LTX.TEX|   ( Dutch (original) version of the user's guide - now obsolete)
  \item \verb|DOC\WP2LATEX.1|   (Man page for WP2LATEX program.)
  \item \verb|DOC\WP2LATEX.TEX| (This user's guide.)
 
  \item


  \item \verb|TEST\|	(The directory with testing WordPerfect files.)
  \item \verb|TEST\TEST.WP| (WP test file with mix of features)
  \item \verb|TEST\CHARACTR.WP| (WP test file with all WP charsets)
\end{description}

Four executable files are supported. One for real mode MSDOS, second
for MSWindows, third for Linux and fourth for protected DOS DJGPP.
All versions work in text mode. Using of DPMI (protected mode) version is not
necessary, because the memory requirements of this program are too small
to do this.
 DJGPP version benefits only for raster images conversion.


\subsection{Re-compilation of the code}

Because the \WPtoLaTeX\ is distributed with source code you can solve to recompile
all code. Recompilation is easy for supported systems: DJGPP and Linux.
(May be that you will succeed in others systems like Solaris, AIX
but I have no chance to test it.)

\subsubsection{Linux and other Unixes}

Type:
\verb|prompt:>./configure| Enter
\verb|prompt:>make| Enter

A {\it configure} script should do all configuration job for you in most cases.
If not, you have to solve a current problem. Please consult a WP2LaTeX.faq
file, where known compilation failures are discussed.


\subsubsection{DOS-DJGPP and GCC}

\bigskip\noindent
Enter a command \verb|make generic| followed by \verb|make|
in the \WPtoLaTeX\ directory.

\noindent
\verb|prompt:>make| Enter

After this command all source code should be completely rebuild.
The program is distributed without syntactical bugs because I will
never release a new code without testing it.

You could benefit from installing a JPG library and compile a code with
JPG support enabled. I have uploaded one snapshot of JPG library
to a \WPtoLaTeX\ homepage:
\verb|http://www.penguin.cz/~fojtik/wp2latex/wp2latex.htm| .


\subsubsection{DOS/WINDOWS and Borland C++}

Because there is freely available Borland C++ compiler, I also provide script
for building \WPtoLaTeX\ by BCC.
 Before using it please ensure that paths in the 
file \verb|bcc55.bat| are correct and also check paths inside .RSP file
.

\medskip
	
	change to directory win
\\
\verb|cd win
|\\
	execute bcc55.bat
\\
\verb|bcc55.bat
|

\subsubsection{DOS/WINDOWS and MSVC}

The project for Microsoft Visual Studio 6.0 is also distributed.

Microsoft Visual Studio 2000 and Microsoft Visual Studio 2003 are able to
open it and upgrade it to their release. If you have MSVC200 or MSVC2003
import a {\it MSVC/wp2latex.dsw} file.

You could rebuild a target {\it Win32 release} or
{\it Win32 release gettext} that has also added online translations
to foreign languages.


==============================================================

%How to build WP2LaTeX for multiple Mac OS X soft- and hardware
\subsubsection{multiple Mac OS X soft- and hardware}

First a statement from Apple: \verb|http://developer.apple.com/library/mac/#qa/qa1118/_index.html|. In
order to provide a WP2LaTeX binary with JPEG and PNG (and, coming, libintl) support we have to build
a statically linked binary. This requires the mentioned crt0.o object file. Since Mac OS X 10.6,
Snow Leopard, intel only, Apple does not provide this object file, one has to build it one-self.
This page describes it a bit: \verb|http://osdir.com/ml/xcode-users/2009-09/msg00213.html|. (You can use my
later explanations to build the perfect crt0.o file. And, actually, the Apple developers link above
leads via Xcode 3.2.6 to Csu-76.)

The absence of crt0.o and JPEG, PNG, and other libraries makes the "static" build option of WP2LaTeX
unusable on Mac OS X.

Next is to build the static JPEG (jpeg-8c; \verb|http://www.ijg.org/|, \verb|http://www.openjpeg.org/|) and PNG
(v. 1.2.44; \verb|http://www.libpng.org/pub/png/libpng.html|) libraries. Building them is necessary because
one cannot guarantee that on some remote Mac the JPEG and PNG shared libraries exist. So we have to
link them statically into the binary. The libs' configure scripts allow quite the same parameters:

\begin{verbatim}
 ./configure --prefix=/some/path/to/a/build/directory --enable-shared=no --with-pic \
 CFLAGS="-arch i386 -isysroot /Developer/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4
 -force_cpusubtype_ALL -m32 -H -pipe -fPIC -Os" \
 LDFLAGS="-L/some/path/to/a/build/directory/lib -L/some/path/to/a/build/directory/Csu-71 -arch
 i386 -Wl,-t" \ CC=gcc-4.0 CCP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0
\end{verbatim}

The backslash characters ("\") at the end of the lines above mean that the lines are broken here and
continue on the next line. They, the leading spaces, and the line breaks can be omitted when
configuring. A few compiler switches and environment settings in these lines point towards
compilation for a minimal Mac OS X version 10.4 ("Tiger"), so such a binary will (presumingly) run
on updated Tiger (with intel support integrated), Leopard, Snow Leopard, Lion, ... for which GCC 4.0
is used because its shared libraries already exist on Tiger. And it looks as if it's just the first
of a series of configurations, builds, and installations with a final step to stitch the few static
libraries to one "fat" one with lipo which can then be linked to the WP2LaTeX binary.

The problem is that starting with the updated intel only Snow Leopard the Developer package on the
Mac OS X 10.6.6 and above install DVD comes with Xcode 4 which does not support elder Mac OS X
versions than 10.6 - itself only (see for example
\verb|http://stackoverflow.com/questions/5333490/how-can-we-restore-ppc-ppc64-as-well-as-full-10-4-10-5-sdk-support-to-xcode-4/5348547|, 
\verb|http://hints.macworld.com/article.php?story=20110318050811544|). So,
with modern Apple hardware you need to install an elder Xcode version (3.2.6), available from the
Apple Developer Connection (\verb|http://developer.apple.com/|), for free, after registration. It would
overwrite the whole installation in /Developer, it overwrites in any case those parts of installed
Xcode which are installed in /usr (so you might need to reinstall Xcode 4). You might decide to
install in /Developer45 to remind you that it contains the SDKs for Mac OS X 10.4 and 10.5 (+ 10.6 +
a lot of iPhone simulators). The -isysroot compiler option then takes as argument the path to the
root of the SDK used for compilation, either as '-isysroot /Developer45/SDKs/MacOSX10.4u.sdk' or as
'-isysroot /Developer/SDKs/MacOSX10.4u.sdk'.

Before we start to build the *optimised* JPEG and PNG libraries we need to take care that we don't
overwrite previously built libraries. We need n passes, where n is the number of supported Mac OS X
architectures. So let's install the built libraries in directories named build/lib-<arch name>. In
the final step the lipo utility would combine them in build/lib or build/lib32 or build/lib64
build/lib{old|modern}. The optimisation switches for the different architectures can be:

\begin{verbatim}
 G3:     -arch ppc    -mcpu=G3 	    -m32 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk
 -mmacosx-version-min=10.4.8 -H -pipe -fPIC -pthread -Os   -mpowerpc-gfxopt G4:     -arch ppc   
 -mcpu=G4 -mtune=G4 -m32 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
 -H -pipe -fPIC -pthread -fast -mpowerpc-gfxopt -faltivec -mabi=altivec G5:     -arch ppc64 
 -mcpu=G5 -mtune=G5 -m64 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
 -H -pipe -fPIC -pthread -fast -mpowerpc-gfxopt -faltivec -mabi=altivec i386:   -arch i386  
 -march=prescott    -m32 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
 -H -pipe -fPIC -pthread -Os -msse3 x86_64: -arch x86_64 -march=nocona      -m64 -isysroot
 /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8 -H -pipe -fPIC -pthread -Os -msse3
 -mssse3
\end{verbatim}


Doing so we also perform "cross-compilation": our local host machine produces output for a foreign
architecture. With Rosetta installed (\verb|http://en.wikipedia.org/wiki/Rosetta_(software)|) compilation
for G3 and G4 targets is like native. So, here are the configure invocations on an intel based Mac
with Snow Leopard:

\begin{verbatim}
    G3:     ./configure --target powerpc-apple-darwin10.8.0   --host x86_64-apple-darwin10.8.0
    --prefix=/path/to/directory/build --libdir=/path/to/directory/build/lib-G3    
    --enable-shared=no --with-pic LDFLAGS="-arch ppc    -Wl,-dead_strip_dylibs -Wl,-bind_at_load
    -Wl,-t" CC=gcc-4.0 CPP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0 CFLAGS="-arch ppc    -isysroot
    /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8 -mcpu=G3        -m32 -H -pipe
    -fPIC -Os   -pthread -mpowerpc-gfxopt" G4:     ./configure --target powerpc-apple-darwin10.8.0  
    --host x86_64-apple-darwin10.8.0 --prefix=/path/to/directory/build
    --libdir=/path/to/directory/build/lib-G4     --enable-shared=no --with-pic LDFLAGS="-arch ppc   
    -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" CC=gcc-4.0 CPP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0
    CFLAGS="-arch ppc    -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
    -mcpu=G4        -m32 -H -pipe -fPIC -fast -pthread -mpowerpc-gfxopt -faltivec -maltivec
    -mabi=altivec -mtune=G4" G5:     ./configure --target powerpc64-apple-darwin10.8.0 --host
    x86_64-apple-darwin10.8.0 --prefix=/path/to/directory/build
    --libdir=/path/to/directory/build/lib-G5     --enable-shared=no --with-pic LDFLAGS="-arch ppc64 
    -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" CC=gcc-4.0 CPP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0
    CFLAGS="-arch ppc64  -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
    -mcpu=G5        -m64 -H -pipe -fPIC -fast -pthread -mpowerpc-gfxopt -faltivec -maltivec
    -mabi=altivec" i386:   ./configure --target i386-apple-darwin10.8.0      --host
    x86_64-apple-darwin10.8.0 --prefix=/path/to/directory/build
    --libdir=/path/to/directory/build/lib-i386   --enable-shared=no --with-pic LDFLAGS="-arch i386  
    -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" CC=gcc-4.0 CPP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0
    CFLAGS="-arch i386   -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
    -march=prescott -m32 -H -pipe -fPIC -Os   -pthread -msse3 -mfpmath=sse" x86_64: ./configure     
                                                --prefix=/path/to/directory/build
    --libdir=/path/to/directory/build/lib-x86_64 --enable-shared=no --with-pic LDFLAGS="-arch x86_64
    -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" CC=gcc-4.0 CPP=cpp-4.0 CCX=g++-4.0 LD=gcc-4.0
    CFLAGS="-arch x86_64 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8
    -march=nocona   -m64 -H -pipe -fPIC -Os -pthread -msse3 -mssse3"
\end{verbatim}

For each architecture a different target for the built library is set with "--libdir=.". The
binaries play no role, won't be used, the C header files will be used to compile WP2LaTeX later on,
but these files are independent of any hardware or OS issues, so for them it plays no role which
configure/compile/install cycle was last. So choose some hardware target to start with: first
configure accordingly (you might save the output of the configure run as well as the created
config.log file), second run make, third run 'make install', and finally 'make clean'. This ends the
cycle and you can proceed with the next hardware target. When you're through with this cycle, start
the cycle for the next library!

When all libraries are built you need to "combine" them. This is done with the lipo utility - which
does not understand the marketing names G3, G4, G5! So it's not possible to combine all three 32-bit
architectures. First we need to create the directories to save the "fat" libraries in, so let's
enter a shell and change directory ("cd") to that "build" directory (/path/to/directory/build) and
invoke:

\begin{verbatim}
 mkdir lib-old lib-new
\end{verbatim}

Now the lipo invocations to build libpng and libjpeg:

\begin{verbatim}
 lipo -create lib-G3/libpng.a lib-i386/libpng.a -o lib-old/libpng.a
 lipo -create lib-G4/libpng.a lib-G5/libpng.a lib-x86_64/libpng.a -o lib-new/libpng.a
 lipo -create lib-G3/libjpeg.a lib-i386/libjpeg.a -o lib-old/libjpeg.a
 lipo -create lib-G4/libjpeg.a lib-G5/libjpeg.a lib-x86_64/libjpeg.a -o lib-new/libjpeg.a
\end{verbatim}

So let's build WP2LaTeX finally! We'll build two binaries, one for old hardware and one for modern
hardware, similar to what is delivered as up-to-date X11. So we have to configure (and then compile)
twice:

\begin{verbatim}
     old: ./configure --without-libintl \
        CPPFLAGS=-I/path/to/directory/build/include \
   CFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions" \
 CXXFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions -fastcp -fconserve-space
 -Wno-non-template-friend" \ LDFLAGS="-L/path/to/directory/build/Csu-71
 -L/path/to/directory/build/lib-old -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t" \ CXX="g++-4.0
 -arch ppc -arch i386 -mmacosx-version-min=10.4.8 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk
 -mmacosx-version-min=10.4.8 -Xarch_ppc -Xarch_ppc -m32 -Xarch_ppc -mcpu=G3 -Xarch_ppc -mtune=G3
 -Xarch_i386 -march=prescott -Xarch_i386 -m32 -Xarch_i386 -msse3" \
  CC="gcc-4.0 -arch ppc -arch i386 -mmacosx-version-min=10.4.8 -isysroot
  /Developer45/SDKs/MacOSX10.4u.sdk -mmacosx-version-min=10.4.8 -Xarch_ppc -Xarch_ppc -m32
  -Xarch_ppc -mcpu=G3 -Xarch_ppc -mtune=G3 -Xarch_i386 -march=prescott -Xarch_i386 -m32 -Xarch_i386
  -msse3" \
 CPP="cpp-4.0"

  modern: ./configure --without-libintl \
   CPPFLAGS=-I/path/to/directory/build/include \
   CFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions -arch ppc -arch ppc64 -arch x86_64
   -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -iwithsysroot /Developer45/SDKs/MacOSX10.4u.sdk
   -mmacosx-version-min=10.4.8" \
 CXXFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions -arch ppc -arch ppc64 -arch x86_64
 -isysroot /Developer45/SDKs/MacOSX10.4u.sdk -iwithsysroot /Developer45/SDKs/MacOSX10.4u.sdk
 -mmacosx-version-min=10.4.8 -fastcp -fconserve-space -Wno-non-template-friend" \
 LDFLAGS="-L/path/to/directory/build/Csu-71 -L/path/to/directory/build/lib-new
 -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t -arch ppc -arch ppc64 -arch x86_64" \ CXX="g++-4.0
 -Xarch_ppc -faltivec -Xarch_ppc -mabi=altivec -Xarch_ppc -mcpu=G4 -Xarch_ppc -mtune=G4 -Xarch_ppc64
 -mpowerpc-gfxopt -Xarch_ppc64 -faltivec -Xarch_ppc64 -mabi=altivec -Xarch_x86_64 -march=nocona
 -Xarch_x86_64 -m64 -Xarch_x86_64 -msse3 -Xarch_x86_64 -mssse3" \
  CC="gcc-4.0 -Xarch_ppc -faltivec -Xarch_ppc -mabi=altivec -Xarch_ppc -mcpu=G4 -Xarch_ppc -mtune=G4
  -Xarch_ppc64 -mpowerpc-gfxopt -Xarch_ppc64 -faltivec -Xarch_ppc64 -mabi=altivec -Xarch_x86_64
  -march=nocona -Xarch_x86_64 -m64 -Xarch_x86_64 -msse3 -Xarch_x86_64 -mssse3" \
 CPP="cpp-4.0"
\end{verbatim}

Again the lines are broken near the backslashes and the many space characters are inserted because
of the look. This time I am not using "gcc-4.0 -E" as the C preprocessor (CPP), because -E and some
other options are not allowed when using multiple -arch settings. For educational reasons. And
because of these I also chose to show the two different methods to build real fat binaries in one
compiler run (although it makes a difference: when putting the -arch flags into CFLAGS/CXXFLAGS
instead of CC/CXX configure will set dependency style to gcc3 rather than gcc[4]; this can play a
role when -E, -S, -save-temps, or -M options are used, which is not allowed with multiple -arch
flags; -MD would need "quoting" with -Wp, or -Xarch\_<arch>). Of no educational use is the
demonstration of the Apple additions -Xarch\_<arch> (for the curious, the wrapper for GCC that Apple
uses is here: \verb|http://www.opensource.apple.com/source/gcc/gcc-5666.3/driverdriver.c|,
\verb|http://www.opensource.apple.com/source/llvmgcc42/llvmgcc42-2336.1/driverdriver.c|). These switches
separate optimising options that they apply only for the specific hardware (for example, all intel
CPUs and the G3, PPC750, do not have the Altivec extension, and no G3, G4, or G5 has intel's SSE
variations). They are similar to CFLAGS and CXXFLAGS, meant for the C language or for the C++
language.

So start building WP2LaTeX and configure now for the one target. After this invoke make. The first
target is built in wp2latex.3.56/mac (the directories 32 and 64 contain elder versions of WP2LaTeX,
either for old or for new hardware). Before starting over for the next target rename the just built
wp2latex binary to wp2latex-new or wp2latex-old or save it in the according subdirectory. Otherwise
it would be overwritten. Before configuring and compiling once more, we need to perform 'make
clean'. Now configure, make, and rename again, followed by a final 'make clean' to save disk space.
You'll have now software that will run on Tiger (Mac OS X 10.4.8 and later), Leopard, Snow Leopard,
Lion, ..., and on (approximately) five sorts of Apple hardware: G3/PowerPC 750, G4/PowerPC 74xx,
G5/PowerPC 970, i386/intel Core Solo \& Duo T1200/T2300/T2400/T2500/T2600 ("Yonah"), x86\_64/intel
Core 2 Duo T5600/T7200/T7300/T7400/T7500/T7600/T7700/T7800
("Merom")/E8135/E8235/E8335/E8435/P7350/P7450/P7550/P8400/P8600/P8700/P8800/T8100/T8300/T9300/T9400/
T9500/T9550/T9600/T9800/T9900/L9300/L9400/L9600/U9400/U9600 ("Penryn")/E7600/E8600 ("Wolfdale")/Core
i3/Core i5/Core i7 ("Nehalem", "Clarkdale", "Arrandale", "Lynnfield", "Sandy Bridge")/intel Xeon
3500/3530/3565/3680 ("Bloomfield")/intel Xeon 5100 ("Woodcrest")/intel Xeon 5300
("Clovertown")/intel Xeon 5400 ("Harpertown")/intel Xeon 5500 ("Gainestown")/intel Xeon
E5620/X5650/X5670 ("Westmere").

When you change the setting of -mmacosx-version-min=10.4.8 to some larger value, 10.5 for example,
then the software will not run on Tiger - and you won't need to compile for the G3. It's support
ended with Mac OS X 10.4.11. So you could build a real 32-bit WP2LaTeX, supporting G4 and i386, a
real 64-bit WP2LaTeX, supporting G5 and x86\_64. And starting with Mac OS X 10.6, Snow Leopard, you
can remove the G4 and G5 support, it's intel only. Then it's probably useful to do it like Apple and
create one combined i386/x86\_64 binary. Similarly when you reduce the features of the binaries you
have to reduce the features of JPEG, PNG and other libraries.


% ==================================================================
% How to build (native) WP2LaTeX for one Mac OS X soft- and hardware
\subsubsection{one Mac OS X soft- and hardware}

The multiple case is clearly meant to make a software that can be easily distributed. In the simple
case you can use the shared or dynamic libraries ("dylibs") from your system, as installed by any
means: manually, by some package manager, otherwise (in some DMG or such archive format). All you
need to do is to tell the configure script where the C header files and the (proper) shared
libraries can be found. For example:

\begin{verbatim}
 ./configure LDFLAGS=-L/sw/lib CPPFLAGS=-I/sw/include
\end{verbatim}

There is one problem, that your compiler can be set to produce a 64-bit binary while the libraries
are only 32-bit or it's set to produce a 32-bit binary by default and the libraries are 64-bit.
Apple installs with Tiger, Leopard, and Snow Leopard "fat" libraries, libraries that have built-in
support for a handful of architectures, as I described in the multiple case, so compilation will
always work with the system binaries, i.e., everything but JPEG, PNG, and libintl support. If you do
not have their libraries and C header files already installed you need to perform this yourself.
Similarly as described for the multiple systems case you have the choice of 32-bit or 64-bit support
and their appropriate compiler options, degree of optimisation. Configure, make, and install these
auxiliary libraries. You don't need to care whether they are 32-bit or 64-bit, they will be the same
as the WP2LaTeX binary, so you can install directly in /some/path/to/a/build/directory/lib. If
necessary correct the settings of LDFLAGS and CPPFLAGS as given before. Now decide for WP2LaTeX
which CFLAGS and CXXFLAGS you want to use. If you wish to set a particular level of optimisation you
need to include the --enable-extra-optimization=no and --enable-optimization=no configure options,
otherwise configure will add -O2 to the compiler switches. The configure invocation could be:

\begin{verbatim}
 ./configure \
 CPPFLAGS=-I/path/to/directory/build/include \
   CFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions <more options>" \
 CXXFLAGS="-H -pipe -fPIC -pthread -fast -fno-exceptions <more options> -fastcp -fconserve-space
 -Wno-non-template-friend" \
  LDFLAGS="-L/some/path/to/a/build/directory/lib -Wl,-dead_strip_dylibs -Wl,-bind_at_load -Wl,-t"
\end{verbatim}

Since you're building native libraries and a native WP2LaTeX binary you don't need to specify
compilers and linkage editor (LD), but you can, to make a specific choice of a compiler (beware:
clang/clang++ might fail). The native build bring one problem to daylight: the compiler will spit
out hundreds of warnings! They are only warnings. They are not errors. They will allow that the
binary gets built (hopefully). And you are warned now that you might see what you don't expect to
see.

I was recommending compiler switches that produce a lot of output. -H makes the compiler report all
C header files it reads which it tries to process the C or C++ source file. Using this option allows
you find whether some C header is used that is supposed not to be used because it can produce
errors. You can safely omit this switch when every things works fine. The -t switch, meant only for
ld and therefore targeted with -Wl, so that it reads completely -Wl,-t, makes ld (gcc in case of GCC
used in all stages) report all object files (*.o) and all libraries (*.a or *.dylib) it links to
create the final binary. It helps to debug the build process, it can also safely be omitted when
everything compiles fine.


%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%

\subsection{Compile options}

You could control tradeoff size over speed by configure script a little bit.

Use \verb|./configure --enable-extra-optimization=size| to optimize for
size. This option shrink executable by 3\% (measured with gcc-3.0.4).
I hope that normal user might prefer this option.

Use \verb|./configure --enable-extra-optimization=speed| to optimize for
speed. This option generates fastest executable that is 5.5\% bigger.
When you are using WP2LaTeX for automatical batch conversion this option might
help you a little bit. Safe mode and output messages also slow down
conversion time.


\subsection{Modularity of the code}
\label{modules}

The current release of \WPtoLaTeX\ is quite big > 400kb. But from now
you could shrink size of code a lot. \WPtoLaTeX\ consists from separate
conversion modules that do not need to be all included in the code.

If you do not need some module, simply comment out it the makefile and relink
\WPtoLaTeX\ . Everything should work fine without recompilation of another
conversion modules.

\medskip

\begin{verbatim}
OBJECTS+=pass1_1$(OBJ)
OBJECTS+=pass1_3$(OBJ)
OBJECTS+=pass1_4$(OBJ)
OBJECTS+=pass1_5$(OBJ)
OBJECTS+=pass1_6$(OBJ)
OBJECTS+=pass1c45$(OBJ)
OBJECTS+=pass1ole$(OBJ) cole/new_cole$(OBJ)

## codepage library for HTML & RTF ##
OBJECTS+=cp-trn$(OBJ)
#conversion module for HTML
OBJECTS+=pass1_ht$(OBJ)
#conversion module for RTF
OBJECTS+=pass1rtf$(OBJ)
#conversion module for T606
# T602 parser ##
OBJECTS+=pass1602$(OBJ)
\end{verbatim}

\medskip

Orientational values of module sizes:

\smallskip

\begin{center}
\begin{tabular}{|l|l|r|r|c|} \hline
 Module name   & Purpose               & code size  & data size & results \\ \hline
 PASS1ABI.CC   & Abiword               & (\dag) 5731 &     488  & moderate \\ \hline
 PASS1C45.CC   & encrypted WP4 and WP5 &      3395  &      323  & decrypts all \\ \hline
 PASS1CDCB.CC  & Docbook               &      3171  &      353  & experimental \\ \hline
 PASS1RTF.CC   & Rich Text File        & (+) 16620  & (+) 2247  & moderate \\ \hline
 PASS1\_1.CC   & WP1.x for MAC         &      3564  &      695  & experimental\\ \hline
 PASS1\_3.CC   & WP2,3,4.x for MAC     &     10107  &     2567  & moderate\\ \hline
 PASS1\_4.CC   & WP4.x                 &      9046  &      685  & good \\ \hline
 PASS1\_5.CC   & WP5.x and WPG         &     16583  &     1335  & excellent \\ \hline
 PASS1\_6.CC   & WP6.x - WP12.x        &     26751  &     2761  & excellent \\ \hline
 PASS1OLE.CC   & OLE Wrapper           & (*)  1068  & (*)  138  & extracts all\\ \hline
 PASS1\_HT.CC  & HTML and Accent       & (+\dag) 12708 & (+) 3332 & moderate \\ \hline
 PASS1602.CC   & Text 602              & (+)  3464  & (+)  278  & good \\ \hline
 PASS1WRD.CC   & MS Word (unfinished)  & (*) 11970  &      774  & bad \\ \hline
 PASS1MTF.CC   & Math Type Equation    &       8053 &     8767  & good \\ \hline
\end{tabular}

\end{center}

\smallskip
(*) Require cole library  (code+6697 :data+18)  \\
(+) Require cp\_trn module (code+357  :data+24665) \\
(\dag) Require XML module (code+1983  :data+13)

\medskip

For example:
you want to convert only WP5 documents so you will save\\
$
(1907+285) + (10537+1740) + (2988+352) + (8629+581) +
(698+121 + 6697+18) +
(24685+1961) + (12708+3332) + (3580+281) +
 = 106122
$

It means that final code will be about 106kb shorter in this case.

Please note also conversion results. Some modules are mature enough and
some are only experimental. You could try this convertor e.g. for Microsoft
Word and look for another convertor, if you are not satisfied with results
attained.



\subsection{Support for gettext library}

This feature allows to internationalize programs by translating their
messages into your native language. The code of \WPtoLaTeX\ was modified
to support this library. If you do not have it, comment the line
\verb|GETTEXT=-D__gettext__| in the \verb|makefile|. Otherwise you will
not able to successfully compile.

\begin{verbatim}
# Uncomment next line for allowing a gettext multilanguage translation features
# This feature is not required for successful run of WP2LaTeX.
GETTEXT=-D__gettext__
\end{verbatim}

\subsection{Debugging version of \WPtoLaTeX}

If you have problems with run of the \WPtoLaTeX\ you can solve to
create debugging version. The comment in makefile should be
clear for explanation.

\begin{verbatim}
# Uncomment next line for compile a debugging version of WP2LaTeX
# DEBUG=-DDEBUG -g
\end{verbatim}

The debugging version logs all function calls so that big .LOG file can
be created. Use this feature only if you really want to debug because
it slows down all code.


\section{Copyright}

This program can be redistributed and/or modified under the terms
of the GNU General Public License version 2 available from
\verb|http://www.gnu.org/copyleft/gpl.html|. If anybody makes any change to this
package, I am asking him to explicitly write that his package
differs from original package.

Current copyright could be obtained by typing wp2latex -copyright.
WP2LaTeX contains several libraries, that have different 
licencing models.

\begin{itemize}
\item{wvParser} GPL Originally obtained from Word View by Caolan.McNamara@ul.ie
	This library could be compiled out - see \ref{modules}.
\item{Atoms} LGPL written by me
\item{Localiser} LGPL obtained from libc.
\item{endnotes.sty} Freeware by John\_Lavagnino@Brown.edu
\end{itemize}

It is also possible to buy commercial version that 
is GPL free.


\section{Conclusion}

The 100\%-correct conversion of a WordPerfect-document is not guaranteed.
Error messages can always appear during processing by \LaTeX.  Some
adjustments to the generated \LaTeX\ file will in many cases be necessary.

The following were given the highest priority :
\begin{itemize}
  \item preventing the loss of text
  \item avoiding program crashes
\end{itemize}
\nwln

Because the sources are included in portable C++ language it should not be
too difficult modifying the program.

The file formats we used for our program were found in the WordPerfect
Developer's Toolkit. 

If you have remarks or comments regarding the program, you can send them
to:

\vspace{1cm}

\newcommand{\DotCZ}{.cz} %I hate automatical Email extraction
Jaroslav Fojt\'{\i}k\\
Email: fojtik@penguin\DotCZ\ (my new Email)\\
       fojtik@htc.honeywell\DotCZ\ (might be invalid after 8/1/2005) \\
   or: fojtik@cmp.felk.cvut\DotCZ\ (this may be invalid after 2000, but still works in 2005 :-)))

\medskip

\begin{minipage}[t]{6cm}
Post Address:
\\
Jaroslav Fojtik\\
Dvouramenna 13
\\
Praha 4 - Podoli\\
140 00
\\
Czech Republic
\end{minipage}


\medskip

Before doing this please visit my www page and test recent version:\\
http://www.penguin.cz/\~{}fojtik/wp2latex/

\bigskip

I have found that all addresses of previous authors are not currently valid.\\
\begin{minipage}[t]{6cm}
R.C. Houtepen \\
Brusselstraat 150 \\
4826 NK Breda \\
The Netherlands \\
Tel: 076-714777
\end{minipage}
\hfill or \hfill
\begin{minipage}[t]{6cm}
\raggedleft
R.L.M. Helwig \\
Eindhoven University of Technology \\
P.O. BOX 513\\
5600 MB Eindhoven\\
The Netherlands \\
Tel: 040 - 472724\\
\nwln
uucp : rcronh@urc.tue.nl\\
bitnet : rcronh@heitue5
\end{minipage}


\newpage
\nwln
\begin{center}
(This page is intentionally left blank for notes.)
\end{center}
\nwln
\end{document}
