Article View: comp.text.tex
Article #790Outlining style option for LaTeX
From: Tim Bradshaw
Date: Tue, 07 Apr 1992 20:27
Date: Tue, 07 Apr 1992 20:27
210 lines
7821 bytes
7821 bytes
Several people asked me about this a while ago so I cleaned it up a
bit and here it is.
--Cut--
#! /bin/sh
# This is a shell archive. Remove anything before this line, then unpack
# it by saving it into a file and typing "sh file". To overwrite existing
# files, type "sh file -c". You can also feed this as standard input via
# unshar, or by typing "sh <file", e.g.. If this archive is complete, you
# will see the following message at the end:
# "End of shell archive."
# Contents: outline.sty outline.tex
# Wrapped by tfb@kesson on Tue Apr 7 21:21:19 1992
PATH=/bin:/usr/bin:/usr/ucb ; export PATH
if test -f outline.sty -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"outline.sty\"
else
echo shar: Extracting \"outline.sty\" \(3133 characters\)
sed "s/^X//" >outline.sty <<'END_OF_outline.sty'
X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
X%% File - outline.sty
X%% Description - Outling macros for LaTeX
X%% Author - Timothy Bradshaw (tfb@homer)
X%% Created On - 1988
X%% Last Modified By- Tim Bradshaw (tfb@eagle)
X%% Last Modified On- Tue Apr 7 20:59:58 1992
X%% Update Count - 10
X%% Status - Not very nice
X%%
X%% $Locker$
X%% $Log$
X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X
X% History:
X%% 17-Mar-1992 Timothy Bradshaw (tfb@homer)
X%% added optional arg for type, and changed \outlinetype to
X%% \outlinedefault
X%% 17-Mar-1992 Timothy Bradshaw (tfb@homer)
X%% added \outlinetype so you can make it do enumerate &c.
X
X%%%% * Notes
X%%% outline.doc: outlining macros for LaTeX. Originally adapted from
X%%% James Walker's Outlining macros in TUGboat 9.1 (1988), but
X%%% modified almost beyond recognition to use LaTeX's enumerate
X%%% environment, and now to be sort-of compatible with emacs'
X%%% outlining.
X
X%%% This works OK for me
X
X%%%% ** Problems
X%%%% *** Stars are magic anywhere not just at start of line.
X%%% The solution to this I think is actually to look for ^^M and make
X%%% it check for * as first char. But that was too hard to do for a
X%%% toy.
X
X%%%% *** counting stars isn't pretty any more.
X%%% When this used ^^Is and then * to indicate items you could just
X%%% define ^^I to increment the counter and then * made an item. But
X%%% now * has to do both that and look for non-* next chars, so I stop
X%%% it being active & then turn it on again. I'd like to know a
X%%% better soln to this.
X
X\newcount\outline@level
X\newcount\outline@lastlevel
X\def\outlinedefault#1{\def\outline@default{#1}}
X\outlinedefault{enumerate}
X
X{
X\catcode`\*=\active
X\gdef\outline{%
X \chardef\star=`\* % So we can put stars in
X \def\starnormal{\catcode`\*=12} % NOrmal section: another hack.
X \def\starmagic{\catcode`\*=\active}
X \global\outline@level=0
X \global\outline@lastlevel=1
X \catcode`\*=\active % must be before the \@ifnextchar!
X \@ifnextchar[{\@outline}{\outline[\outline@default]}}
X\gdef\@outline[#1]{
X \xdef\outline@type{#1}% locally
X \begin{\outline@type}%
X \let*=\outline@selfcount}
X}
X
X\def\outline@selfcount{%
X %% Count stars: is there a better way than this?
X \starnormal
X \global\advance\outline@level by 1
X \@ifstar{\outline@selfcount}{\starmagic \outline@item}}
X
X%%% \endoutline must tidy up any outstanding nested lists.
X\def\endoutline{%
X \ifnum\outline@lastlevel > 1
X \end{\outline@type}
X \global\advance\outline@lastlevel by -1
X \endoutline
X \else
X \end{\outline@type}
X \fi}
X
X\def\outline@item{%
X %%
X \ifnum\outline@lastlevel < \outline@level
X \begin{\outline@type}
X \global\advance\outline@lastlevel by 1
X \outline@item
X \else\ifnum\outline@lastlevel > \outline@level
X \end{\outline@type}
X \global\advance\outline@lastlevel by -1
X \outline@item
X \else
X \outline@doitem
X \global\outline@level=0
X \fi\fi}
X
X\let\outline@doitem\item
X% This version puts everything up to the first `.' into an \fbox
X%\def\outline@doitem #1.{\item\fbox{#1}}
END_OF_outline.sty
if test 3133 -ne `wc -c <outline.sty`; then
echo shar: \"outline.sty\" unpacked with wrong size!
fi
# end of overwriting check
fi
if test -f outline.tex -a "${1}" != "-c" ; then
echo shar: Will not over-write existing file \"outline.tex\"
else
echo shar: Extracting \"outline.tex\" \(2531 characters\)
sed "s/^X//" >outline.tex <<'END_OF_outline.tex'
X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%% -*- Mode: Latex -*- %%%%%%%%%%%%%%%%%%%%%%%%%%%%
X%% File - outline.tex
X%% Description - Some kind of documentation for outline.sty
X%% Author - Tim Bradshaw (tfb@eagle)
X%% Created On - Tue Apr 7 21:07:30 1992
X%% Last Modified By- Tim Bradshaw (tfb@eagle)
X%% Last Modified On- Tue Apr 7 21:23:27 1992
X%% Update Count - 4
X%% Status - for looking at
X%%
X%% $Locker$
X%% $Log$
X%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
X
X% History:
X%% 7-Apr-1992 Tim Bradshaw (tfb@eagle)
X%% This went with the outline.sty posted Tue Apr 7 21:12:57 1992.
X%% I wish there was a good portable documenting style (maybe this
X%% doc stuff?)
X
X\documentstyle[outline]{article}
X\begin{document}
X\section*{Outlining style for \LaTeX{}, Tim Bradshaw}
XThe `outline' style option will allow you to generate lists of various
Xsorts by using a syntax very similar to Emacs' outline mode.
XBasically you can use it like this:
X\begin{quote}
X\begin{verbatim}
X\begin{outline}
X* This is an item
X** This is a subitem of the first one
X** and another
X*** with a third level
X* first again
X\end{outline}
X\end{verbatim}
X\end{quote}
XWill produce
X\begin{outline}
X* This is an item
X** This is a subitem of the first one
X** and another
X*** with a third level
X* first again
X\end{outline}
XAnd that's basically what it does. There are some useful things to
Xknow though:
X\begin{outline}[itemize]
X* You can set the type of list you want to generate in one of two
X ways:
X** Globally, you can set use \verb.\outlinedefault. to set it, via,
X for instance \verb.\outlinedefault{itemize}. The default default is
X \verb.enumerate..
X** The \verb.outline. environment takes a (rather non-standard: is
X this good \LaTeX{} macro style?) optional arg to set the type for
X each instance: \verb.\begin{outline}[itemize]..
X
X* It cleans up after itself: you can leap several levels or end the
X environment deeply nested (within the limits of \LaTeX{}'s list
X environments).
X
X* Stars are magic {\em anywhere}, not just at beginning of line. I'm
X not sure if this is desirable or not actually. It can be defeated in
X two ways:
X** You can say \verb.\star. to get \star{}.
X** You can say \verb|{\starnormal ...}| to make a section of text where
X stars are normal again, {\starnormal like *this* for instance}.
X\end{outline}
X
XAnd I suppose I'd better put my email address, I am:
X\begin{quote}
X-- Tim Bradshaw, {\tt tim.bradshaw@edinburgh.ac.uk}
X\end{quote}
X\end{document}
END_OF_outline.tex
if test 2531 -ne `wc -c <outline.tex`; then
echo shar: \"outline.tex\" unpacked with wrong size!
fi
# end of overwriting check
fi
echo shar: End of shell archive.
exit 0
Technical Details
Message-ID:
<TFB.92Apr7212716@eagle.aisb.ed.ac.uk>Path:
arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!aisb!aisb!tfbShow Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!sparky!uunet!mcsun!uknet!edcastle!aisb!aisb!tfb From: tfb@aisb.ed.ac.uk (Tim Bradshaw) Newsgroups: comp.text.tex Subject: Outlining style option for LaTeX Message-ID: <TFB.92Apr7212716@eagle.aisb.ed.ac.uk> Date: 7 Apr 92 20:27:16 GMT Sender: news@aisb.ed.ac.uk (Network News Administrator) Organization: Dept AI, Edinburgh University, Scotland Lines: 210