ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Cascaded description
@ 2019-04-02  9:38 Procházka Lukáš Ing.
  2019-04-06  9:08 ` Procházka Lukáš Ing.
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. @ 2019-04-02  9:38 UTC (permalink / raw)
  To: ConTeXt

[-- Attachment #1: Type: text/plain, Size: 1915 bytes --]

Hello,

I'm trying to get nested descriptions (using "tab") to form a "cascade". The result should look like:

AAA ababababababab
     ababababababab

     BBB ababababab
         ababababab

         CCC ababab
             ababab

<--> indent (margin?) of the first nested description in relation to its parent
      should equal width of parent's head (+ distance?), i.e. width of "AAA ",

     <--> indent (margin?) of the second nested description in relation to its parent
          should equal width of parent's head (+ distance?), i.e. width of "BBB ",

<------> so it should be width of "AAA " + 'width of "BBB " in total.

I'm not able to achieve this. My code so far is (and I also played with various combinations of alternative, margin, hang, indent...):

----
\starttext
   A

   \bgroup
     \setuptab[headstyle={\bold\tt},sample=123,width=fit,alternative=left]
       \starttab{abc}
         \input knuth

         \starttab{def}
           \input knuth

         \stoptab
       \stoptab
   \egroup

   \bgroup
     \setuptab[headstyle={\bold\tt},sample=123456,width=fit,alternative=hanging]
       \starttab{ghijkl}
         \input knuth

         \starttab{mnopqr}
           \input knuth

         \stoptab
       \stoptab
   \egroup
\stoptext
----

- Paragraphs of "abc" and "def": size of indentation of the paragraphs is good in relation to width of head, but paragraph "def" is not "cascaded".

- Paragraphs "ghijkl" and "mnopqr" are "cascaded" well; but width of (margin?) is any - it is not related to the width of the sample text.

So how to combine both approaches to get the desired result?

Best regards,

Lukas


-- 
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS: nrpt3sn | IČO: 40763439
Bezová 1658
147 14 Praha 4

Mob.: +420 702 033 396

[-- Attachment #2: 2~.mkiv --]
[-- Type: application/octet-stream, Size: 498 bytes --]

\starttext
  A

  \bgroup
    \setuptab[headstyle={\bold\tt},sample=123,width=fit,alternative=left]
      \starttab{abc}
        \input knuth

        \starttab{def}
          \input knuth

        \stoptab
      \stoptab
  \egroup

  \bgroup
    \setuptab[headstyle={\bold\tt},sample=123456,width=fit,alternative=hanging]
      \starttab{ghijkl}
        \input knuth

        \starttab{mnopqr}
          \input knuth

        \stoptab
      \stoptab
  \egroup
\stoptext

[-- Attachment #3: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Cascaded description
  2019-04-02  9:38 Cascaded description Procházka Lukáš Ing.
@ 2019-04-06  9:08 ` Procházka Lukáš Ing.
  2019-04-06 10:45   ` Hans Hagen
  0 siblings, 1 reply; 3+ messages in thread
From: Procházka Lukáš Ing. @ 2019-04-06  9:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users

[-- Attachment #1: Type: text/plain, Size: 3240 bytes --]

Hello,

I finally found a solution (which doesn't use \description or any other Ctx command) (and which may be clumsy - I'm not so good in tex programming):

----
\def\IndByText#1{%
   \newbox\IndByTextBox
   \newdimen\IndByTextBoxWd
   \setbox\IndByTextBox\hbox{#1}%
   \IndByTextBoxWd=\wd\IndByTextBox
   \advance\leftskip by\IndByTextBoxWd
   \def\Left##1{%
     \hskip-\IndByTextBoxWd
     \hbox to\IndByTextBoxWd{##1\hfill}%
     \ignorespaces
   }%
   \ignorespaces
   \setupindenting[no]%
}

\starttext
   \input knuth

   \bgroup
     \IndByText{\bold{Abcdef~}}
     \Left{\bold{Abcdef}}
       \input knuth

       \bgroup
         \IndByText{\bold{Klmnopqr~}}
         \Left{\bold{Klmnopqr}}
           Something

         \Left{\bold{Shorter}}
           \input knuth
       \egroup
   \egroup
\stoptext
----

The only thing I cannot get rid of is a warning in the log:

"
warning         > \box \IndByTextBox is already defined (\relax it first)
warning         > \dimen \IndByTextBoxWd is already defined (\relax it first)
"

How & where to "relax the box"?

Best regards,

Lukas


On Tue, 02 Apr 2019 11:38:18 +0200, Procházka Lukáš Ing. <LPr@pontex.cz> wrote:

> Hello,
>
> I'm trying to get nested descriptions (using "tab") to form a "cascade". The result should look like:
>
> AAA ababababababab
>      ababababababab
>
>      BBB ababababab
>          ababababab
>
>          CCC ababab
>              ababab
>
> <--> indent (margin?) of the first nested description in relation to its parent
>       should equal width of parent's head (+ distance?), i.e. width of "AAA ",
>
>      <--> indent (margin?) of the second nested description in relation to its parent
>           should equal width of parent's head (+ distance?), i.e. width of "BBB ",
>
> <------> so it should be width of "AAA " + 'width of "BBB " in total.
>
> I'm not able to achieve this. My code so far is (and I also played with various combinations of alternative, margin, hang, indent...):
>
> ----
> \starttext
>    A
>
>    \bgroup
>      \setuptab[headstyle={\bold\tt},sample=123,width=fit,alternative=left]
>        \starttab{abc}
>          \input knuth
>
>          \starttab{def}
>            \input knuth
>
>          \stoptab
>        \stoptab
>    \egroup
>
>    \bgroup
>      \setuptab[headstyle={\bold\tt},sample=123456,width=fit,alternative=hanging]
>        \starttab{ghijkl}
>          \input knuth
>
>          \starttab{mnopqr}
>            \input knuth
>
>          \stoptab
>        \stoptab
>    \egroup
> \stoptext
> ----
>
> - Paragraphs of "abc" and "def": size of indentation of the paragraphs is good in relation to width of head, but paragraph "def" is not "cascaded".
>
> - Paragraphs "ghijkl" and "mnopqr" are "cascaded" well; but width of (margin?) is any - it is not related to the width of the sample text.
>
> So how to combine both approaches to get the desired result?
>
> Best regards,
>
> Lukas
>
>


-- 
Ing. Lukáš Procházka | mailto:LPr@pontex.cz
Pontex s. r. o.      | mailto:pontex@pontex.cz | http://www.pontex.cz | IDDS:nrpt3sn
Bezová 1658
147 14 Praha 4

Mob.: +420 702 033 396

[-- Attachment #2: IndByTex.mkiv --]
[-- Type: application/octet-stream, Size: 660 bytes --]

\def\IndByText#1{%
  \newbox\IndByTextBox
  \newdimen\IndByTextBoxWd
  \setbox\IndByTextBox\hbox{#1}%
  \IndByTextBoxWd=\wd\IndByTextBox
  \advance\leftskip by\IndByTextBoxWd
  \def\Left##1{%
    \hskip-\IndByTextBoxWd
    \hbox to\IndByTextBoxWd{##1\hfill}%
    \ignorespaces
  }%
  \ignorespaces
  \setupindenting[no]%
}

\starttext
  \input knuth

  \bgroup
    \IndByText{\bold{Abcdef~}}
    \Left{\bold{Abcdef}}
      \input knuth

      \bgroup
        \IndByText{\bold{Klmnopqr~}}
        \Left{\bold{Klmnopqr}}
          Something

        \Left{\bold{Shorter}}
          \input knuth
      \egroup
  \egroup
\stoptext

[-- Attachment #3: IndByTex.pdf --]
[-- Type: application/pdf, Size: 14439 bytes --]

[-- Attachment #4: Type: text/plain, Size: 493 bytes --]

___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

* Re: Cascaded description
  2019-04-06  9:08 ` Procházka Lukáš Ing.
@ 2019-04-06 10:45   ` Hans Hagen
  0 siblings, 0 replies; 3+ messages in thread
From: Hans Hagen @ 2019-04-06 10:45 UTC (permalink / raw)
  To: ntg-context

On 4/6/2019 11:08 AM, Procházka Lukáš Ing. wrote:
> Hello,
> 
> I finally found a solution (which doesn't use \description or any other 
> Ctx command) (and which may be clumsy - I'm not so good in tex 
> programming):
> 
> ----
> \def\IndByText#1{%
>    \newbox\IndByTextBox
>    \newdimen\IndByTextBoxWd
>    \setbox\IndByTextBox\hbox{#1}%
>    \IndByTextBoxWd=\wd\IndByTextBox
>    \advance\leftskip by\IndByTextBoxWd
>    \def\Left##1{%
>      \hskip-\IndByTextBoxWd
>      \hbox to\IndByTextBoxWd{##1\hfill}%
>      \ignorespaces
>    }%
>    \ignorespaces
>    \setupindenting[no]%
> }
> 
> \starttext
>    \input knuth
> 
>    \bgroup
>      \IndByText{\bold{Abcdef~}}
>      \Left{\bold{Abcdef}}
>        \input knuth
> 
>        \bgroup
>          \IndByText{\bold{Klmnopqr~}}
>          \Left{\bold{Klmnopqr}}
>            Something
> 
>          \Left{\bold{Shorter}}
>            \input knuth
>        \egroup
>    \egroup
> \stoptext
> ----
> 
> The only thing I cannot get rid of is a warning in the log:
> 
> "
> warning         > \box \IndByTextBox is already defined (\relax it first)
> warning         > \dimen \IndByTextBoxWd is already defined (\relax it 
> first)
> "
> 
> How & where to "relax the box"?

that would eventually make you run out of boxes and dimens

just move

\newbox\IndByTextBox
\newdimen\IndByTextBoxWd

outside the macro

> Best regards,
> 
> Lukas
> 
> 
> On Tue, 02 Apr 2019 11:38:18 +0200, Procházka Lukáš Ing. <LPr@pontex.cz> 
> wrote:
> 
>> Hello,
>>
>> I'm trying to get nested descriptions (using "tab") to form a 
>> "cascade". The result should look like:
>>
>> AAA ababababababab
>>      ababababababab
>>
>>      BBB ababababab
>>          ababababab
>>
>>          CCC ababab
>>              ababab
>>
>> <--> indent (margin?) of the first nested description in relation to 
>> its parent
>>       should equal width of parent's head (+ distance?), i.e. width of 
>> "AAA ",
>>
>>      <--> indent (margin?) of the second nested description in 
>> relation to its parent
>>           should equal width of parent's head (+ distance?), i.e. 
>> width of "BBB ",
>>
>> <------> so it should be width of "AAA " + 'width of "BBB " in total.
>>
>> I'm not able to achieve this. My code so far is (and I also played 
>> with various combinations of alternative, margin, hang, indent...):
>>
>> ----
>> \starttext
>>    A
>>
>>    \bgroup
>>      
>> \setuptab[headstyle={\bold\tt},sample=123,width=fit,alternative=left]
>>        \starttab{abc}
>>          \input knuth
>>
>>          \starttab{def}
>>            \input knuth
>>
>>          \stoptab
>>        \stoptab
>>    \egroup
>>
>>    \bgroup
>>      
>> \setuptab[headstyle={\bold\tt},sample=123456,width=fit,alternative=hanging] 
>>
>>        \starttab{ghijkl}
>>          \input knuth
>>
>>          \starttab{mnopqr}
>>            \input knuth
>>
>>          \stoptab
>>        \stoptab
>>    \egroup
>> \stoptext
>> ----
>>
>> - Paragraphs of "abc" and "def": size of indentation of the paragraphs 
>> is good in relation to width of head, but paragraph "def" is not 
>> "cascaded".
>>
>> - Paragraphs "ghijkl" and "mnopqr" are "cascaded" well; but width of 
>> (margin?) is any - it is not related to the width of the sample text.
>>
>> So how to combine both approaches to get the desired result?
>>
>> Best regards,
>>
>> Lukas
>>
>>
> 
> 
> 
> ___________________________________________________________________________________
> 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://context.aanhet.net
> archive  : https://bitbucket.org/phg/context-mirror/commits/
> wiki     : http://contextgarden.net
> ___________________________________________________________________________________
> 


-- 

-----------------------------------------------------------------
                                           Hans Hagen | PRAGMA ADE
               Ridderstraat 27 | 8061 GH Hasselt | The Netherlands
        tel: 038 477 53 69 | www.pragma-ade.nl | www.pragma-pod.nl
-----------------------------------------------------------------
___________________________________________________________________________________
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://context.aanhet.net
archive  : https://bitbucket.org/phg/context-mirror/commits/
wiki     : http://contextgarden.net
___________________________________________________________________________________

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

end of thread, other threads:[~2019-04-06 10:45 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-04-02  9:38 Cascaded description Procházka Lukáš Ing.
2019-04-06  9:08 ` Procházka Lukáš Ing.
2019-04-06 10:45   ` 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).