\documentclass{none}
%% RCS $Id: font-latex.tex,v 1.5 2003/07/25 15:00:03 rhogee Exp $
\begin{document}                %This is just to trick emacs into latex-mode
%% If you use XEmacs, turn on latex-mode now:
%%  M-x latex-mode

This file does not compile under TeX or LaTeX.
It is a font-latex torture test, or rather, a demonstration of what 
font-latex is supposed to do.

\section{Decoration Level 1}

 \section*{...}   should work as \section{...}

Decoration levels are set by the font-lock variable:
  font-lock-maximum-decoration

In the lowest level, comments and dollar-sign math are fontified:

% This is a comment at the beginning of a line.
But this is a percentage: 100\% should not be fontified.   %This is a comment

Dollar-sign math like $ F = ma $ and $$ F = ma $$ But don't trigger
math-mode if it's quoted, i.e. a price tag \$45.50 and \$45 or
trigger math-mode off if it's embedded in math: $ T = \$5.56 $
However, a dollar sign embedded in $$ T = \$5.56 $$ is too complicated 
to handle for little gain, so is not fontified at all.

Note:  XEmacs 19.14 fails on quoted comments and dollar signs.
       This appears to be a bug in XEmacs since it uses the same syntax-table
       as emacs does. 

Strings are in font-lock-string-face:

 ``this is a normal quote'' and these are multilingual quoted strings: 
  "< french "> and "`german"' quotes, also << french >> and 8-bit « french ».

The following are in red (font-latex-warning-face) because they should
only appear as the last edit stage of the document:

  \pagebreak
  \nopagebreak
  \newpage
  \clearpage
  \cleardoublepage
  \enlargethispage
  \linebreak
  \nolinebreak
  \newline
  \-
  \\
  \\*
 and these selected AmSLaTeX commands:
  \displaybreak
  \allowdisplaybreaks
 and column separator & but not \&.

Font Changing commands:

  \bf \sc \upshape \scshape \bfseries  -> font-latex-bold-face
  \it \em \itshape \slshape            -> font-latex-italic-face

  These are in font-lock-type-face because they are... well, types:

  \rm \tt \sf \rmfamily \sffamily \ttfamily \mdseries     
  \tiny \scriptsize \footnotesize \small \normalsize \large \Large \LARGE
  \huge \Huge

  If they appear preceded by a bracket, then the argument is fontified:
  Old LaTeX font commands:
  
  {\bf text} {\sc text}                       - text in bold
  {\em text} {\it text} {\sl text}            - text in italc
  {\tt text} {\sf text} {\rm text}            - text in type-face
  {\huge text} {\Huge text}

  LaTeX2e font commands:
  
  {\bfseries text} {\upshape text} {\scshape text}
  {\itshape shape} {\slshape text} 
  {\mdseries text} {\rmfamily text} {\sffamily text} {\ttfamily text} 

  \textbf{text} \textup{text} \textsc{text}
  \textit{text} \textsl{text} \emph{text}
  \textrm{text} \textsf{text} \texttt{text} \textmd{text} 
  
  and these AmSLaTeX commands:  \pmb{text} and \boldsymbol{text}
  
  {\it multiline patterns are handled ok,
     even while typing them, if in continuous edit.} 
  {\bf multiline patterns are handled ok, 
     even while typing them, if in continuous edit.} 
  
  But the text within brackets here { \bf won't fontify} because of the 
  space before the \bf.
  
  Combinations are *not* always handled correctly:
                                \textit{foo \textbf{bar}}
                                   {\em foo \textbf{bar}}
                                \textbf{foo    {\em bar}}
                                \textbf{foo \textit{bar}}   

 [Q] Should these be added?
  
  \mathrm{letters} \mathnormal{letters} \mathcal{letters} \mathbf{letters}
  \mathsf{letters} \mathtt{letters} \mathit{letters}
 
  \mathcal{test} \mathscr{fgt}

  \mathfrak{test}


\section{Decoration Level 2}

Now we add LaTeX commands for...

cross-referencing:  LaTeX keywords in font-lock-keyword-face
                    [options] in      font-lock-variable-name-face ?
                    {arguments} in    font-lock-reference-face

  \pageref{aa}  \ref{aa} and \eqref{aa} and \index{aa} and \glossary{aa}
  \label{key} and
  \cite{key} and \cite[e.g.][page 30]{key} for special cite packages or
  \citeanycommand[e.g.]{key} for user-defined stuff.
  \footnotemark{mark}

  \include{file} and \input{file} and \bibliography{file}.

  Perhaps these shouldn't be here, because their arguments are readable text:

    \footnotetext{test} and  \footnote{foo \textbf{bar} blah}  

variables definitions:   LaTeX keywords in font-lock-keyword-face
                         [options] in      font-lock-variable-name-face ?
                         {arguments} in    font-lock-variable-name-face

  \setlength{\gnat}{1.1in}
  \settowidth{\gnat}{small}
  \settowidth{\gnat}{\em small}  % FIXME: Fails because of the \em.

  \addtolength{\gnat}{-.1\gnat} 
  \setcounter{footnote}{17} \addtocounter{footnote}{-2}

Functions:    LaTeX keywords in font-lock-keyword-face
              [options] in      font-lock-variable-name-face ?
              {arguments} in    font-lock-function-name-face

  \begin{environment} \end{environment}

  \documentstyle{article} 
  \documentclass[12pt]{article}
  \usepackage[french]{babel}
  
  \bibliographystyle{agu} \thispagestyle{empty} \pagestyle{empty}
  \pagenumbering{roman}
  \includeonly{file list} \nofiles{stuff}

  \newenvironment{stuff} and \newcommand{stuff} and 
  \newenvironment*{stuff} and \newcommand*{stuff} and 
  \newlength{stuff} and \newtheorem{stuff} and \newcounter{stuff} and 
  \renewenvironment{stuff} and \renewcommand{stuff} and 
  \renewenvironment*{stuff} and \renewcommand*{stuff} and 
  \renewlength{stuff} and \renewtheorem{stuff} and \renewcounter{stuff}.

  \fbox{foo} \mbox{foobar} \sbox{bar} 
  \vspace{1 in}  \hspace{2 in} 
%FIXME These don't work with "\\>" at the end of the regexp in 
%      font-latex-match-function:
  \vspace*{1 in} \hspace*{3 in}

 [Q] Should these commands be added?  (The first is used a lot)
 
  \maketitle 
  \appendix \tableofcontents \listoffigures \listoftables 
  \raggedright \makeindex \makeglossary

LaTeX commands for which the argument is actual text:
                    LaTeX keywords in font-lock-keyword-face
                    [options] in      font-lock-variable-name-face ?
                    {arguments} in    font-lock-type-face

  \chapter{Title}
  \part{1}
  \section{1 \mbox{text} more text}
  \subsection{1.1 Title}
  \subsubsection{1.1.1 Title}
  \paragraph{1.1.1.1 Title}

  \author{Peter Galbraith} 
  \address{galbraith@mixing.qc.dfo.ca} 
  \date{today} 
  \title[option]{text spanning 
                 multiple lines}

  \caption{text}

  \item 
  \item[name]

 [Q] But is this too much argument to fontify?  I could only fontify
     up to a certain length.

  \caption{\label{f:eg_overturn}
 %% Comment inside.  
  CTD profile in St.\ Lawrence estuary ({\sc sle}), showing measured
  $\rho(z)$ (thick line, sigma density units), re-ordered profile
  $\hat\rho(z)$ (thin line) and Thorpe fluctuation
  $\rho'(z)=\rho(z)-\hat\rho(z)$ (shaded area).  Depths $A$ and $B$ span a
  ``complete overturn'' (Dillon's~[1984] notation) or ``reordering region''
  (our notation).  A second reordering region is delineated by the dashed
  box above.}

Various equation environments:
  The math stuff is in font-latex-math-face.

  \begin{equation}
   F = ma
  \end{equation}
 
  \begin{eqnarray*}\label{test}
    F & = & ma 
  \end{eqnarray*}
 
  \begin{eqnarray}\label{test}
    F & = & ma \\
    F & = & ma
  \end{eqnarray}
 
  and some AmSLaTeX math environments: 
  gather, multline, align, alignat, xalighat, xxalighat
 
  \begin{xxalignat}\label{e:ozmidov}
    F & = & ma 
  \end{xxalignat}
 
  and in-text math like \( F = ma \) and \[ F = ma \]
 
  \[
   F = ma
  \]
 
  but don't trigger an opening math environment with \\[len]

  
Any other LaTeX command consisting of a slash followed by alphabetic
characters is fontified sedately: \anycommand But it has to work with
connected commands \frenchspacing\sloppy This is nice with commands that
should fade into the background so they aren't attracting attention away
from the text.

Special cases: \hello'hello and \@oddfoot 

Note that these aren't fontified because they are not commands, but quoted
characters:   \# \$ \% \& \~ \_ \^ \{ \}

So if some usually otherwise fontfied command isn't, then you probably
typed it in wrong...

Comments within stuff:
~~~~~~~~~~~~~~~~~~~~~~
Comments before commands inhibit their usual fontification, as they
get fontified as comments.  e.g. if you comment-out this whole file
it should all be in comment-face.

But comments ``within'' LaTeX commands must also be fontified as comments: 

\[
F = ma                          % Comment
\]

\caption{\label{stuff}          %Comment
caption text.}

\begin{equation}\label{string}
%% comment
 F = ma
\end{equation}

{\bf text                       % Unusual comment placement, but still
     more text}

\textbf{text                    % Unusual comment placement, but still
        more text}

\begin{verbatim}
this is a test $jjjjjj
\textbf{test} 
\end{verbatim}
 jjjjj
   ``One sentence that is
in two different lines.''


-- 
Peter S. Galbraith, Debian Developer          <psg@debian.org>
                                 http://people.debian.org/~psg
GPG key 1024/D2A913A1 - 97CE 866F F579 96EE  6E68 8170 35FF 799E
