% extern.tex copyright 1992 Victor Eijkhout
% copyright 2014--2016 Vafa Khalighi
%
%
% 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 3 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
% MERCHANTABILITY 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, see .
%
%
\Chapter[chap:referencing]
Referencing
In manuals and scientific documents you often want to write something
like `see Chapter~4'. But what if you shuffle the chapters a bit? It
would be nice if the number would be updated automatically. With
\Lollipop, as with many other \TeX\ macro packages, this is easily
done.
Here is an example to set the mood for the rest of this chapter.
The sort of thing that is referred to most is a heading. So suppose
you want to refer to a section number.
\Example
\DefineHeading:TestSection
line:start Style:italic TestSectionCounter Spaces:2 title
line:stop Stop
\TestSection[one:section?] First section\par
After this section will come section~\ref[other:section!].
\TestSection[other:section!] Another section\par
This is the section that came after section~\ref[one:section?].
\ExampleStop
\Section What and how do you reference?
You can reference not only headings but everything that has a
counter. Thus all generic constructs can be referenced, and in
addition you can reference item numbers in a list (there are examples
of this latter possibility in section~\ref[sec:bib]). The simplest way
of referencing something is to put the key in square brackets behind
it:
\Ver>\Section[this:section] The title of This SectionSection \ref[this:section] on page \pgref[this:section]\label[the:key]\Section Precautions and remedies
\label[sec:precautions]\label[sec:remedies]
In this section ...[ref:two] Dididi\par
This is after section \ref[ref:one].
\ExampleStop
This mechanism is also used in lists, where it's mostly useful for
bibliographies generated by Bib\TeX; see section~\ref[sec:BibTeX].
\Section[sec:ref-local] Local references
Some documents are
collated out of parts that were documents in themselves.
The \Lollipop\ command \cs{InputFile} facilitates in a number
of ways working with such a segmented file (see
section~\ref[sec:InputFile]). One of the problems with input files is
that in such a case it may happen that the same reference key is used
in more than one part of the document. This phenomenon is
not at all unknown in multiple authored documents. Ordinarily this
would result in incorrect references.
To prevent such collisions \Lollipop\ can use local
references: the command \refcs{LocalReferences} has default \n{no},
and specifying
\Ver>LocalReferences:yes
\ExampleStop
Here is a way to customize the label (if you need to refresh your
memory about description lists, see
section~\ref[sec:description:list]).
\Example
\DefineList:BibList item:left [ itemCounter ] item:stop
label:start ( description ) label:stop Stop
In this example we shall have occasion to refer to
\ref[Abe80] and~\ref[Ceedee79].\par
\Indent:no Bibliography
\BibList \item[Aace55] Aace55
C.D. Aace, Inscrutible title.
\item[Abe80] Abe80
E.F. Abe, Worthless drivel.
\item[Ceedee79] Ceedee79
G.H. Ceedee, Contractual obligation.
\>
\ExampleStop
\SubSection[sec:BibTeX] Bibliographies with Bib\TeX
\Lollipop has an interface to the popular Bib\TeX\
bibliography database program, based on the `BtxMac' macros
by Karl Berry and Oren Patashnik. \Lollipop\ is set up for them, you
only have to \cs{input} the file \file{btxmac.tex}. (The version
of btxmac used to test this is \n{0.99h}.) You can find global
information about Bib\TeX\ in the \LaTeX\ book~{%\tracingmacros=2
%\tracingcommands\tracingmacros
\bibref[La:book]},
since Bib\TeX\ was
originally written for \LaTeX.
Since there is some redefining going on between btxmac and \Lollipop\
you have to load the btxmac file before the \cs{Start} command (see
section~\ref[sec:doc-start-stop]).
Since the btxmac file already has a default way of formatting the
bibliography you can get away with just putting the lines
\Ver>\bibliography{ }
\bibliographystyle{ }\DefineList:BBL>, so you can see in the `lists' chapter of this
manual what options apply.
For example:
\Ver>\DefineBBL line:start Style:italic literal:Literature line:stop
item:left [ begingroup Style:bold itemCounter
endgroup ] item:stop
Stop\bibref[Knuth80]>. This command has a very simple definition
\Ver>\def\bibref[#1]{[\ref[#1]]\nocite{#1}}\def\supref[#1]{$^{\rm \ref[#1]}$\nocite{#1}}\WriteExtern:no> (see
section~\ref[sec:write-extern]) defines \cs{noauxfile} to prevent
regeneration of the bib entries in the \file{.aux} file.
You don't have to do that anymore.
\Section Obscure details
For the sake of efficiency, not all macros in Lollipop automatically
accept labels for referencing, only the ones that use the \n{label}
option, or that have a counter (remember, the default form of the
reference is just the counter). If you want a macro that has no
counter and no label specification to accept a label, use the option
\refopt{haslabel}. One reason for doing this is that you have access to
the label itself through the control sequence \refcs{RefLabel}.
\Chapter[chap:external-files] External Files
Some document require information to be collected during a run. Such
information typically is a table of contents or index, and it is
gathered in an external file. (The reason for gathering such
information in a file at all is that often some external manipulation,
for instance sorting of an index, is needed.) Since there are many
possibilities for external files (mathematical monographs may have a
list of definitions, or a list of notations) \Lollipop\ does not
predefine such files, but supplies all of the tools for creating them.
External files involve four actions:
\Enumerate\item The file should be declared.
\item It should be specified what information is to be written to the
file.
\item The formatting of the contents of the file has to be specified.
\item The file has to be loaded.
\>
You can have at most 15 external files per document.
\Section[sec:write-extern] Declaring and loading an external file
The first act, declaring the existence of the external file is very
easy with the command \refcs{DefineExternalFile}:
an internal name and a three-character file name extension have
to be given as parameters.
\Ver>\DefineExternalFile:contents=toc\LoadExternalFile:contents\DefineHeading:Section
[...]
external:contents title external:stop\DefineExternalItem:Section file:contents
[...] Stop\DefineExternalItem:Chapter file:contents
item:left ChapterLabel item:stop
title begingroup Spaces:2 Style:italic Page endgroup
Stop\DefineExternalItem:SubSection file:contents
PushIndentLevel PushIndentLevel
item:left SectionLabel . SubSectionLabel item:stop
title begingroup Spaces:2 Style:italic Page endgroup
Stop