ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* Table headers and section titles
@ 2011-09-13 14:30 Felix Ingram
  2011-09-15 13:29 ` Felix Ingram
  0 siblings, 1 reply; 2+ messages in thread
From: Felix Ingram @ 2011-09-13 14:30 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Hello all,

I've had another stab at converting our Word template to Context. I've
managed to draw some pretty shapes using MetaPost (and I'd like to add
my +1 for getting some alpha channel support for linear_shade) and I
got really close to getting my table headings working.

I would like to have a gradient fill that runs the width of the table
header. The following shows where I've got to:

%% GRADIENT SETUP
\definecolor[a][r=0.098039,g=0.223529,b=0.52549]
\definecolor[b][r=0.098039,g=0.654902,b=0.866667]

\startuniqueMPgraphic{LinearShade}
path p ;
p := unitsquare xscaled \overlaywidth yscaled \overlayheight ;
linear_shade(p,5,\MPcolor{a},\MPcolor{b}) ;
\stopuniqueMPgraphic

\defineoverlay[shaded][\useMPgraphic{LinearShade}]

\setupTABLE[row][1][background={shaded},backgroundcolor=blue,foregroundcolor=white]

\starttext
\framed[background={shaded}, width=\textwidth, frame=off]{}
\bTABLE
\bTABLEhead
\bTR \bTH 1 \eTH \bTH 1 \eTH \bTH 1 \eTH \bTH 1 \eTH \bTH Page  \eTH \eTR
\eTABLEhead
\bTABLEbody
\bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 1 \eTD \bTD 1 \eTD \bTD 1     \eTD \eTR
\eTABLEbody
\eTABLE
\stoptext


The output shows a framed element which is similar to what I want to
achieve and the table shows where I've got to. I believe that there
are only really two options as to how I can get what I want:

1. Recalculate the gradient fill for each cell. This will require
knowing the column width and the ability to change the cell's
background as appropriate. I have no idea how to do either.
2. Draw the framed fill to the width of the table and then position it
behind the table header (which is actually how it gets done in Word).
However, I don't know how to determine the table width, or how to
accurately position the frame.

The next problem I have is with section headings. For each section
heading we are required to include a box that contains some meta
information.
This is what I have at the moment:

\setuphead[section][color=blue, aligntitle=float]

\definefloat[issueinfo][issueinfos] % Define our fancy boxout
\setupcaption[issueinfo][location=none] % Define our fancy boxout
\defineframedtext[issueinfo][]

\starttext

\section{My section header}
\placeissueinfo[right, y=-2cm]{}{
\startissueinfo[width=4cm]
Ref: ref-1 \par
a: Medium \par
b: low \par
c: 9.0
\stopissueinfo
}
Short loin shank rump pork belly ball tip pig. Spare ribs shank
tri-tip capicola strip steak. Frankfurter leberkäse filet mignon
boudin pork belly. Capicola shankle ribeye, hamburger brisket jerky
rump short ribs turkey ham hock andouille pork chop chicken tongue
pork belly. Ball tip tongue corned beef shoulder bresaola. Tri-tip
turducken salami ground round pork. Rump tenderloin pork loin ham hock
boudin, meatball venison pastrami prosciutto.

\stoptext

I'd like to be able to accurately place the box alongside the title
itself. Ideally I'd like to draw a line under the section header that
meets the left side of the box as well, though I'll take what I can
get at this point.

I hope the examples make sense. Thanks in advance for any help you can give.

Felix
___________________________________________________________________________________
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] 2+ messages in thread

* Re: Table headers and section titles
  2011-09-13 14:30 Table headers and section titles Felix Ingram
@ 2011-09-15 13:29 ` Felix Ingram
  0 siblings, 0 replies; 2+ messages in thread
From: Felix Ingram @ 2011-09-15 13:29 UTC (permalink / raw)
  To: mailing list for ConTeXt users

Some follow up notes in case anyone else is trying to do something similar

On 13 September 2011 15:30, Felix Ingram <f.ingram.lists@gmail.com> wrote:
> I've had another stab at converting our Word template to Context. I've
> managed to draw some pretty shapes using MetaPost (and I'd like to add
> my +1 for getting some alpha channel support for linear_shade) and I
> got really close to getting my table headings working.

Re: alpha channels - I'm now using TIKZ for the drawing and so this is
now sorted.

> I would like to have a gradient fill that runs the width of the table
> header. The following shows where I've got to:
>
> %% GRADIENT SETUP
> \definecolor[a][r=0.098039,g=0.223529,b=0.52549]
> \definecolor[b][r=0.098039,g=0.654902,b=0.866667]
>
> \startuniqueMPgraphic{LinearShade}
> path p ;
> p := unitsquare xscaled \overlaywidth yscaled \overlayheight ;
> linear_shade(p,5,\MPcolor{a},\MPcolor{b}) ;
> \stopuniqueMPgraphic
>
> \defineoverlay[shaded][\useMPgraphic{LinearShade}]
>
> \setupTABLE[row][1][background={shaded},backgroundcolor=blue,foregroundcolor=white]
>
> \starttext
> \framed[background={shaded}, width=\textwidth, frame=off]{}
> \bTABLE
> \bTABLEhead
> \bTR \bTH 1 \eTH \bTH 1 \eTH \bTH 1 \eTH \bTH 1 \eTH \bTH Page  \eTH \eTR
> \eTABLEhead
> \bTABLEbody
> \bTR \bTD 1 \eTD \bTD 1 \eTD \bTD 1 \eTD \bTD 1 \eTD \bTD 1     \eTD \eTR
> \eTABLEbody
> \eTABLE
> \stoptext
>
>
> The output shows a framed element which is similar to what I want to
> achieve and the table shows where I've got to. I believe that there
> are only really two options as to how I can get what I want:
>
> 1. Recalculate the gradient fill for each cell. This will require
> knowing the column width and the ability to change the cell's
> background as appropriate. I have no idea how to do either.
> 2. Draw the framed fill to the width of the table and then position it
> behind the table header (which is actually how it gets done in Word).
> However, I don't know how to determine the table width, or how to
> accurately position the frame.

Still no idea about these - I will probably try to draw something with
tikz and then move it. Still not sure how to determine the table
width, but we only have a few tables and they are fairly constant in
size, so I might just fake it.

> The next problem I have is with section headings. For each section
> heading we are required to include a box that contains some meta
> information.
> This is what I have at the moment:
>
> \setuphead[section][color=blue, aligntitle=float]
>
> \definefloat[issueinfo][issueinfos] % Define our fancy boxout
> \setupcaption[issueinfo][location=none] % Define our fancy boxout
> \defineframedtext[issueinfo][]
>
> \starttext
>
> \section{My section header}
> \placeissueinfo[right, y=-2cm]{}{
> \startissueinfo[width=4cm]
> Ref: ref-1 \par
> a: Medium \par
> b: low \par
> c: 9.0
> \stopissueinfo
> }
> Short loin shank rump pork belly ball tip pig. Spare ribs shank
> tri-tip capicola strip steak. Frankfurter leberkäse filet mignon
> boudin pork belly. Capicola shankle ribeye, hamburger brisket jerky
> rump short ribs turkey ham hock andouille pork chop chicken tongue
> pork belly. Ball tip tongue corned beef shoulder bresaola. Tri-tip
> turducken salami ground round pork. Rump tenderloin pork loin ham hock
> boudin, meatball venison pastrami prosciutto.
>
> \stoptext
>
> I'd like to be able to accurately place the box alongside the title
> itself. Ideally I'd like to draw a line under the section header that
> meets the left side of the box as well, though I'll take what I can
> get at this point.

After some careful reading of the Details manual I have something that
I'm fairly happy with.


\definefloat[issueinfo][issueinfos]
\setupcaption[issueinfo][location=none] % Turn off caption
\defineframedtext[issueinfo]
\setupframedtext[issueinfo][
width=4cm, % set the width
frame=on,   % turn on the framw
framecolor=blue,  % colour it
]
\setupfloat[issueinfo]
[
default={inner, height, high, low, none}, % set up padding etc
margin=\structdepth,
rightmargindistance=2cm,
maxwidth=0.5cm,
color=blue,
]

I then place it with the following:

    \movesidefloat[-5*line]
    \placeissueinfo[right]{}{
        \startissueinfo
...
        \stopissueinfo

The movesidefloat shifts it up to where I want it to be. The only
issue is that my section headings would overlap the box if the text
was too long, so I redefined the heading like this:

\setuphead[section]
[before=\page,
aligntitle=float, % Redundant I believe, as the next option will
prevent it being required
width=12cm,   % Set the width to something that won't impact our box.
after={{\color[red] \hrule width 125mm \vskip 2em}},
]


The 'after' settings draw the line that I was looking for and 125mm
just happens to bring it to the edge of the box, so I'm a little
happier.

I hope this is useful to someone.

Felix
___________________________________________________________________________________
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] 2+ messages in thread

end of thread, other threads:[~2011-09-15 13:29 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2011-09-13 14:30 Table headers and section titles Felix Ingram
2011-09-15 13:29 ` Felix Ingram

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