ntg-context - mailing list for ConTeXt users
 help / color / mirror / Atom feed
* alignment in cells without "alignmentcharacter"
@ 2005-11-13  0:48 Mojca Miklavec
  2005-11-13 14:16 ` Taco Hoekwater
  0 siblings, 1 reply; 9+ messages in thread
From: Mojca Miklavec @ 2005-11-13  0:48 UTC (permalink / raw)


Hello,

(A question for a coffee break for Hans or Taco while updating macros
for tables, although it may already be implemented somewhere.)

I have a table with one column for room names with an optional slash
(see below). The case is equivalent to aligning floating-point &
natural numbers (without comma) in the same column.

I aligned the entries with alignmentcharacter=/, which works perfect
except in the cases where there's no slash present (the real example
did an even worse, extremely strange alignment, where those numbers
were sticking out of the cells, but I'll investigate that a bit & post
an example another time).

% plain text aligned in the same way as I would like it to have in the result
\setupTABLE[c][1][aligncharacter=yes,alignmentcharacter=/,width=3cm,align=middle]
\bTABLE
\bTR\bTD  01/1  \eTD\eTR
\bTR\bTD  02/13 \eTD\eTR
\bTR\bTD  03    \eTD\eTR
\bTR\bTD 314/2  \eTD\eTR
\bTR\bTD 315    \eTD\eTR
\eTABLE

Is there an elegant way which would align those numbers as if they had
an additional slash on the right? I was thinking about placing a
transparent slash behind those number, but there may be a a cleaner &
more elegant solution for it. If not, it could be done approximately
in the spirit of

alignifnoalignmentcharacterpresent=
   absoluteflushleft / % according to the cell
   absoluteflushright / % according to the cell
   middle /
   relativeflushleft / % according to the aligned content
   % since remaining numbers may be aligned to the right or to the middle,
   % this would align just as left as the leftmost number with
alignment character
   relativeflushright /
   leftofthealignmentcharacter / % I only need this one
   rightofthealignmentcharacter
   .

Alternatively I could define something completely invisible like
\alignmehere and then use:

\setupTABLE[c][1]
   [aligncharacter=yes,
    alignmentcharacter={\alignmehere},
    width=3cm,align=middle]
\bTABLE
\bTR\bTD  01\alignmehere/1  \eTD\eTR
\bTR\bTD  02\alignmehere/13 \eTD\eTR
\bTR\bTD  03\alignmehere    \eTD\eTR
\bTR\bTD 314\alignmehere/2  \eTD\eTR
\bTR\bTD 315\alignmehere    \eTD\eTR
\eTABLE

but I don't know what the definition of "\alignmehere" could be so
that it would work OK. (Useful for complex alignments; for aligning
nubers the first solution would be cleaner and better.)

Thanks for any suggestions,
    Mojca

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-13  0:48 alignment in cells without "alignmentcharacter" Mojca Miklavec
@ 2005-11-13 14:16 ` Taco Hoekwater
  2005-11-13 19:02   ` Peter Münster
  2005-11-14 18:45   ` Mojca Miklavec
  0 siblings, 2 replies; 9+ messages in thread
From: Taco Hoekwater @ 2005-11-13 14:16 UTC (permalink / raw)


Mojca Miklavec wrote:
> 
> Is there an elegant way which would align those numbers as if they had
> an additional slash on the right? I was thinking about placing a

Browsing through the source I've found two approaches:

1. A currently undocumented, but nice & clean solution:

   \chardef\characteralignmentmode=2

2. A not at all elegant solution, that doesn't depend on a hidden
   feature:

   \unexpanded\def\hide#1{\hphantom{/}}
   \setupTABLE[c][1][.... as before ...]
   \bTABLE
   \bTR\bTD  01/1  \eTD\eTR
   \bTR\bTD  02/13 \eTD\eTR
   \bTR\bTD  03\hide/    \eTD\eTR
   \bTR\bTD 314/2  \eTD\eTR
   \bTR\bTD 315\hide/    \eTD\eTR
   \eTABLE

Cheers, Taco

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-13 14:16 ` Taco Hoekwater
@ 2005-11-13 19:02   ` Peter Münster
  2005-11-14  7:24     ` Taco Hoekwater
  2005-11-14 18:45   ` Mojca Miklavec
  1 sibling, 1 reply; 9+ messages in thread
From: Peter Münster @ 2005-11-13 19:02 UTC (permalink / raw)


Hello,
concerning this subject, I have another feature request:

\unexpanded\def\HideV#1{\vphantom{#1}}
\starttext
\chardef\characteralignmentmode=5 % align on left side of the character
\setupTABLE[aligncharacter=yes]
\bTABLE
\bTR\bTD 1,23\%\eTD\eTR
\bTR\bTD 12,3\%\eTD\eTR
\bTR\bTD 123\HideV,\%\eTD\eTR
\eTABLE
>From the first row to the last, the numbers 1, 2 and 3 should be aligned.
\stoptext

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-13 19:02   ` Peter Münster
@ 2005-11-14  7:24     ` Taco Hoekwater
  2005-11-14 16:28       ` Peter Münster
  0 siblings, 1 reply; 9+ messages in thread
From: Taco Hoekwater @ 2005-11-14  7:24 UTC (permalink / raw)



Hi Peter,

I am not sure what you want achieve here. Can you create
a fake table that shows what you have in mind?

Taco
(Also, I assume you meant \hphantom not \v...?)

Peter Münster wrote:
> Hello,
> concerning this subject, I have another feature request:
> 
> \unexpanded\def\HideV#1{\vphantom{#1}}
> \starttext
> \chardef\characteralignmentmode=5 % align on left side of the character
> \setupTABLE[aligncharacter=yes]
> \bTABLE
> \bTR\bTD 1,23\%\eTD\eTR
> \bTR\bTD 12,3\%\eTD\eTR
> \bTR\bTD 123\HideV,\%\eTD\eTR
> \eTABLE
>>From the first row to the last, the numbers 1, 2 and 3 should be aligned.
> \stoptext
> 
> Cheers, Peter
> 

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-14  7:24     ` Taco Hoekwater
@ 2005-11-14 16:28       ` Peter Münster
  2005-11-14 18:19         ` Taco Hoekwater
  0 siblings, 1 reply; 9+ messages in thread
From: Peter Münster @ 2005-11-14 16:28 UTC (permalink / raw)


On Mon, 14 Nov 2005, Taco Hoekwater wrote:

> I am not sure what you want achieve here. Can you create
> a fake table that shows what you have in mind?

Here is a fake table (alignment on the left side of the decimal point):

  1,23%
 12,3%
123%

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-14 16:28       ` Peter Münster
@ 2005-11-14 18:19         ` Taco Hoekwater
  0 siblings, 0 replies; 9+ messages in thread
From: Taco Hoekwater @ 2005-11-14 18:19 UTC (permalink / raw)


Peter Münster wrote:
> On Mon, 14 Nov 2005, Taco Hoekwater wrote:
> 
> 
>>I am not sure what you want achieve here. Can you create
>>a fake table that shows what you have in mind?
> 
> 
> Here is a fake table (alignment on the left side of the decimal point):
> 
>   1,23%
>  12,3%
> 123%

Ok, I understand you now (now I have to figure out how to get
the desired result ...)


Taco

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-13 14:16 ` Taco Hoekwater
  2005-11-13 19:02   ` Peter Münster
@ 2005-11-14 18:45   ` Mojca Miklavec
  2005-11-14 18:55     ` Mojca Miklavec
  2005-11-14 19:39     ` Peter Münster
  1 sibling, 2 replies; 9+ messages in thread
From: Mojca Miklavec @ 2005-11-14 18:45 UTC (permalink / raw)


On 11/13/05, Taco Hoekwater <taco@elvenkind.com> wrote:
> Mojca Miklavec wrote:
> >
> > Is there an elegant way which would align those numbers as if they had
> > an additional slash on the right? I was thinking about placing a
>
> Browsing through the source I've found two approaches:
>
> 1. A currently undocumented, but nice & clean solution:
>
>    \chardef\characteralignmentmode=2

Thank you! Found in supp-ali.tex under
%D Yet undocumented.
:) Than was exactly the answer I was looking for. (with)

> 2. A not at all elegant solution, that doesn't depend on a hidden
>    feature:
>
>    \unexpanded\def\hide#1{\hphantom{/}}
>    \setupTABLE[c][1][.... as before ...]
>    \bTABLE
>    \bTR\bTD  01/1  \eTD\eTR
>    \bTR\bTD  02/13 \eTD\eTR
>    \bTR\bTD  03\hide/    \eTD\eTR
>    \bTR\bTD 314/2  \eTD\eTR
>    \bTR\bTD 315\hide/    \eTD\eTR
>    \eTABLE

Interesting ;) I was thinking about making a \hphantom, but didn't
come to the idea of having blind arguments. I didn't know how the
mechanism of finding an alignment character works.

For Peter: are you looking for the code below or for an automated
solution to do it?

\def\mypercent#1{\hbox to 0pt{\%\hss}}
\chardef\characteralignmentmode=2
\setupTABLE[c][1][aligncharacter=yes,alignmentcharacter={,}]
\bTABLE
\bTR\bTD   1,23\% \eTD\eTR
\bTR\bTD  12,3\%  \eTD\eTR
\bTR\bTD 123\mypercent, \eTD\eTR
\eTABLE

Mojca

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-14 18:45   ` Mojca Miklavec
@ 2005-11-14 18:55     ` Mojca Miklavec
  2005-11-14 19:39     ` Peter Münster
  1 sibling, 0 replies; 9+ messages in thread
From: Mojca Miklavec @ 2005-11-14 18:55 UTC (permalink / raw)


Btw: How do I prevent different cell widths in the following two tables?

\starttext
\def\mypercent#1{\hbox to 0pt{\%\hss}}
\chardef\characteralignmentmode=2
\setupTABLE[c][1][aligncharacter=yes,alignmentcharacter={,}]
\bTABLE
\bTR\bTD   1,23\% \eTD\eTR
\bTR\bTD  12,3\%  \eTD\eTR
\bTR\bTD 123, \eTD\eTR
\eTABLE
\bTABLE
\bTR\bTD   1,23\% \eTD\eTR
\bTR\bTD  12,3\%  \eTD\eTR
\bTR\bTD 123\mypercent, \eTD\eTR
\eTABLE
\stoptext

Mojca


(And sorry for a couple of strange typos/unfinished sentences in my last mail.)

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

* Re: alignment in cells without "alignmentcharacter"
  2005-11-14 18:45   ` Mojca Miklavec
  2005-11-14 18:55     ` Mojca Miklavec
@ 2005-11-14 19:39     ` Peter Münster
  1 sibling, 0 replies; 9+ messages in thread
From: Peter Münster @ 2005-11-14 19:39 UTC (permalink / raw)


On Mon, 14 Nov 2005, Mojca Miklavec wrote:

> For Peter: are you looking for the code below or for an automated
> solution to do it?
> 
> \def\mypercent#1{\hbox to 0pt{\%\hss}}
> \chardef\characteralignmentmode=2
> \setupTABLE[c][1][aligncharacter=yes,alignmentcharacter={,}]
> \bTABLE
> \bTR\bTD   1,23\% \eTD\eTR
> \bTR\bTD  12,3\%  \eTD\eTR
> \bTR\bTD 123\mypercent, \eTD\eTR
> \eTABLE

Hello Mojca,

the "1" of the last line touches the frame...
But thank you nevertheless, you gave me the right hint:

\unexpanded\def\HideH#1{\hphantom{#1}}
\def\NoWidth#1{\hbox to 0pt{#1\hss}}
\starttext
\setupTABLE[aligncharacter=yes]
\bTABLE
\bTR\bTD   1,23\,\%               \eTD\eTR
\bTR\bTD  12,3\,\%                \eTD\eTR
\bTR\bTD 123\NoWidth{\,\%}\HideH, \eTD\eTR
\eTABLE
\stoptext

Cheers, Peter

-- 
http://pmrb.free.fr/contact/

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

end of thread, other threads:[~2005-11-14 19:39 UTC | newest]

Thread overview: 9+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2005-11-13  0:48 alignment in cells without "alignmentcharacter" Mojca Miklavec
2005-11-13 14:16 ` Taco Hoekwater
2005-11-13 19:02   ` Peter Münster
2005-11-14  7:24     ` Taco Hoekwater
2005-11-14 16:28       ` Peter Münster
2005-11-14 18:19         ` Taco Hoekwater
2005-11-14 18:45   ` Mojca Miklavec
2005-11-14 18:55     ` Mojca Miklavec
2005-11-14 19:39     ` Peter Münster

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