% latex4jed.tex   -*- LaTeX -*-
%
% By Guido Gonzato, guido.gonzato@univr.it
%
% Date: 20 February 2004

\documentclass[11pt]{article}
\usepackage{alltt}
\usepackage{texnames}
\usepackage[colorlinks,urlcolor=blue]{hyperref}

% -----

\newcommand{\version}{1.4.4}
\newcommand{\bl}{\textbackslash{}}
\newcommand{\key}[1]{\texttt{$\langle$#1$\rangle$}}
\newcommand{\chr}[1]{\texttt{`#1'}}

% doesn't it deserve its very own logo?
\def\LJ{\LaTeX\kern-.2em\raise.5ex\hbox%
{\sc 4}\kern-.2em\textsc{Jed}}

% -----

\begin{document}

\title{\LJ: an enhanced \LaTeX{} mode for Jed}

\author{Version \version\\
Guido `goccia' Gonzato, Ph.D.\\
\url{guido, dot, gonzato, at, univr, dot, it}}

\date{Universit\`a di Verona (Italy)\\
Facolt\`a di Scienze MM. FF. NN.\\
\today}

\maketitle

\begin{abstract}
  The Jed editor supports several programming languages and text formats,
  including \LaTeX. However, the author of this document feels that the
  default library file \texttt{latex.sl} is too simple, and that it could be
  improved in many ways.

  This document describes an enhanced \texttt{latex.sl}, which aims at
  making the process of writing \LaTeX{} documents an easy and pleasant
  task. Inspired by Emacs' AUC-\TeX, the new \texttt{latex.sl} provides
  the user with menus, templates, many utilities, and integrated
  conversion and previewing of \LaTeX{} documents.
\end{abstract}

\small
\tableofcontents
\listoftables
% \listoffigures
\normalsize

% -----

\section{Introduction}

Many \TeX{}nicians use \texttt{emacs} or \texttt{vim}. Both are great
programs with excellent \LaTeX{} support: AUC-\TeX.

However, for several reasons many people prefer other editors. I use a
fast and compact \texttt{emacs} clone called Jed,
\url{http://www.jedsoft.org/jed}. It can be customised and extended using
S-Lang, an easy-to-learn language similar to C. Jed supports a variety of
programming modes, with syntax highlighting and other facilities; \LaTeX{}
support is provided by \texttt{latex.sl} and other S-Lang files included
in the distribution.

I feel that the default implementation of \texttt{latex.sl} is far behind
AUC-\TeX, and that it could be improved in many ways. When I write code or
documentation, I discipline myself to follow the so-called `Goccia's
Rules':

\begin{enumerate}

  \item the program \emph{should} be as helpful as possible, but
  \item it \emph{must not} stand in the way; therefore,
  \item it \emph{should} be fully customisable, and 
  \item it \emph{should} be usable by experts and newbies alike.

\end{enumerate}

In my opinion, \texttt{latex.sl} breaks Goccia's Rules 1 and 4. It should
attempt to be more useful, especially for \LaTeX{} beginners.

J\o rgen Larsen \url{<jl@dirac.ruc.dk>} wrote a much better
implementation, available from \url{http://dirac.ruc.dk/~jl/jed/}. I
initially added menus to his mode, but as its development proceeded I lost
sync with it. Many ideas of my implementation were taken from J\o rgen's;
I suggest that you check it out.

I eventually decided to roll my own \texttt{latex.sl}: from now on, \LJ.
It was developed on Linux, but it also works and other Unix systems and
even Windows. It was tested on a RedHat 7.3 GNU/Linux box with te\TeX, and
under Windows 98 with MiK\TeX.

The latest version of \LJ{} is \version, it works with Jed 0.99.15
upwards, and is available from CTAN mirrors; for example,\\
\url{http://www.ctan.org/tex-archive/support/jed}.

% -----

\section{Installing \LJ}

In the following, I assume that you have a working installation of Jed.

% -----

\subsection{As Superuser}

First of all, make a backup copy of \path{$JED_ROOT/lib/latex.sl}. In the
event you don't like \LJ{}\footnote{unlikely \texttt{:-)}}, you'll be able to
restore the original file. However, I'm pretty sure you will not roll
back{\ldots}

Copy \texttt{latex.sl} and \texttt{latex.hlp} to \path{$JED_ROOT/lib}.
Optionally, create \path{$JED_ROOT/lib/latex} and copy the modules
\texttt{prosper.sl} and \texttt{notice.sl} there. More details on modules
are given in Section~\ref{sec:modules}.

Finally, add these lines to your \texttt{.jedrc}:

{\small
\begin{verbatim}
add_mode_for_extension ("latex", "tex");
enable_dfa_syntax_for_mode ("LaTeX");
\end{verbatim}
}

For a system-wide installation, edit the lines above in the file
\path{$JED_ROOT/lib/jed.rc}.

I \emph{recommend} that you create the DFA\footnote{the regular
expression-based highlighting scheme.} cache table. If you don't, the DFA
table will be slowly created each time you start Jed on a \LaTeX{}
document. It could take \emph{minutes}!

As root, add \texttt{latex.sl} to the list in the file
\texttt{preparse.sl}, then run the command:

{\small
\begin{verbatim}
jed -batch -n -l preparse
\end{verbatim}
}

This step may be required each time you update \LJ{} to a new version.

% -----

\subsection{As Normal User}

If you don't have one, create a personal Jed library directory; for
example,

{\small
\begin{verbatim}
$ mkdir /home/myself/myjedlib
\end{verbatim}
}

then copy \texttt{latex.sl} to this directory and add these lines to your
\texttt{.jedrc}:

{\small
\begin{verbatim}
variable Jed_Home_Library = "/home/myself/myjedlib";
set_jed_library_path (Jed_Home_Library + "," +
                      get_jed_library_path());
Jed_Highlight_Cache_Dir = Jed_Home_Library;
add_mode_for_extension ("latex", "tex");
enable_dfa_syntax_for_mode ("LaTeX");
\end{verbatim}
}

Jed will now find and use the new \texttt{latex.sl} instead of the default
library file. The highlight cache will be built automatically the first time
you use \LJ; a Jed update will not affect your private installation.

% -----

\subsection{Note for Windows Users}

\LJ{} can be used with Jed for the DOS console, but it gives its best with
\texttt{wjed}. However, as of Jed 0.99.16 \texttt{wjed} will not use
standard menus unless you modify \path{$JED_ROOT/lib/os.sl}. Lines 33--34
read:

{\small
\begin{verbatim}
%. "menus" evalfile pop         %  Uncomment to enable text menus
. "wmenu.sl" evalfile pop     %  Uncomment to enable GUI menus
\end{verbatim}
}

It should be the opposite: uncomment out line 33 to enable text menus, and
comment out line 34. Wjed will now show the \textsf{Mode} menu.

% -----

\subsection{Caveat}

By default, \LJ{} is incompatible with folding mode because of clashing
\texttt{Ctrl-Cf} key binding. Unless you're prepared to change the key
bindings in \texttt{folding.sl}, you can solve the problem setting this
variable in your \texttt{.jedrc}:

{\small
\begin{verbatim}
variable LaTeX_Font_Key = "n";
\end{verbatim}
}

which will make all font operations start with \texttt{Ctrl-Cn} instead of
\texttt{Ctrl-Cf}.

% -----

\subsection{Colours}

Obviously, \LJ{} looks better with \texttt{xjed} and \texttt{wjed}. Three
nice colour schemes are provided: \texttt{elegant.sl}, \texttt{modern.sl},
and \texttt{night.sl}. If you wish, copy them to
\path{JED_ROOT/lib/colors/Xjed/}. If you want or need to use plain console
\texttt{jed}, add this line to your favourite colour scheme (e.g.
\path{JED_ROOT/lib/colors/blue2.sl}):

{\small
\begin{verbatim}
set_color ("keyword2", "brightgreen", $2); % other keywords
\end{verbatim}
}

I suggest that you insert these lines in \texttt{.jedrc}:

{\small
\begin{verbatim}
#ifdef WINGUI
set_color_scheme ("Xjed/night");
#elifdef XWINDOWS
set_color_scheme ("Xjed/modern");
#else
set_color_scheme ("blue2");
#endif
\end{verbatim}
}

Hereafter, I shall assume that you run Jed in Emacs emulation mode. All
key bindings will start in \texttt{Ctrl-C}; users who prefer IDE mode will
use \texttt{Ctrl-Z} instead. I also remind you that all operations can be
interrupted with \texttt{Ctrl-G}.

% -----

\subsection{Customisation}
\label{sec:custom}

The user can customise \LJ{} changing the value of its variables. Insert
lines like the following in your \texttt{.jedrc}. Default values are
shown:

{\small
\begin{verbatim}
variable LaTeX_Default_Output = 
               "dvi"; % or: "ps", "eps", "dvipdf", "pdf"
variable LaTeX_Indent = 2;
variable LaTeX_Article_Default_Options = "a4paper,12pt";
variable LaTeX_Book_Default_Options = "twoside,11pt";
variable LaTeX_Letter_Default_Options = "a4paper,12pt";
variable LaTeX_Report_Default_Options = "twoside,12pt";
variable LaTeX_Slides_Default_Options = "a4paper,landscape";
variable LaTeX_Default_Language = "italian,english" % for Babel
custom_variable ("LaTeX_Rerun", "y"); % for xrefs
#ifdef WIN32
variable LaTeX_View_Dvi_Command = "yap";
variable LaTeX_View_Ps_Command = "gsview32";
variable LaTeX_View_Pdf_Command = "gsview32";
variable LaTeX_Print_Command = "gsview32";
variable LaTeX_Clearup_Cmd, "del *.out *.aux *.lo? *.to?";
variable LaTeX_Modules_Dir, JED_ROOT + "\\lib\\latex\\";
#else
variable LaTeX_View_Dvi_Command = "xdvi";
variable LaTeX_View_Ps_Command = "gv -watch";
variable LaTeX_View_Pdf_Command = "xpdf -z width";
variable LaTeX_Print_Command = "lpr";
variable LaTeX_Clearup_Cmd = "/bin/rm -f *.out *.aux *.lo? *.to?";
variable LaTeX_Modules_Dir = JED_ROOT + "/lib/latex/";
#endif
\end{verbatim}
}

Windows users must make sure that all auxiliary programs are in the PATH.

The name and purpose of these variables should be self-explanatory. For
example, \texttt{LaTeX\_Rerun} specifies whether
(\texttt{pdf})\texttt{latex} should be rerun to resolve all cross
references. If you don't want to delete temporary files after the
\texttt{latex} run(s), set \texttt{LaTeX\_Clearup\_Cmd} to ``'' (empty
string).

You can further customise \LJ{} adding a \texttt{latex\_mode\_hook}
function to \texttt{.jedrc}. For instance, I want to type accented letters
on my Italian keyboard, and get the right \TeX{} sequence. So I added this
function:

{\small
\begin{alltt}
define latex_mode_hook ()
\{
  set_abbrev_mode (1);
  if ( () = abbrev_table_p ("LaTeX") )
    use_abbrev_table ("LaTeX");
#ifdef WIN32
  % prevent clash with movement keys
  undefinekey ("\`a\`a", "LaTeX-Mode");
  definekey (" \bl\bl`a", "\`a\`a", "LaTeX-Mode");
#else
  local_setkey (" \bl\bl`a",     "\`a");
#endif
  local_setkey (" \bl\bl'e",     "\'e");
  local_setkey (" \bl\bl`e",     "\`e");
  local_setkey (" \bl\bl`\bl\bl{}i\{\}", "\`\i");
  local_setkey (" \bl\bl`o",     "\`o");
  local_setkey (" \bl\bl`u",     "\`u");
\}
\end{alltt}
}

Sometimes, the defaults you set in \texttt{.jedrc} are not appropriate for
the current editing session. In that case, you can temporarily change the
values of the variables using the \textsf{Mode/\-Customise Defaults} menu
entry.

% -----

\section{Editing \LaTeX{} Documents}

% -----

\subsection{Main Features of \LJ{}}

As of version \version, \LJ{} has the following features:

\begin{itemize}
  \item thoroughly menu-driven 
  \item advanced DFA syntax highlighting
  \item full integration with external programs
  \item templates
  \item modules
  \item document structure
  \item integrated debugging
  \item symbol completion
  \item many commands to write \LaTeX{} sources in less time.
\end{itemize}

Available key bindings are shown in the \textsf{Mode} menu entries, and
were defined in a (hopefully) intuitive and consistent manner. Some examples
are \texttt{Ctrl-Css} (or \texttt{Ctrl-C Ctrl-S Ctrl-S}) for
\textsf{Mode/\-Sections/\-\textbackslash{}section}, \texttt{Ctrl-Cec} for
the \texttt{center} environment, and so on.

Thanks to this arrangement, this guide contains only one table of key
bindings: Table~\ref{tab:keys}. In most cases, it's much simpler to read
the menus!

There is another important feature you'll want to use. Most commands are
\emph{region-or-word aware}. For example, if a region is defined and you
select \textsf{Mode/\-Environments/\-center}, that region will be included
in a \texttt{center} environment. If the cursor is positioned on a word
and you select \textsf{Mode/\-Font/\-\textbackslash{}emph}, the word will
be included in a \texttt{\textbackslash{}emph} command.

\begin{table}[htbp]
  \centering
  \small
  \begin{tabular}{ll}
  \hline
  \textbf{Keybinding} & \textbf{Action} \\
  \hline
  \texttt{Ctrl-C\key{Left}} & go to previous paragraph\\
  \texttt{Ctrl-C\key{Right}} & go to next paragraph\\
  \texttt{Ctrl-C\&} & \bl\texttt{\&}\\
  \texttt{Ctrl-C\$} & \bl\texttt{\$}\\
  \texttt{Ctrl-C\#} & \bl\texttt{\#}\\
  \texttt{Ctrl-C\%} & \bl\texttt{\%}\\
  \texttt{Ctrl-C(} & \bl\texttt{\{}\\
  \texttt{Ctrl-C)} & \bl\texttt{\}}\\
  \texttt{Ctrl-C\_} & \bl\texttt{\_}\\
  \texttt{Ctrl-C\textless} & \bl\texttt{textless\{\}}\\
  \texttt{Ctrl-C\textgreater} & \bl\texttt{textgreater\{\}}\\
  \texttt{Ctrl-C\textasciicircum} & \bl\texttt{textasciicircum\{\}}\\
  \texttt{Ctrl-C\textasciitilde} & \bl\texttt{textasciitilde\{\}}\\
  \texttt{Ctrl-C\textbackslash} & \bl\texttt{textbackslash\{\}}\\
  \texttt{Ctrl-C\textbar} & \bl\texttt{textbar\{\}}\\
  \texttt{Ctrl-C\{} & \texttt{\{\}}, region or word aware\\
  \texttt{'} or \texttt{"} & smart quotes\\
  \texttt{Ctrl-C'} or \texttt{Ctrl-C"} & 
  smart quotes, region or word aware \\
  \texttt{...} & \texttt{\{\bl ldots\}}\\
  % arrows
  \texttt{<-} & \texttt{\{\bl leftarrow\}}\\
  \texttt{<=} & \texttt{\{\bl Leftarrow\}}\\
  \texttt{< --} & \texttt{\{\bl longleftarrow\}}\\
  \texttt{< ==} & \texttt{\{\bl Longleftarrow\}}\\
  \texttt{< ->} & \texttt{\{\bl leftrightarrow\}}\\
  \texttt{< =>} & \texttt{\{\bl Leftrightarrow\}}\\
  \texttt{->} & \texttt{\{\bl rightarrow\}}\\
  \texttt{=>} & \texttt{\{\bl Rightarrow\}}\\
  \texttt{-->} & \texttt{\{\bl longrightarrow\}}\\
  \texttt{==>} & \texttt{\{\bl Longrightarrow\}}\\
  \texttt{|->} & \texttt{\{\bl mapsto\}}\\
  \texttt{|-->} & \texttt{\{\bl longmapsto\}}\\
  \texttt{Ctrl-Ce}\key{TAB} & 
  insert environment, with completion\\
  \texttt{Ctrl-Cf}\key{TAB} & 
  insert font, with completion\\
  \texttt{Ctrl-Ch} & info help on word\\
  \texttt{Alt-}\key{TAB} or \texttt{Alt-V} & symbol completion\\
  \texttt{TAB} & indent line\\
  \texttt{ESC 1}\key{TAB} & unindent line\\
  \texttt{Ctrl-C[} & start environment\\
  \texttt{Ctrl-C]} & close environment\\
  \texttt{ESC 1}\key{cmd} & command, long form\\
  \texttt{Ctrl-C}\key{RET} & new \texttt{\bl item} line\\
  \texttt{F8} & preview document\\
  \texttt{F9} & run (pdf)\texttt{latex}\\
  \hline
  \end{tabular}
  \caption{Key bindings not available in menu entries.}
  \label{tab:keys}
\end{table}

% -----

\subsection{Getting Started}

Start a new document, say \texttt{newfile.tex}. The \texttt{.tex}
extension will automatically invoke \LJ, which can also be started on any
buffer typing \texttt{Alt-X latex\_mode}. See also the
\textsf{Buffers/\-Select Mode} menu.

The \textsf{Mode} menu contains many entries and sub-menus, and it also
indicates the key bindings when available. You'll want to browse through
the menus, especially if you're not a \LaTeX{} expert. 

Now select \textsf{Mode/\-Templates/\-Article} to create an article
template. Fill it with some text: add a couple of sections, some
environments, change the fonts, and so on. Let \LJ{} help you:
use the menus, but try and memorise the key bindings. Note the syntax
highlighting of keywords and other \LaTeX{} elements.

When you're finished, typeset your document using \textsf{Mode/\-Compose}.
\texttt{latex} will be run on your document, and if no errors occur the
file \texttt{newfile\-.dvi} will be created. If errors do occur, please
read Section~\ref{sec:composing}.

Now select \textsf{Mode/\-View} to preview your document. Et voil\`a, all
done, without ever using the command line!

% -----

\subsection{Directory Independence}

You don't have to start Jed in the same directory where your \LaTeX{}
files are kept. When you begin editing a file, \LJ{} takes note of its
parent directory. All subsequent operations will be performed from
there. As a result, if your file includes external files of figures,
everything will work as expected.

% -----

\subsection{Editing Compressed Files}

Jed has the ability to edit compressed files. To enable this feature,
insert this line in \texttt{.jedrc} or \texttt{jed.rc}:

{\small
\begin{verbatim}
auto_compression_mode ();
\end{verbatim}
}

\LJ{} works on compressed files with no problems, but obviously it cannot
deal with compressed external figures or \texttt{\textbackslash{}include}d
parts. Editing compressed files may be useful on low-resource machines.


% -----

\subsection{\LaTeX{} Info Help}

On Linux and other Unix-like systems, the \LaTeX{} Info pages are surely
installed. Check out typing \texttt{info latex} at the shell prompt.

\LJ{} integrates with the Info pages. If you wish to get some
help on a \LaTeX{} command or keyword, place the cursor on that word and
press \texttt{Ctrl-Ch}. If the word is covered in the Info pages, the
relevant info page will be loaded. Press \key{q} to quit the Info page.

% -----

\subsection{Symbol Completion}

This feature was borrowed by the old \texttt{latex.sl}. If you start
typing a \LaTeX{} keyword and type \texttt{Alt-}\key{TAB}, the keyword
will self complete. Type \texttt{Alt-}\key{TAB} again to cycle through
possible completions. For example, after typing
\texttt{\textbackslash{}bib} you'll cycle through
\texttt{\textbackslash{}bib\-item[]\{\}},
\texttt{\textbackslash{}biblio\-grapy\{\}}, and
\texttt{\textbackslash{}biblio\-grapy\-style\{\}}.

Under X11, the window manager may reserve \texttt{Alt-}\key{TAB} for
itself, and MS Windows uses this key binding to switch between tasks. In
that case, use \texttt{Esc-}\key{TAB}.

% -----

\subsection{Indentation}

\LJ{} uses a kind of `preventive indentation' scheme: it tries to save you
from hitting the \key{TAB} key to indent the line.

Normally, a new line starts at the same column as the line above, but
lines within environments are indented. For example, start a
\texttt{center} environment with \texttt{Ctrl-Cec}: the text will be
indented by the amount specified by the variable \texttt{LaTeX\_Indent}.
The default is 2 columns, but it can be changed as seen in
Section~\ref{sec:custom}.

If you want to force an indented line, press the \key{TAB} key. This will
simply indent the line by \texttt{LaTeX\_Indent}, regardless of the
current environment. \texttt{ESC 1}\key{TAB} will unindent a line,
provided that the line starts with the adequate number of spaces.

Finally, if you're editing messy \LaTeX{} sources\footnote{not written with
Jed, obviously ;-)}, you can indent environments with \texttt{Ctrl-CeD}.

% -----

\subsection{Environments}

Environments can be entered via the \textsf{Mode/\-Environments} menu.
This method will provide the right indentation for both the environment
and the text it encloses.

Another way to start a new environment is typing \texttt{Ctrl-C[}. You'll
be prompted for the environment name, and the
\texttt{\textbackslash{}begin{}} line will be inserted. When you're done,
close the environment with \texttt{Ctrl-C]}.

Environments can be renamed via the \textsf{Mode/\-Environments/\-reName}
menu entry or its corresponding key binding, provided that the cursor is
within an environment.

% -----

\subsubsection{Using a Prefix}

Some environments and commands use optional parameters. By default, menu
entries and key bindings produce the command without the optional part.
Goccia's rule 1 is obeyed, but what about rule 2?

Using a \emph{prefix} (shortly, pressing \texttt{ESC 1} before any other
key binding) will insert a more complete form. For example, if you press
\texttt{Ctrl-Cpl} you will get
\texttt{\textbackslash{}includegraphics\{\}}, while pressing \texttt{ESC 1
Ctrl-Cpl} you will get
\texttt{\textbackslash{}in\-clu\-de\-gra\-phics%
[scale=\textbar{}width=\textbar{}height=]\{\}}.

% -----

\subsubsection{Itemize}

In \texttt{itemize} or \texttt{enumerate} environments you can use
\texttt{Ctrl-C}\key{RET} to start a new \texttt{\textbackslash{}item}
line.

% -----

\subsubsection{Tables}

\LJ{} makes it easier to write tables. When you start a
\texttt{table} or \texttt{tabular} environment, you'll be prompted for the
number of columns, then a table template will be inserted.

The \textsf{Mode/\-Environments/\-table row} menu entry will insert a line
containing the right number of \texttt{\&} delimiters, and terminated by
\texttt{\textbackslash{}\textbackslash{}}. Just fill in the blanks.

% -----

\subsection{Templates}

Templates for standard \LaTeX{} document classes: \texttt{article},
\texttt{book}, \texttt{letter}, \texttt{report}, and \texttt{slides}, are
provided. In addition, templates for notices and for Prosper presentations
(\url{http://prosper.sourceforge.net}) were added as modules (see
below) for your convenience. The latter lets you write a presentation in
minutes!

The most commonly used packages are also listed in the 
\textsf{Mode/\-Templates/\-Packages} sub-menu. The listed packages were
chosen after some statistics on several \LaTeX{} documents.

% -----

\subsection{Modules}
\label{sec:modules}

\LJ{} has a modular structure, so that its functionality can be enhanced
as needed. Additional modules can be written by the user as S-Lang files
and must reside in \texttt{LaTeX\_Modules\_Dir}. This directory is
\path{$JED_ROOT/lib/latex} by default, but the user can choose his or her
directory in \texttt{.jedrc}:

{\small
\begin{verbatim}
variable LaTeX_Modules_Dir = "/home/guido/.jedmodules/";
\end{verbatim}
}

Writing modules is very simple, even if you are not an S-Lang expert.
There you are a template:

{\small
\begin{verbatim}
% mymodule.sl
define mymodule_fun1 ()
{
  % your code here
}
define mymodule_fun2 ()
{
  % your code here
}
% ... more code...
$1 = "LaTeX-Mode";
$2 = "Global.M&ode.Modules.mymodule";
% optional keybindings
definekey_reserved ("mymodule_fun1", "t1", $1);
definekey_reserved ("mymodule_fun2", "t2", $1);
% optional menus
menu_append_item ($2, "mymodule fun&1", "mymodule_fun1");
menu_append_item ($2, "mymodule fun&2", "mymodule_fun2");
% end of file mymodule.sl
\end{verbatim}
}

Version \version{} of \LJ{} ships with these modules:

\begin{description}
  \item [notice.sl] for writing single-page notices;
  \item [prosper.sl] for Prosper presentations;
  \item [textpos.sl] for poster-like material.
\end{description}


% -----

\subsection{Maths}

It's virtually impossible to list all mathematical symbols supported by
\LaTeX{} in a menu. That said, most symbols are available under
\textsf{Mode/\-Math}.

Greek letters are obtained typing \texttt{Ctrl-Cm} and a letter; the 
equivalent Greek letter, if available, will be inserted. For instance,
\texttt{Ctrl-Cma} inserts \texttt{\textbackslash{}alpha}, and
\texttt{Ctrl-CmG} inserts \texttt{\textbackslash{}Gamma}. An alternative
way is toggling Math mode, after which you type \texttt{`}-letter
(backquote-letter) to get the Greek letter. All available symbols are
provided by the file \texttt{ltx-math.sl}, included in the Jed
distribution.

Arrows are obtained as shown in Table~\ref{tab:keys}.

% -----

\subsection{Document Structure}

Use this feature to navigate through complex documents. The
\texttt{*Structure*} buffer shows the document structure, listing all
\texttt{\textbackslash{}parts}, \texttt{\textbackslash{}sections}, etc.
and the line where they begin.

Press \key{RET} or double click on a section to move to the relative line
in the \LaTeX{} buffer, or \key{q} to quit.

% -----

\section{Composing and Debugging}
\label{sec:composing}

\LJ{} typesets your documents using five output profiles: dvi,
ps, eps, pdf, and dvipdf. The final output is, respectively: a
\texttt{.dvi} file, a \texttt{.ps} or \texttt{.eps} file made with
\texttt{dvips}, a \texttt{.pdf} file made with \texttt{dvipdf}, and a
\texttt{.pdf} file made with \texttt{pdflatex}. The default output profile
is dvi.

Select \textsf{Mode/\-Compose} (or press \texttt{F9}) to typeset the
buffer using the current output profile. A `beep' will notify you of
warnings, e.g.

{\small
\begin{verbatim}
Rerun to get cross-references right.
\end{verbatim}
}

If errors are detected, the cursor will be moved to the offending line.
Press \texttt{Ctrl-C'} to move to the next error. The \texttt{latex} error
log can be inspected at any moment in the the \texttt{*LaTeX log*} buffer.

If the conversion succeeded, the following \textsf{Mode/\-View} command
will start the appropriate viewer. If you try to run a viewer but the
document has not been typeset yet, a single \texttt{latex} run will be
performed and the viewer will be launched.

% -----

\subsection{Using a Master File}

When you work on complex documents, you can set a buffer as the `master
file'. That means that although you may be working on several \LaTeX{}
files at the same time, all operations of conversion, previewing etc. will
be performed on the master file. This is useful, for example, when you
have a main file that includes several parts.

If you disable the master file, all operations will be performed on the
current buffer.

% -----

\section{Notes on \BibTeX}

\LaTeX{} mode doesn't provide any support for writing \BibTeX{} files. Jed
has an excellent \texttt{bibtex} mode already. Edit a file with
\texttt{.bib} extension to turn \texttt{bibtex} mode on.

% -----

\section{Known Issues}

\begin{itemize}

  \item The current implementation of syntax highlighting could be
  improved. The most apparent problem is that text enclosed in curly
  braces isn't always highlighted correctly. The same problem affects
  strings that span more than two lines. This is a limitation of the DFA
  code in Jed.
  
  \item Auxiliary programs are not launched as separate processes.
  In other words, you have to wait for a \texttt{latex} run to complete
  before you can edit the text. Would asyncronous compilation be a better
  choice?
  
  \item There is no support for \AMSTeX{} symbols. I'll gladly accept a
  user-contributed module, which should be straightforward to
  write---per\-haps just a bit lengthy.
  
  \item The documentation (this guide) is probably too concise.
  Please let me know if you think it is.

\end{itemize}

% -----

\section{The End}

\LJ{} was written and is copyrighted \textcopyright{} by Guido
Gonzato, Ph.D. \url{guido,dot,gonzato,at,univr,dot,it}.

\medskip

This program is free software; you can redistribute it and/or modify it
under the terms of the GNU General Public License as published by the Free
Software Foundation; either version 2 of the License, or (at your option)
any later version.

This program is distributed in the hope that it will be useful, but
WITHOUT ANY WARRANTY; without even the implied warranty of
MER\-CHAN\-TA\-BI\-LI\-TY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

You should have received a copy of the GNU General Public License along
with this program; if not, write to the Free Software Foundation, Inc.,
675 Mass Ave, Cambridge, MA 02139, USA.

\medskip

So, in actual fact this program is \emph{copylefted} by me.

Many thanks to G\"unter Milde and J\"org Sommer for their valuable
contributions, and to all users who helped me with suggestions and bug
reports. I'm especially indebted with J\o rgen Larsen for showing me how
to write good S-Lang code. Wait---can I forget to thank John E. Davis for
his great editor?

I use \LJ{} every day, and I think it's very useful and complete. However,
I'll be glad to receive suggestions and requests from you. If you find a
bug or would like me to add new features, please feel free to contact me.
If you want to send me a module, you're more than welcome!

Enjoy,

\nopagebreak
\newlength{\enjoy}
\settowidth{\enjoy}{Enjoy,}
\hspace{\enjoy}Guido \texttt{=8-)}

% -----

\end{document}
