Re: Changing the Chapter environment on the fly?

2009-01-28 Thread Uwe Stöhr

Steve Litt schrieb:

Very soon I'll need to be able to change the Chapter environment on the fly. 
Specifically, I'll need to change the word "Chapter" to "Tool", and I'll need 
to change counters. So it would look something like this:


Chapter 1: The Brave New World
Chapter 2: Introduction
Tool 1: Prepare
Tool 2: Make a Damage Control Plan

> Chapter 3: What You've Learned

Tool 3: Get the Symptom Description

> Chapter 4: What You've Learned

Implementing this is tricky. Attached is a file where I did this. (I used the koma-script book class 
because this class is the most customizable I know.)


The code is:

% define new counters
\newcounter{save}
\newcounter{tool}
% print the counter value as small Latin letter
\renewcommand{\thetool}{\alph{tool}}
% save the original chapter counter definition
\let\myChapter\thechapter

% define the new command
\newcommand{\tool}[1]{%
 % set the name
 \renewcommand{\chaptername}{Tool}
 % increase the counter
 \stepcounter{tool}
 % save the chapter counter
 \setcounter{save}{\thechapter}
 % redefine the chapter counter
 \let\thechapter\thetool
 % redefine the hyperlink chapter counter to have an unique anchor
 \renewcommand\theHchapter{Tool-\thechapter}
 % use chapter as normal
 \chapter{#1}
 % restore the original counter definitions and values
 \renewcommand{\chaptername}{Chapter}
 \let\thechapter\myChapter
 \setcounter{chapter}{\thesave}
 \renewcommand\theHchapter{\thechapter}
}

It only works when you are using in the document settings "hyperref". Although you probably already 
use hyperref, you can delete all lines in the above code that contain "theHchapter" to make it work 
without hyperref.


I spoze I could make Tool a whole different environment, but it would have to 
show up in the table of contents,


This works, but the problem is, that only the numbers of chapters appear in the TOC. Therefore I 
used small Latin letters for the number of the tool. (Because parts are numbered big Roman, 
appendices big Latin, so you can only decide between small Roman or small Latin.)



it would have to print on the page headers


This works without problems.

regards Uwe


newfile3.lyx
Description: application/lyx


Re: Changing the Chapter environment on the fly?

2009-01-28 Thread Konrad Hofbauer

Steve Litt wrote:
it just seems easier to me to change the word "Chapter" to "Tool" 

\renewcommand{\chaptername}{Tool}


and back again, and to change the counter and then change it back again.



Both untested, both won't show in LyX.
Be warned that some things might go nuts (e.g., cross-references).

HTH,
/Konrad



Re: Changing the Chapter environment on the fly?

2009-01-28 Thread Les Denham
On Wednesday 28 January 2009, Steve Litt wrote:
> Any ideas how to do this?

Steve,

I don't remember the details, but I believe this kind of manipulation is 
covered in the Memoir manual 
(http://www.tug.org/texlive/Contents/live/texmf-dist/doc/latex/memoir/memman.pdf
 
and probably also somewhere on your system is you installed doumentation).  
You'd need to do it in LaTeX.

-- 
Les

~~
Please avoid sending me Word or PowerPoint attachments.
See http://www.gnu.org/philosophy/no-word-attachments.html