LATEX-L Archives

Mailing list for the LaTeX3 project

LATEX-L@LISTSERV.UNI-HEIDELBERG.DE

Options: Use Forum View

Use Proportional Font
Show Text Part by Default
Condense Mail Headers

Message: [<< First] [< Prev] [Next >] [Last >>]
Topic: [<< First] [< Prev] [Next >] [Last >>]
Author: [<< First] [< Prev] [Next >] [Last >>]

Print Reply
Sender:
Mailing list for the LaTeX3 project <[log in to unmask]>
Date:
Fri, 21 Aug 2009 06:27:40 +0100
Reply-To:
Mailing list for the LaTeX3 project <[log in to unmask]>
Subject:
MIME-Version:
1.0
Content-Transfer-Encoding:
7bit
In-Reply-To:
Content-Type:
text/plain; charset=ISO-8859-1
From:
Joseph Wright <[log in to unmask]>
Parts/Attachments:
text/plain (115 lines)
Will Robertson wrote:
> On 20/08/2009, at 2:32 AM, Joseph Wright wrote:
> 
>> Just a first thought, based on a better understanding of the concept. As
>> you say, this might not be the best idea in the end.   I will probably
>> write myself some (private) notes on the structure now I have a better
>> picture of how things work, and see if anything else strikes me.
> 
> I think I see where my model of what's going on (particularly regarding
> collections) was slightly off-kilter. I agree we should delay discussing
> the mechanics (names, order of the args) until after we're solid on the
> fundamentals.
> 
> I've now got a new question. Following Joseph's examples, we might have
> something like \chapter which uses an instance 'chapter' of type
> 'sectioning'.
> 
> What should be done at the document design level to customise the look
> of the chapter headings? I don't think we want to have to redefine
> \chapter, so there are two options:
> 
> 1. create a fresh instance called 'chapter' with the desired parameters,
> 2. "edit" the current 'chapter' instance.
> 
> The first option is what is necessary in, say, titlesec. I've got to
> admit it's not my favourite, because it requires you to possibly set or
> re-set a bunch of parameters that you were already happy with. (And you
> also have to know the name of the template it was produced with.)
> 
> Let's say then that I'd like to be able to edit the instance 'chapter';
> is there any way to be able to do this?
> 
> I imagine markup like
> 
>     \EditInstance{sectioning}{chapter}% template is implicit!
>         { ...keyvals... }
> 
> but I don't know if my desire for this construct illustrates a
> misunderstanding of mine of the system.
> 
> Will
> 
> P.S.  I guess that something like the above \EditInstance would require
> a saved keyval list for the parameters used to generate the instance;
> however, I don't think that's an unacceptable use of memory.
> 

From Frank's explanation, my understanding is slightly different. The
key is to remember where templates it into all of this. Taking my
example from before, and sticking with the current naming scheme, we
might have

\DeclareTemplateType { sectioning } 3
\DeclareTemplate { sectioning } { starts-new-page } 3
  { <key definitions> { <code> }
\DeclareTemplate { sectioning } { space-before-and-after }
  { <key definitions> { <code> }
\DeclareRestrictedTemplate { sectioning }
  { starts-new-page-no-number } { starts-new-page }
  { <key settings> }
\DeclareInstance { sectioning } { chapter } { starts-new-page }
  { <key settings> }
\DeclareCollectionInstance { frontmatter } { sectioning }
  { chapter } { starts-new-page-no-number }
  { <key settings>}

\DeclareDocumentCommand \chapter { s o m } {
  % Code to include
  \UseInstance { sectioning } { chapter }
}

If I'm designing a document and want to completely change \chapter, I
have a few options:

1) If one of the existing templates can do what I want with the right
keyval settings, I re-declare the instance. So if I want to alter font
sizes and so on but not more general layout, I do

\DeclareInstance { sectioning } { chapter } { starts-new-page }
  { <new key settings> }

plus probably

\DeclareCollectionInstance { frontmatter } { sectioning }
  { chapter } { starts-new-page-no-number }
  { <new key settings>}

2) If one of the other existing templates works for me, I do essentially
the same thing but change template. Assuming that
"space-before-and-after" is used for sections, to make chapters look
like sections

\DeclareInstance { sectioning } { chapter } { space-before-and-after }
  { <new key settings> }

3) If I want a radically new design, I create a new template then use it.

\DeclareTemplate { sectioning } { completely-unlike-LaTeX-defaults } 3
  { <key definitons> } { <code> }
\DeclareInstance { sectioning } { chapter }
  { completely-unlike-LaTeX-defaults } { <key settings> }

In all three cases, the document command is left alone. Of course, this
leaves open the question of how much variation each template leaves
open. I can see your argument for creating instances with only minor
adjustments from existing ones ("All I want to do is change length a to
length b, leaving everything else alone."). My feeling is that the idea
is that document classes should be much clearer on the settings they
use, so the cost of copying a template and altering only a few lines is
worth it in clarity of what is going on. The danger of allowing
something like \EditInstance is that you can easily get back to ad hoc
changes here and there with no clear separation of design and document code.
-- 
Joseph Wright

ATOM RSS1 RSS2