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.

How can I shrink the height of the foo cell to fit its content?

\starttext

\startTABLE
    \NC foo \NC[nr=2]\input knuth   \NC \NR
    \NC bar \NC                         \NR
\stopTABLE

\stoptext

enter image description here

share|improve this question

2 Answers 2

Do you know where the problem lies, with your question? It's not that the option [nr=2] may or may not be needed, or that an image, albeit unnecessary, since you clearly provided the code, was included in such question, somewhat fulfilling a MWE requirement, to resolve it. But the problem, at least for me, was with a poorly written, last-minute, in the rush one sentence question that in the end, left me unsure, what you wanted to accomplish. Raise the foo bar? Or stretch the bar bar? And fit its content? Anyhow, I'm assuming, that the contents you referred to, are those of the quotation by DEK.

In the three examples, I got rid of the option [nr=2]. You don't want an unstable table. That was an add on. Don't trust brackets. Brackets are like seasons. In the second example, I replaced the last \NR with \FR and of course, one of the \NC had to go. In the third example, the command \vcenter was used, so whatever text is used within the cell, stretches along with it. Isn't that nice? As soon as you bring more contents into the table, the table makes room for its contents.

A fourth example, just places bar and the line above it, below foo, in which case, all is needed is an \hrule to separate foo and bar.

Long story short:


\starttext

\startTABLE
    \NC foo \NC \input knuth \NC \NR
    \NC bar \NC             \NR
\stopTABLE
\stoptext

Second example:


\starttext

\startTABLE
    \NC foo \NC \input knuth  \FR
    \NC bar \NC             \NR
\stopTABLE
\stoptext

Third example:


\starttext

\startTABLE
    \NC foo \NC \input knuth \NC    \NR
    \NC \vcenter{\input zapf\par} \NC  \NR
\stopTABLE

\stoptext

Fourth example:


\starttext

\startTABLE
    \NC foo \hrule bar  \NC \input knuth   \NC \NR
    \NC bar \NC                         \NR
\stopTABLE

\stoptext

enter image description here enter image description here enter image description here enter image description here

share|improve this answer
1  
I agree with you with that poorly written sentence… however I understood a different thing. In my opinion he just wanted to have the foo cell adjusted to the foo word only (so the only visible change would be that the word bar —and the line above it— would be just below the foo word, instead aligned in the middle of the height of the second column cell —the one that was merged—). I'm not sure if I understood well, but I think an image from OP would easily solve this. –  Manuel Jul 13 at 8:43
1  
Hello, Manuel. You said that the way you understood the question, was in the intention that bar and the rule above it, is right below foo. And I think I also thought about it, in which case, if that is the purpose, then, it would no longer be stretching foo but bar, and as a result, foo shrinks, not stretch. Ha! Then something in the lines of \NC foo \hrule bar \NC \input knuth should suffice. I'll add another image. –  doed Jul 13 at 10:19
    
Yes Doed and Manuel, I used the wrong word (stretch instead of shrink), sorry for the misunderstanding. I've just corrected the question. The problem with your solution is that I need that [nr=2] in my real example so \hrule is not the right solution. I have finally found a not perfect solution: setting manually the height of the bar cell to the maximum (setting height=fit for the foo cell does NOT work). See my answer below. –  user2326961 Jul 15 at 8:31
up vote 0 down vote accepted

I have finally found a not perfect solution: setting manually the height of the bar cell shrinks the foo cell (setting height=fit for the foo cell does not work).

\starttext

\startTABLE
    \NC foo                 \NC[nr=2] \input knuth  \NC \NR
    \NC[height=28ex] bar    \NC                         \NR
\stopTABLE

\stoptext

I have chosen 28ex for the height because linespace in ConTeXt is equal to 2.8ex and I need the height of 10 lines in this example to fit the knuth paragraph (if I could find a way to get automatically the number of lines required to fit the knuth paragraph it would be better).

enter image description here

share|improve this answer

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.