\stretched in chapter titles in MKII
I am trying to stretch two lines of text to the same width for use as a chapter head. I have two major problems: 1. The second line of text is appended to the end of the first line instead of being placed below it. 2. I get errors when using #1 and #2 as values, i.e {Chapter #1} and {#2}. Because of these errors I have hardcoded the values in the example that follows: \def\MyChapterCommand#1#2% #1 is number, #2 is text {\hbox to \hsize {\ss\stretched{Chapter 1}} \par \hbox to \hsize {\ss\bf\stretched{Test Chapter Title}}} \setuphead[chapter] [command=\MyChapterCommand] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Tom Benjey 717-258-9733 voice 717-243-0074 fax Twitter: @TomBenjey
Further experimentation has found a partial solution. However, I am still unable to get the chapter title line to stretch properly: %works fine as is except that chapter title is hardcoded %errors when hardcoded title is replaced with #2 %doesn't error when title is replaced with {#2} but title is not stretched %number of closing }s determined by trial and error \def\MyChapterCommand#1#2% #1 is number, #2 is text { \framed[frame=off,align=middle] {{\hbox to \hsize {\ss\stretched{Chapter {#1}}}} \par {{\hbox to \hsize {\switchtobodyfont[20pt]{\ss\bf\stretched{My Chapter Title}}}}}}} \setuphead[chapter] [command=\MyChapterCommand] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Tom Benjey 717-258-9733 voice 717-243-0074 fax Twitter: @TomBenjey -----Original Message----- From: ntg-context-bounces@ntg.nl [mailto:ntg-context-bounces@ntg.nl] On Behalf Of Tom Sent: Monday, July 05, 2010 3:16 PM To: ntg-context@ntg.nl Subject: [NTG-context] \stretched in chapter titles in MKII I am trying to stretch two lines of text to the same width for use as a chapter head. I have two major problems: 1. The second line of text is appended to the end of the first line instead of being placed below it. 2. I get errors when using #1 and #2 as values, i.e {Chapter #1} and {#2}. Because of these errors I have hardcoded the values in the example that follows: \def\MyChapterCommand#1#2% #1 is number, #2 is text {\hbox to \hsize {\ss\stretched{Chapter 1}} \par \hbox to \hsize {\ss\bf\stretched{Test Chapter Title}}} \setuphead[chapter] [command=\MyChapterCommand] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Tom Benjey 717-258-9733 voice 717-243-0074 fax Twitter: @TomBenjey ____________________________________________________________________________ _______ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ____________________________________________________________________________ _______
Am 05.07.10 21:15, schrieb Tom:
I am trying to stretch two lines of text to the same width for use as a chapter head. I have two major problems:
1. The second line of text is appended to the end of the first line instead of being placed below it.
2. I get errors when using #1 and #2 as values, i.e {Chapter #1} and {#2}. Because of these errors I have hardcoded the values in the example that follows:
You can use \stretched in headers only with \deeptextcommand and \deepnumbercommand. Wolfgang
Am 05.07.10 21:15, schrieb Tom:
I am trying to stretch two lines of text to the same width for use as a chapter head. I have two major problems:
1. The second line of text is appended to the end of the first line instead of being placed below it.
2. I get errors when using #1 and #2 as values, i.e {Chapter #1} and {#2}. Because of these errors I have hardcoded the values in the example that follows:
\define[1]\ChapterTextStretch {\line{\stretched{#1}}} \define[1]\ChapterNumberStretch{\determineheadnumber[chapter]\ChapterTextStretch{Chapter \currentheadnumber}} \setuphead [chapter] [alternative=middle, textstyle=sansbold, numberstyle=sans, deeptextcommand=\ChapterTextStretch, deepnumbercommand=\ChapterNumberStretch] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang
\define[1]\ChapterTextStretch {\line{\stretched{#1}}} \define[1]\ChapterNumberStretch{\determineheadnumber[chapter]\ChapterTextStr etch{Chapter \currentheadnumber}} \setuphead [chapter] [alternative=middle, textstyle=sansbold, numberstyle=sans, deeptextcommand=\ChapterTextStretch, deepnumbercommand=\ChapterNumberStretch] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang Thanks, Wolfgang. You have not only solved my immediate problem but have also provided me with examples of using the \deep commands. I haven't found enough documentation of them yet to get through my thick skull an understanding of what they do and how to use them. Can you explain to me the significance of the [1]s after the defines? I would still like to be able to convert chapter numbers to words without impacting the table of contents. I am confused about how \determineheadnumber and \currentheadnumber work. It appears to me that \determineheadnumber places the chapter number in a register and \currentheadnumber retrieves that value. I tried inserting \numstr before \currentheadnumber. That converts the chapter number to text and doesn't mess up the TOC but the first line is no longer stretched. Clearly, I don't understand this very well at all. Tom
\define[1]\ChapterTextStretch {\line{\stretched{#1}}} \define[1]\ChapterNumberStretch{\determineheadnumber[chapter]\ChapterTextStr etch{Chapter \currentheadnumber}} \setuphead [chapter] [alternative=middle, textstyle=sansbold, numberstyle=sans, deeptextcommand=\ChapterTextStretch, deepnumbercommand=\ChapterNumberStretch] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang I've tried to modify this code to change the chapter numbers to words. That part was successful but the above code only stretches the word "Chapter" but not the numbers' words. I also get errors when I try to get all caps by inserting \WORD in the first command. \input c:/BookLayouts/MyFirstBook/Macros/numstr.tex \define[1]\ChapterTextStretch {\line{\stretched{#1}}} \define[1]\ChapterNumberStretch {\ChapterTextStretch{Chapter\ChapterNumberWords}} \define[1]\ChapterNumberWords {\determineheadnumber[chapter]\numstr{\currentheadnumber}} \setuphead [chapter] [alternative=middle, textstyle=sansbold, numberstyle=sans, deeptextcommand=\ChapterTextStretch, deepnumbercommand=\ChapterNumberStretch] \starttext \completecontent \chapter{Test Chapter Title} \input knuth \chapter{Test Chapter With Very Long Title That Might Overflow Page} \input knuth \chapter{Test Chapter With Long Title Doesn't Overflow} \input knuth \stoptext Tom
Tom Benjey 717-258-9733 voice 717-243-0074 fax blog: www.TomBenjey.com The code that follows works fine in MKII but doesn't stretch the chapter title in MKIV. What must I change? Also, I want to convert the chapter number to text before stretching it. Has anything been done to the routines that convert numerals to alpha characters since last summer? Thanks, Tom -----Original Message----- From: ntg-context-bounces@ntg.nl [mailto:ntg-context-bounces@ntg.nl] On Behalf Of Wolfgang Schuster Sent: Tuesday, July 06, 2010 12:19 PM To: mailing list for ConTeXt users Subject: Re: [NTG-context] \stretched in chapter titles in MKII Am 05.07.10 21:15, schrieb Tom:
I am trying to stretch two lines of text to the same width for use as a chapter head. I have two major problems:
1. The second line of text is appended to the end of the first line instead of being placed below it.
2. I get errors when using #1 and #2 as values, i.e {Chapter #1} and {#2}. Because of these errors I have hardcoded the values in the example that follows:
\define[1]\ChapterTextStretch {\line{\stretched{#1}}} \define[1]\ChapterNumberStretch{\determineheadnumber[chapter]\ChapterTextStr etch{Chapter \currentheadnumber}} \setuphead [chapter] [alternative=middle, textstyle=sansbold, numberstyle=sans, deeptextcommand=\ChapterTextStretch, deepnumbercommand=\ChapterNumberStretch] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang ____________________________________________________________________________ _______ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ____________________________________________________________________________ _______
Am 22.02.2011 um 01:18 schrieb Tom:
The code that follows works fine in MKII but doesn't stretch the chapter title in MKIV. What must I change? Also, I want to convert the chapter number to text before stretching it. Has anything been done to the routines that convert numerals to alpha characters since last summer?
Use \structuretitle and \structurenumber to access the values. \defineconversion [tom] [One,Two,Three,Four,Five,…] \define[1]\ChapterTextCommand {\line{\expanded{\stretched{\structuretitle}}}} \define[1]\ChapterNumberCommand {\line{\expanded{\stretched{Chapter \convertnumber{tom}{\structurenumber}}}}} \setuphead [chapter] [ alternative=middle, style=\ssc, textstyle=\bf, numberstyle=\tf, textcommand=\ChapterTextCommand, numbercommand=\ChapterNumberCommand] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang
I'm sorry for being so thick but this code errors out when I run it under TexLive 2010 MKIV. The problem seems to be in the processing of textcommand, so I commented it out. The error went away and the \ChapterNumberCommand seemed to execute correctly. However, I want to stretch the title as well as the chapter number, so that is not a solution. I couldn't find documentation for \structuretitle and \structurenumber and am completely lost. Tom Benjey 717-258-9733 voice 717-243-0074 fax blog: www.TomBenjey.com -----Original Message----- From: ntg-context-bounces@ntg.nl [mailto:ntg-context-bounces@ntg.nl] On Behalf Of Wolfgang Schuster Sent: Tuesday, February 22, 2011 3:40 AM To: mailing list for ConTeXt users Subject: Re: [NTG-context] \stretched in chapter titles in MKII Am 22.02.2011 um 01:18 schrieb Tom:
The code that follows works fine in MKII but doesn't stretch the chapter title in MKIV. What must I change? Also, I want to convert the chapter number to text before stretching it. Has anything been done to the routines that convert numerals to alpha characters since last summer?
Use \structuretitle and \structurenumber to access the values. \defineconversion [tom] [One,Two,Three,Four,Five,.] \define[1]\ChapterTextCommand {\line{\expanded{\stretched{\structuretitle}}}} \define[1]\ChapterNumberCommand {\line{\expanded{\stretched{Chapter \convertnumber{tom}{\structurenumber}}}}} \setuphead [chapter] [ alternative=middle, style=\ssc, textstyle=\bf, numberstyle=\tf, textcommand=\ChapterTextCommand, numbercommand=\ChapterNumberCommand] \starttext \chapter{Test Chapter Title} \input knuth \stoptext Wolfgang ____________________________________________________________________________ _______ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ____________________________________________________________________________ _______
Am 22.02.2011 um 14:42 schrieb Tom:
I'm sorry for being so thick but this code errors out when I run it under TexLive 2010 MKIV. The problem seems to be in the processing of textcommand, so I commented it out. The error went away and the \ChapterNumberCommand seemed to execute correctly. However, I want to stretch the title as well as the chapter number, so that is not a solution. I couldn't find documentation for \structuretitle and \structurenumber and am completely lost.
Use the ConTeXt minimals or use a more pleasant layout for your headers, the stretched titles don’t look very nice. Wolfgang
I can actually use this for books that don't have chapter titles because I like how it appears with a font like Iwona-light. Tom Benjey 717-258-9733 voice 717-243-0074 fax blog: www.TomBenjey.com -----Original Message----- From: ntg-context-bounces@ntg.nl [mailto:ntg-context-bounces@ntg.nl] On Behalf Of Wolfgang Schuster Sent: Tuesday, February 22, 2011 5:15 PM To: mailing list for ConTeXt users Subject: Re: [NTG-context] \stretched in chapter titles in MKII Am 22.02.2011 um 14:42 schrieb Tom:
I'm sorry for being so thick but this code errors out when I run it under TexLive 2010 MKIV. The problem seems to be in the processing of textcommand, so I commented it out. The error went away and the \ChapterNumberCommand seemed to execute correctly. However, I want to stretch the title as well as the chapter number, so that is not a solution. I couldn't find documentation for \structuretitle and \structurenumber and am completely lost.
Use the ConTeXt minimals or use a more pleasant layout for your headers, the stretched titles don't look very nice. Wolfgang ____________________________________________________________________________ _______ If your question is of interest to others as well, please add an entry to the Wiki! maillist : ntg-context@ntg.nl / http://www.ntg.nl/mailman/listinfo/ntg-context webpage : http://www.pragma-ade.nl / http://tex.aanhet.net archive : http://foundry.supelec.fr/projects/contextrev/ wiki : http://contextgarden.net ____________________________________________________________________________ _______
participants (2)
-
Tom
-
Wolfgang Schuster