ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* problems with vertical spacing and boxes
@ 2010-11-09  9:12 Thomas A. Schmitz
  2010-11-09  9:19 ` Thomas A. Schmitz
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas A. Schmitz @ 2010-11-09  9:12 UTC (permalink / raw)
  To: mailing ConTeXt users list for

Hi all,

I need a somewhat unusual vertical setup for typesetting a play. Here is some ASCII art that may show what I want:

SP XXXXXXXXXXX
   XXXXXX        15

So: beginning of the line has a fixed space for the abbreviation of the speaker (if there is a speaker designation attached to the line). Then comes the line itself, which fills ca. 80 % amount of the linewidth and needs to be broken as a normal paragraph if it is longer than this space. At the end of the line, another fixed space with the line number, flushright; this number needs to be at the bottom of the paragraph. I have tried three different approaches, but all of them have some problem. One thing to keep in mind: there will be around 3000 such lines, so this might affect processing time. So here are the three approaches:

1. low-level, with boxes. Problem: messes up vertical spacing. (I have set the interlinespace to an absurd dimension because this shows the problem in a clearer way). I tried using \strut s at a few places, but couldn't get this to work:

2. tabulate: nice, but I can't get the number to be aligned to the bottom. Is there any parameter or trick for that?

3. baseline between columns is not aligned (maybe I'm missing the right parameter?), extra vertical space is added.

Eagerly awaiting your suggestions!

All best

Thomas

\setupbodyfont[termes,12pt]

\setupinterlinespace[line=4.5ex]

\startbuffer
\MyLine{5}{Fa.}{This line is short.}

\MyLine{10}{Me.}{This line is slightly longer, so it will be broken into
  two lines in the output.}

\MyLine{15}{Fa.}{This line is short again.}

\MyLine{20}{Me.}{Another longer line that will be broken into
  two lines in the output.}

\MyLine{25}{Fa.}{And the last line.}
\stopbuffer
\starttext

\def\MyLine#1#2#3%
  {\setbox\scratchbox\vbox{\hsize=6cm #3}\hbox{\vbox to \ht\scratchbox{\hbox to 1cm{\bf #2}\vfill}\vbox{\hsize=6cm #3\par}\vbox to \ht\scratchbox{\vfill\hbox to 1cm{\hfill #1}}}}

\getbuffer

\definetabulate[ELine][|Blw(0.65cm)|p(5.8cm)|rw(0.8cm)|]

\def\MyLine#1#2#3%
  {\startELine
    \NC #2 \NC #3 \NC #1 \NR
   \stopELine}

\getbuffer

\setupTABLE[column][1][width=1cm,frame=off,offset=0pt,,align={right}]
\setupTABLE[column][2][width=6cm,frame=off,align={normal}]
\setupTABLE[column][3][width=1cm,frame=off,align={left,low}]

\def\MyLine#1#2#3%
  {\bTABLE
    \bTR\bTD \bf #2 \eTD\bTD #3 \eTD\bTD #1 \eTD \eTR
   \eTABLE}

\getbuffer

\stoptext

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09  9:12 problems with vertical spacing and boxes Thomas A. Schmitz
@ 2010-11-09  9:19 ` Thomas A. Schmitz
  2010-11-09 14:47   ` Wolfgang Schuster
  0 siblings, 1 reply; 7+ messages in thread
From: Thomas A. Schmitz @ 2010-11-09  9:19 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Oh, I forgot one important detail: I have protrusion enabled, so I need protrusion for the main text (argument #2). This works with the low-level approach, but not with the other ones, I think.

On Nov 9, 2010, at 10:12 AM, Thomas A. Schmitz wrote:

> Hi all,
> 
> I need a somewhat unusual vertical setup for typesetting a play. Here is some ASCII art that may show what I want:
> 
> SP XXXXXXXXXXX
>   XXXXXX        15
> 
> So: beginning of the line has a fixed space for the abbreviation of the speaker (if there is a speaker designation attached to the line). Then comes the line itself, which fills ca. 80 % amount of the linewidth and needs to be broken as a normal paragraph if it is longer than this space. At the end of the line, another fixed space with the line number, flushright; this number needs to be at the bottom of the paragraph. I have tried three different approaches, but all of them have some problem. One thing to keep in mind: there will be around 3000 such lines, so this might affect processing time. So here are the three approaches:
> 
> 1. low-level, with boxes. Problem: messes up vertical spacing. (I have set the interlinespace to an absurd dimension because this shows the problem in a clearer way). I tried using \strut s at a few places, but couldn't get this to work:
> 
> 2. tabulate: nice, but I can't get the number to be aligned to the bottom. Is there any parameter or trick for that?
> 
> 3. baseline between columns is not aligned (maybe I'm missing the right parameter?), extra vertical space is added.
> 
> Eagerly awaiting your suggestions!
> 
> All best
> 
> Thomas
> 
> \setupbodyfont[termes,12pt]
> 
> \setupinterlinespace[line=4.5ex]
> 
> \startbuffer
> \MyLine{5}{Fa.}{This line is short.}
> 
> \MyLine{10}{Me.}{This line is slightly longer, so it will be broken into
>  two lines in the output.}
> 
> \MyLine{15}{Fa.}{This line is short again.}
> 
> \MyLine{20}{Me.}{Another longer line that will be broken into
>  two lines in the output.}
> 
> \MyLine{25}{Fa.}{And the last line.}
> \stopbuffer
> \starttext
> 
> \def\MyLine#1#2#3%
>  {\setbox\scratchbox\vbox{\hsize=6cm #3}\hbox{\vbox to \ht\scratchbox{\hbox to 1cm{\bf #2}\vfill}\vbox{\hsize=6cm #3\par}\vbox to \ht\scratchbox{\vfill\hbox to 1cm{\hfill #1}}}}
> 
> \getbuffer
> 
> \definetabulate[ELine][|Blw(0.65cm)|p(5.8cm)|rw(0.8cm)|]
> 
> \def\MyLine#1#2#3%
>  {\startELine
>    \NC #2 \NC #3 \NC #1 \NR
>   \stopELine}
> 
> \getbuffer
> 
> \setupTABLE[column][1][width=1cm,frame=off,offset=0pt,,align={right}]
> \setupTABLE[column][2][width=6cm,frame=off,align={normal}]
> \setupTABLE[column][3][width=1cm,frame=off,align={left,low}]
> 
> \def\MyLine#1#2#3%
>  {\bTABLE
>    \bTR\bTD \bf #2 \eTD\bTD #3 \eTD\bTD #1 \eTD \eTR
>   \eTABLE}
> 
> \getbuffer
> 
> \stoptext
> 
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09  9:19 ` Thomas A. Schmitz
@ 2010-11-09 14:47   ` Wolfgang Schuster
  2010-11-09 15:05     ` Thomas A. Schmitz
  0 siblings, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2010-11-09 14:47 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.11.2010 um 10:19 schrieb Thomas A. Schmitz:

> Oh, I forgot one important detail: I have protrusion enabled, so I need protrusion for the main text (argument #2). This works with the low-level approach, but not with the other ones, I think.

You have to enable protrusion for natural tables your self with „align=hanging“.

Another solution for your problem is to use descriptions:

\definefontfeature[default][default][protrusion=quality]

\setupbodyfont[termes,12pt]

\setupinterlinespace[line=4.5ex]

\setupalign[hanging]

\starttext

\definedescription
  [Fa]
  [text=Fa.,
   width=1cm,
   command=\currentdescriptionlabel\gobbleoneargument,
   distance=0pt,
   title=yes,
  %style={\hsize10cm},
   closesymbol=\rlap{\quad\currentdescriptiontitle}]

\Fa{15} \input knuth\par

\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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09 14:47   ` Wolfgang Schuster
@ 2010-11-09 15:05     ` Thomas A. Schmitz
  2010-11-09 15:53       ` Wolfgang Schuster
  2010-11-09 15:54       ` Wolfgang Schuster
  0 siblings, 2 replies; 7+ messages in thread
From: Thomas A. Schmitz @ 2010-11-09 15:05 UTC (permalink / raw)
  To: mailing list for ConTeXt users


On Nov 9, 2010, at 3:47 PM, Wolfgang Schuster wrote:

> You have to enable protrusion for natural tables your self with „align=hanging“.
> 
> Another solution for your problem is to use descriptions:

Thanks Wolfgang, I must remember align=hanging (had a similar problem with footnotes recently). Descriptions may be a way, but would it be possible to mimick my input syntax here:

\MyLine{5}{Fa.}{This line is short.}

and define a description that will take "5" as "closesymbol" and "Fa." as "text"? Otherwise, I'd need to define a description for every speaking character.

Thomas
___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09 15:05     ` Thomas A. Schmitz
@ 2010-11-09 15:53       ` Wolfgang Schuster
  2010-11-09 17:08         ` Thomas A. Schmitz
  2010-11-09 15:54       ` Wolfgang Schuster
  1 sibling, 1 reply; 7+ messages in thread
From: Wolfgang Schuster @ 2010-11-09 15:53 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.11.2010 um 16:05 schrieb Thomas A. Schmitz:

> Thanks Wolfgang, I must remember align=hanging (had a similar problem with footnotes recently). Descriptions may be a way, but would it be possible to mimick my input syntax here:
> 
> \MyLine{5}{Fa.}{This line is short.}
> 
> and define a description that will take "5" as "closesymbol" and "Fa." as "text"? Otherwise, I'd need to define a description for every speaking character.


Another solution:

\setupbodyfont[termes,12pt]

\setupinterlinespace[line=4.5ex]

\setupalign[hanging]

\defineitemgroup[myline][width=1cm,symstyle=bold]

\define[3]\MyLine
  {\startmyline\hsize=7cm
   \sym{#2}#3\wordright[2em]{#1}%
   \stopmyline}

\starttext

\MyLine{5}{Fa.}{This line is short.}

\MyLine{12}{Ma.}{\input knuth }

\MyLine{8}{Pa.}{\input ward }

\stoptext

When you’re going to use this for a long document i suggest an alternative method for the input:

\MyLine[lines=...,speaker=...] ... \par

and

\startMyLine[lines=...,speaker=...]
...
\stopMyLine

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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09 15:05     ` Thomas A. Schmitz
  2010-11-09 15:53       ` Wolfgang Schuster
@ 2010-11-09 15:54       ` Wolfgang Schuster
  1 sibling, 0 replies; 7+ messages in thread
From: Wolfgang Schuster @ 2010-11-09 15:54 UTC (permalink / raw)
  To: mailing list for ConTeXt users


Am 09.11.2010 um 16:05 schrieb Thomas A. Schmitz:

> 
> On Nov 9, 2010, at 3:47 PM, Wolfgang Schuster wrote:
> 
>> You have to enable protrusion for natural tables your self with „align=hanging“.
>> 
>> Another solution for your problem is to use descriptions:
> 
> Thanks Wolfgang, I must remember align=hanging (had a similar problem with footnotes recently). Descriptions may be a way, but would it be possible to mimick my input syntax here:
> 
> \MyLine{5}{Fa.}{This line is short.}
> 
> and define a description that will take "5" as "closesymbol" and "Fa." as "text"? Otherwise, I'd need to define a description for every speaking character.
> 
> Thomas
> ___________________________________________________________________________________
> 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
> ___________________________________________________________________________________

___________________________________________________________________________________
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
___________________________________________________________________________________


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

* Re: problems with vertical spacing and boxes
  2010-11-09 15:53       ` Wolfgang Schuster
@ 2010-11-09 17:08         ` Thomas A. Schmitz
  0 siblings, 0 replies; 7+ messages in thread
From: Thomas A. Schmitz @ 2010-11-09 17:08 UTC (permalink / raw)
  To: mailing list for ConTeXt users


On Nov 9, 2010, at 4:53 PM, Wolfgang Schuster wrote:

> Another solution:
> 
> \setupbodyfont[termes,12pt]
> 
> \setupinterlinespace[line=4.5ex]
> 
> \setupalign[hanging]
> 
> \defineitemgroup[myline][width=1cm,symstyle=bold]
> 
> \define[3]\MyLine
>  {\startmyline\hsize=7cm
>   \sym{#2}#3\wordright[2em]{#1}%
>   \stopmyline}
> 
> \starttext
> 
> \MyLine{5}{Fa.}{This line is short.}
> 
> \MyLine{12}{Ma.}{\input knuth }
> 
> \MyLine{8}{Pa.}{\input ward }
> 
> \stoptext
> 
> When you’re going to use this for a long document i suggest an alternative method for the input:
> 
> \MyLine[lines=...,speaker=...] ... \par
> 
> and
> 
> \startMyLine[lines=...,speaker=...]
> ...
> \stopMyLine
> 
> Wolfgang

Yes, this looks good! I use the macro in a slightly more complex situation, so my "real" syntax is

\MyLine[<number>][yes|no][<Speaker>]{<line content>}

where yes|no determines whether the number should be displayed or not and the third argument (the speaker) is optional; it it's there, it will be typeset in the space at the beginning of the line. Complex, but makes it easy to read my source...

Thanks!

Thomas
___________________________________________________________________________________
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
___________________________________________________________________________________


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

end of thread, other threads:[~2010-11-09 17:08 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2010-11-09  9:12 problems with vertical spacing and boxes Thomas A. Schmitz
2010-11-09  9:19 ` Thomas A. Schmitz
2010-11-09 14:47   ` Wolfgang Schuster
2010-11-09 15:05     ` Thomas A. Schmitz
2010-11-09 15:53       ` Wolfgang Schuster
2010-11-09 17:08         ` Thomas A. Schmitz
2010-11-09 15:54       ` Wolfgang Schuster

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).