alignment in cells without "alignmentcharacter"
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
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
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/
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
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/
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
On 11/13/05, Taco Hoekwater
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
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.)
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/
participants (4)
-
Mojca Miklavec
-
Mojca Miklavec
-
Peter Münster
-
Taco Hoekwater