ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Float caption feature request
@ 2006-05-01 17:17 Johannes Graumann
  2006-05-05  7:40 ` Taco Hoekwater
  2006-05-05 12:42 ` Hans Hagen
  0 siblings, 2 replies; 8+ messages in thread
From: Johannes Graumann @ 2006-05-01 17:17 UTC (permalink / raw)


Hello,

In LaTeX (don't remember whether this is generic or specific to one of the
packages I used to use), the 'caption' command for floats came along this
way:

\caption[optional short version]{Caption}

If one uses the 'optional short version' bit, the Table of Figures/Tables
present the short version rather than the whole caption (which in my case
is long paragraphs and makes the TOF/TOT unpractical). I would very much
like to have that functionality in context.

Thanks for any hints on how to achieve this. Poking around in the source did
not lead this newbie to a starting point ...

Joh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-01 17:17 Float caption feature request Johannes Graumann
@ 2006-05-05  7:40 ` Taco Hoekwater
  2006-05-05 22:35   ` Johannes Graumann
  2006-05-05 12:42 ` Hans Hagen
  1 sibling, 1 reply; 8+ messages in thread
From: Taco Hoekwater @ 2006-05-05  7:40 UTC (permalink / raw)


Johannes Graumann wrote:
> Hello,
> 
> In LaTeX (don't remember whether this is generic or specific to one of the
> packages I used to use), the 'caption' command for floats came along this
> way:
> 
> \caption[optional short version]{Caption}
> 
> If one uses the 'optional short version' bit, the Table of Figures/Tables
> present the short version rather than the whole caption (which in my case
> is long paragraphs and makes the TOF/TOT unpractical). I would very much
> like to have that functionality in context.

Perhaps \nomarking works in captions as well (have not checked).

Cheers,
Taco

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-01 17:17 Float caption feature request Johannes Graumann
  2006-05-05  7:40 ` Taco Hoekwater
@ 2006-05-05 12:42 ` Hans Hagen
  2006-05-05 15:30   ` Johannes Graumann
  2006-05-06 22:34   ` Mojca Miklavec
  1 sibling, 2 replies; 8+ messages in thread
From: Hans Hagen @ 2006-05-05 12:42 UTC (permalink / raw)


Johannes Graumann wrote:
> Hello,
>
> In LaTeX (don't remember whether this is generic or specific to one of the
> packages I used to use), the 'caption' command for floats came along this
> way:
>
> \caption[optional short version]{Caption}
>   
we use [] for references, and once users want one alternative, they may 
want another one as well, so best cook up a generic mechanism
> If one uses the 'optional short version' bit, the Table of Figures/Tables
> present the short version rather than the whole caption (which in my case
> is long paragraphs and makes the TOF/TOT unpractical). I would very much
> like to have that functionality in context.
>
> Thanks for any hints on how to achieve this. Poking around in the source did
> not lead this newbie to a starting point ...
>   

something

\def\MyCaption{\firstoftwoarguments}

...\MyCaption{bla}{more bla} 

or better, wrapped in a feature: 

\unprotect

% let's reuse this one in selectors (from syst-ext) 

\def\dofilterfromstr#1#2% max n
  {\ifcase#1\or
     \ifcase#2\or
       \strippedcsname\firstofoneargument
     \else
       \strippedcsname\gobbleoneargument
     \fi
   \or
     \ifcase#2\or
       \strippedcsname\firstoftwoarguments
     \or
       \strippedcsname\secondoftwoarguments
     \else
       \strippedcsname\gobbletwoarguments
     \fi
   \or
     \ifcase#2\or
       \strippedcsname\firstofthreearguments
     \or
       \strippedcsname\secondofthreearguments
     \or
       \strippedcsname\thirdofthreearguments
     \else
       \strippedcsname\gobblethreearguments
     \fi
   \or
     \ifcase#2\or
       \strippedcsname\firstoffourarguments
     \or
       \strippedcsname\secondoffourarguments
     \or
       \strippedcsname\thirdoffourarguments
     \or
       \strippedcsname\fourthoffourarguments
     \else
       \strippedcsname\gobblefourarguments
     \fi
   \or
     \ifcase#2\or
       \strippedcsname\firstoffivearguments
     \or
       \strippedcsname\secondoffivearguments
     \or
       \strippedcsname\thirdoffivearguments
     \or
       \strippedcsname\fourthoffivearguments
     \or
       \strippedcsname\fifthoffivearguments
     \else
       \strippedcsname\gobblefivearguments
     \fi
   \fi}

\def\filterfromvalue#1#2#3% value max n
  {\@EA\@EAEAEA\csname                   % we use the fact that an
     \@EA\ifx\csname#1\endcsname\relax   % undefined cs has become \relax
       \strippedcsname\gobbleoneargument % which we then gobble here
     \else
       \dofilterfromstr{#2}{#3}%
     \fi
     \endcsname\csname#1\endcsname}

\def\filterfromnext#1#2% max n {..}{..}{..}{..}
  {\csname\dofilterfromstr{#1}{#2}\endcsname}

% new, selectors

\definesystemvariable{sx}

\def\defineselector{\dodoubleargument\dodefineselector}
\def\setupselector {\dodoubleargument\dosetupselector}

\def\dodefineselector[#1][#2]{\getparameters[\??sx#1][\c!max=2,\c!n=1,#2]}
\def\dosetupselector [#1][#2]{\getparameters[\??sx#1][#2]}

\unexpanded\def\select#1%
  {\filterfromnext
     {\executeifdefined{\??sx#1\c!max}1}
     {\executeifdefined{\??sx#1\c!n  }1}}

\defineselector[caption][max=2,n=1]

\start
    \setupselector[caption][n=1]
    \placelist[figure][criterium=all]
\stop

\starttext

\placefigure
  {\select{caption}{zapf}{\input zapf \relax}}
  {}

\stoptext

i'll add selectors to the core 

Hans 

-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-05 12:42 ` Hans Hagen
@ 2006-05-05 15:30   ` Johannes Graumann
  2006-05-06  0:11     ` Johannes Graumann
  2006-05-06 22:34   ` Mojca Miklavec
  1 sibling, 1 reply; 8+ messages in thread
From: Johannes Graumann @ 2006-05-05 15:30 UTC (permalink / raw)


The 'selector' feature sounds truly wonderfull! The code below doesn't
compile yet for me though ...
1) '\protect' needs to be called after '{\executeifdefined{\??sx#1\c!n  
1}}', no?
2) Even after changing that I run into the following error when compiling
the example below:

! Missing { inserted.
<to be read again>

l.94
         {\select{caption}{zapf}{\input zapf \relax}}

Thank you for your help!

Joh

Hans Hagen wrote:
> \unprotect
> 
> % let's reuse this one in selectors (from syst-ext)
> 
> \def\dofilterfromstr#1#2% max n
>   {\ifcase#1\or
>      \ifcase#2\or
>        \strippedcsname\firstofoneargument
>      \else
>        \strippedcsname\gobbleoneargument
>      \fi
>    \or
>      \ifcase#2\or
>        \strippedcsname\firstoftwoarguments
>      \or
>        \strippedcsname\secondoftwoarguments
>      \else
>        \strippedcsname\gobbletwoarguments
>      \fi
>    \or
>      \ifcase#2\or
>        \strippedcsname\firstofthreearguments
>      \or
>        \strippedcsname\secondofthreearguments
>      \or
>        \strippedcsname\thirdofthreearguments
>      \else
>        \strippedcsname\gobblethreearguments
>      \fi
>    \or
>      \ifcase#2\or
>        \strippedcsname\firstoffourarguments
>      \or
>        \strippedcsname\secondoffourarguments
>      \or
>        \strippedcsname\thirdoffourarguments
>      \or
>        \strippedcsname\fourthoffourarguments
>      \else
>        \strippedcsname\gobblefourarguments
>      \fi
>    \or
>      \ifcase#2\or
>        \strippedcsname\firstoffivearguments
>      \or
>        \strippedcsname\secondoffivearguments
>      \or
>        \strippedcsname\thirdoffivearguments
>      \or
>        \strippedcsname\fourthoffivearguments
>      \or
>        \strippedcsname\fifthoffivearguments
>      \else
>        \strippedcsname\gobblefivearguments
>      \fi
>    \fi}
> 
> \def\filterfromvalue#1#2#3% value max n
>   {\@EA\@EAEAEA\csname                   % we use the fact that an
>      \@EA\ifx\csname#1\endcsname\relax   % undefined cs has become \relax
>        \strippedcsname\gobbleoneargument % which we then gobble here
>      \else
>        \dofilterfromstr{#2}{#3}%
>      \fi
>      \endcsname\csname#1\endcsname}
> 
> \def\filterfromnext#1#2% max n {..}{..}{..}{..}
>   {\csname\dofilterfromstr{#1}{#2}\endcsname}
> 
> % new, selectors
> 
> \definesystemvariable{sx}
> 
> \def\defineselector{\dodoubleargument\dodefineselector}
> \def\setupselector {\dodoubleargument\dosetupselector}
> 
> \def\dodefineselector[#1][#2]{\getparameters[\??sx#1][\c!max=2,\c!n=1,#2]}
> \def\dosetupselector [#1][#2]{\getparameters[\??sx#1][#2]}
> 
> \unexpanded\def\select#1%
>   {\filterfromnext
>      {\executeifdefined{\??sx#1\c!max}1}
>      {\executeifdefined{\??sx#1\c!n  }1}}
> 
> \defineselector[caption][max=2,n=1]
> 
> \start
>     \setupselector[caption][n=1]
>     \placelist[figure][criterium=all]
> \stop
> 
> \starttext
> 
> \placefigure
>   {\select{caption}{zapf}{\input zapf \relax}}
>   {}
> 
> \stoptext
> 
> i'll add selectors to the core
> 
> Hans
> 
> -----------------------------------------------------------------
>                                           Hans Hagen | PRAGMA ADE
>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
>                                              | www.pragma-pod.nl
> -----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-05  7:40 ` Taco Hoekwater
@ 2006-05-05 22:35   ` Johannes Graumann
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Graumann @ 2006-05-05 22:35 UTC (permalink / raw)


Taco Hoekwater wrote:

> Perhaps \nomarking works in captions as well (have not checked).
Sadly no.

Joh

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-05 15:30   ` Johannes Graumann
@ 2006-05-06  0:11     ` Johannes Graumann
  0 siblings, 0 replies; 8+ messages in thread
From: Johannes Graumann @ 2006-05-06  0:11 UTC (permalink / raw)


Just disregard this post and have mercy on the deadline panicked ...

Joh

Johannes Graumann wrote:

> The 'selector' feature sounds truly wonderfull! The code below doesn't
> compile yet for me though ...
> 1) '\protect' needs to be called after '{\executeifdefined{\??sx#1\c!n
> 1}}', no?
> 2) Even after changing that I run into the following error when compiling
> the example below:
> 
> ! Missing { inserted.
> <to be read again>
> 
> l.94
>          {\select{caption}{zapf}{\input zapf \relax}}
> 
> Thank you for your help!
> 
> Joh
> 
> Hans Hagen wrote:
>> \unprotect
>> 
>> % let's reuse this one in selectors (from syst-ext)
>> 
>> \def\dofilterfromstr#1#2% max n
>>   {\ifcase#1\or
>>      \ifcase#2\or
>>        \strippedcsname\firstofoneargument
>>      \else
>>        \strippedcsname\gobbleoneargument
>>      \fi
>>    \or
>>      \ifcase#2\or
>>        \strippedcsname\firstoftwoarguments
>>      \or
>>        \strippedcsname\secondoftwoarguments
>>      \else
>>        \strippedcsname\gobbletwoarguments
>>      \fi
>>    \or
>>      \ifcase#2\or
>>        \strippedcsname\firstofthreearguments
>>      \or
>>        \strippedcsname\secondofthreearguments
>>      \or
>>        \strippedcsname\thirdofthreearguments
>>      \else
>>        \strippedcsname\gobblethreearguments
>>      \fi
>>    \or
>>      \ifcase#2\or
>>        \strippedcsname\firstoffourarguments
>>      \or
>>        \strippedcsname\secondoffourarguments
>>      \or
>>        \strippedcsname\thirdoffourarguments
>>      \or
>>        \strippedcsname\fourthoffourarguments
>>      \else
>>        \strippedcsname\gobblefourarguments
>>      \fi
>>    \or
>>      \ifcase#2\or
>>        \strippedcsname\firstoffivearguments
>>      \or
>>        \strippedcsname\secondoffivearguments
>>      \or
>>        \strippedcsname\thirdoffivearguments
>>      \or
>>        \strippedcsname\fourthoffivearguments
>>      \or
>>        \strippedcsname\fifthoffivearguments
>>      \else
>>        \strippedcsname\gobblefivearguments
>>      \fi
>>    \fi}
>> 
>> \def\filterfromvalue#1#2#3% value max n
>>   {\@EA\@EAEAEA\csname                   % we use the fact that an
>>      \@EA\ifx\csname#1\endcsname\relax   % undefined cs has become \relax
>>        \strippedcsname\gobbleoneargument % which we then gobble here
>>      \else
>>        \dofilterfromstr{#2}{#3}%
>>      \fi
>>      \endcsname\csname#1\endcsname}
>> 
>> \def\filterfromnext#1#2% max n {..}{..}{..}{..}
>>   {\csname\dofilterfromstr{#1}{#2}\endcsname}
>> 
>> % new, selectors
>> 
>> \definesystemvariable{sx}
>> 
>> \def\defineselector{\dodoubleargument\dodefineselector}
>> \def\setupselector {\dodoubleargument\dosetupselector}
>> 
>> \def\dodefineselector[#1][#2]{\getparameters[\??sx#1][\c!max=2
\c!n=1,#2]}
>> \def\dosetupselector [#1][#2]{\getparameters[\??sx#1][#2]}
>> 
>> \unexpanded\def\select#1%
>>   {\filterfromnext
>>      {\executeifdefined{\??sx#1\c!max}1}
>>      {\executeifdefined{\??sx#1\c!n  }1}}
>> 
>> \defineselector[caption][max=2,n=1]
>> 
>> \start
>>     \setupselector[caption][n=1]
>>     \placelist[figure][criterium=all]
>> \stop
>> 
>> \starttext
>> 
>> \placefigure
>>   {\select{caption}{zapf}{\input zapf \relax}}
>>   {}
>> 
>> \stoptext
>> 
>> i'll add selectors to the core
>> 
>> Hans
>> 
>> -----------------------------------------------------------------
>>                                           Hans Hagen | PRAGMA ADE
>>               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
>>      tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
>>                                              | www.pragma-pod.nl
>> -----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-05 12:42 ` Hans Hagen
  2006-05-05 15:30   ` Johannes Graumann
@ 2006-05-06 22:34   ` Mojca Miklavec
  2006-05-07 18:15     ` Hans Hagen
  1 sibling, 1 reply; 8+ messages in thread
From: Mojca Miklavec @ 2006-05-06 22:34 UTC (permalink / raw)


On 5/5/06, Hans Hagen wrote:

> \placefigure
>   {\select{caption}{zapf}{\input zapf \relax}}
>   {}
>
> \stoptext
>
> i'll add selectors to the core

Very nice feature!

What about
    \select[caption]{zapf}{\input zapf \relax}
syntax instead? (You're the boss and the designer, but square brackets
seem more consistent with other ConTeXt commands; at least to me.)

Mojca

^ permalink raw reply	[flat|nested] 8+ messages in thread

* Re: Float caption feature request
  2006-05-06 22:34   ` Mojca Miklavec
@ 2006-05-07 18:15     ` Hans Hagen
  0 siblings, 0 replies; 8+ messages in thread
From: Hans Hagen @ 2006-05-07 18:15 UTC (permalink / raw)


Mojca Miklavec wrote:
> On 5/5/06, Hans Hagen wrote:
>
>   
>> \placefigure
>>   {\select{caption}{zapf}{\input zapf \relax}}
>>   {}
>>
>> \stoptext
>>
>> i'll add selectors to the core
>>     
>
> Very nice feature!
>
> What about
>     \select[caption]{zapf}{\input zapf \relax}
> syntax instead? (You're the boss and the designer, but square brackets
> seem more consistent with other ConTeXt commands; at least to me.)
>   
this is indeed more natural to context, but i consider \select to be more like the \getvariable mechanism, and when used inside [] it saves outer braces: 

\setupheadertexts[\select{caption}{zapf}{\input zapf \relax}]

Hans 
 
-----------------------------------------------------------------
                                          Hans Hagen | PRAGMA ADE
              Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
     tel: 038 477 53 69 | fax: 038 477 53 74 | www.pragma-ade.com
                                             | www.pragma-pod.nl
-----------------------------------------------------------------

^ permalink raw reply	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2006-05-07 18:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2006-05-01 17:17 Float caption feature request Johannes Graumann
2006-05-05  7:40 ` Taco Hoekwater
2006-05-05 22:35   ` Johannes Graumann
2006-05-05 12:42 ` Hans Hagen
2006-05-05 15:30   ` Johannes Graumann
2006-05-06  0:11     ` Johannes Graumann
2006-05-06 22:34   ` Mojca Miklavec
2006-05-07 18:15     ` Hans Hagen

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).