Take the 2-minute tour ×
TeX - LaTeX Stack Exchange is a question and answer site for users of TeX, LaTeX, ConTeXt, and related typesetting systems. It's 100% free, no registration required.

In the question Generate table with dynamic number of columns the OP posed a question to which my initial reaction was "No".

However, now I've run into something interesting which, if I'm reading it right, would fit the bill. From the TeX by topic by Victor Eijkhout (25.2.3):

\noalign{\penalty100} for discouraging a page break (or line break) in between two rows (columns) of an \halign (\valign).

So if I understood the above correctly, for \valign that would read:

\noalign{\penalty100} for discouraging a line break in between two columns of an \valign.

I thought: "That's exactly what was asked for", but couldn't figure out how.

share|improve this question
    
\penalty1000 only discourages a line break; to inhibit it you have to say \penalty10000 –  egreg May 14 '11 at 10:10
    
@egreg: typo. Fixed to the question. Doesn't change the outcome. –  morbusg May 14 '11 at 10:19
    
If I add some columns to that alignment, I don't get any line break. Please, provide a minimal example. –  egreg May 14 '11 at 10:25
    
@egreg: uh, what do you mean "minimal example"? It is a minimal example! If you got it to work, could you add that as an answer? Thanks! –  morbusg May 14 '11 at 10:35
    
@morbusg: I don't follow you. It' obvious that the alignment you show will not have any line break when the \hsize is reasonable. But if I typeset your alignment after \hsize=1pt I don't get any line break, that would instead be present if the inserted penalties were less than 10000. –  egreg May 14 '11 at 10:40
show 10 more comments

1 Answer

Just as \halign creates an alignment by specifying a prototype row, \valign creates an alignment by specifying a prototype column. Inside a \valign, & specifies the end of a row in a column, and \cr means "end-of-column"; each cell and column is typeset in (internal) vertical mode and the whole alignment is then passed to the paragraph builder (in horizontal mode).

In a \halign there's no way to slice off one column once the alignment has been built; with a \valign it's impossible to slice off a row.

morbusg example specifies an alignment in which there can be an arbitrary number of rows, each with the template \hbox{\strut#}; the alignment entries tell TeX to build a succession of three columns (each one with two rows). Columns are separated from the next by a \penalty10000 which inhibits a line break after each column (and before the first and after the last one, also).

share|improve this answer
    
though it is in fact possible to slice off a column by painfully \unhbox-ing the alignment and going through the various boxes. –  Bruno Le Floch May 14 '11 at 18:48
    
@Bruno: That's true, but certainly not an easy task. –  egreg May 14 '11 at 19:44
    
I know. Trying to recreate \halign mostly by hand, I got stuck on \halign to <dimen> and \halign spread <dimen>. The rest (\noalign, \span) was mostly ok. One case in which I couldn't manage to unbox properly is alignment displays, such as $$\halign{...}$$. –  Bruno Le Floch May 16 '11 at 7:32
2  
@Bruno: I believe it's the same problem one is faced when trying to unbox a tabular, because of the \mathon and \mathoff items. –  egreg May 16 '11 at 7:48
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.