PreTeXtBook / pretext

PreTeXt: an authoring and publishing system for scholarly documents
https://pretextbook.org
Other
266 stars 208 forks source link

paragraph elements in table cells #224

Closed Alex-Jordan closed 3 years ago

Alex-Jordan commented 8 years ago

Feature request to implement paragraphs in table cells.

In LaTeX, columns can be p{}, m{}, or b{} where the argument is a width. Latter two require the array package. They align the cell text top, middle, or bottom respectively within the cell, assuming the cell ends up taller than the paragraph.

There is also the tabularx package to consider, which I prefer to use (when writing direct tex) if a table of mine will have paragraphs. CTAN says "The pack­age is part of the la­tex-tools bun­dle in the LaTeX re­quired dis­tri­bu­tion." Instead of a tabular environment, you have a tabularx environment that takes a width argument for the entire table width. Then you can use X columns. After any r, c, l, p{}, columns have been accounted for, the remaining space taken from the overall width is evenly divided among the X columns.

davidfarmer commented 8 years ago

The feature request doesn't seem to mention an important aspect of the original discussion, which started like this:

Here's a table in CLM: http://spot.pcc.edu/math/clm/to-the-instructor.html

I have "br" elements in the source to get the breaking like: Velocity through Limits

If you look further down the table you will see entries like:

Leibniz Notation through
     Derivative Formulas and Function Behavior

The br in the source is actually conveying useful information which makes the table much easier to use. The natural way to wrap that phrase is less good.

Perhaps one can think of those table entries as lists with two rows (and no bullets or other markers), which is being simulated by the br.

So I don't think the proposed feature request will actually provide a way to do what is wanted, unless the point is that it will become legal (and properly supported in the LaTeX) to use the br.

Alex-Jordan commented 8 years ago

I was thinking that multiple p elements in a cell might server the purpose of a br. It would be some interesting XSL for sure.

On Fri, Apr 8, 2016 at 5:42 AM, davidfarmer notifications@github.com wrote:

The feature request doesn't seem to mention an important aspect of the original discussion, which started like this:

Here's a table in CLM: http://spot.pcc.edu/math/clm/to-the-instructor.html

I have "br" elements in the source to get the breaking like: Velocity through Limits

If you look further down the table you will see entries like:

Leibniz Notation through Derivative Formulas and Function Behavior

The br in the source is actually conveying useful information which makes the table much easier to use. The natural way to wrap that phrase is less good.

Perhaps one can think of those table entries as lists with two rows (and no bullets or other markers), which is being simulated by the br.

So I don't think the proposed feature request will actually provide a way to do what is wanted, unless the point is that it will become legal (and properly supported in the LaTeX) to use the br.

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/rbeezer/mathbook/issues/224#issuecomment-207418272

Alex Jordan Mathematics Instructor Portland Community College

davidfarmer commented 8 years ago

I think that would count as tag abuse in the example case, because you would have to split a sentence/phrase across two "p"s.

It would be good to determine the semantically correct way to do the markup, and then we can decide on what practical approach to take.

Maybe a line break is the best option?

Alex-Jordan commented 8 years ago

In that particular example, it really is just one line and I'm wanting it to wrap in the tex output, but only r, c, and l columns are available using MBX. It doesn't have to break in the specific way that I've forced it to break presently. That's just my hack to get the tex output to be narrow enough. So I wouldn't actually use two p's for this example, just one.

On Fri, Apr 8, 2016 at 9:21 AM, davidfarmer notifications@github.com wrote:

I think that would count as tag abuse in the example case, because you would have to split a sentence/phrase across two "p"s.

It would be good to determine the semantically correct way to do the markup, and then we can decide on what practical approach to take.

Maybe a line break is the best option?

— You are receiving this because you authored the thread. Reply to this email directly or view it on GitHub https://github.com/rbeezer/mathbook/issues/224#issuecomment-207499967

Alex Jordan Mathematics Instructor Portland Community College

davidfarmer commented 8 years ago

But the way you broke the lines looks really good!

If you just put it in one p then some will use one line, and others two.

In that particular example, it really is just one line and I'm wanting it to wrap in the tex output, but only r, c, and l columns are available using MBX. It doesn't have to break in the specific way that I've forced it to break presently. That's just my hack to get the tex output to be narrow enough. So I wouldn't actually use two p's for this example, just one.

Alex-Jordan commented 8 years ago

Well, I'll accept the compliment. The DTD has a "multiline" group that doesn't have much in it yet. The comments mention things like addresses, which naturally break up into several lines. Maybe, like with poetry, some kind of pseudo-paragraph object that has actual "line" children would help, as long as it were not abused.

Here are more tables from CLM with "paragraph cells": http://spot.pcc.edu/math/clm/appendix-units.html. You can find the print here, on the page numbered 147: http://spot.pcc.edu/math/clm/clm-print.pdf. I used local xsl overrides of "tabular" to get p{} columns (and to use booktabs) to make this output. So it's another use case to consider that is perhaps more relevant to the original feature request. I'm not in love with how these tables look, in both HTML and print, but they're a start.

rbeezer commented 8 years ago

For poetry, you would go

<stanza>
  <line>Leibniz Notation through</line>
  <line>Derivative Formulas and Function Behavior</line>
</stanza>

I much prefer this to using <br /> which feels too much like LaTeX's \. For example, n lines need n-1 br.

Would a cell wrapping be enough? Or maybe it is part of some more general use of <p>.

davidfarmer commented 8 years ago

Cell wrapping is not enough: see 3 comments above.

The "line" idea looks promising.

rbeezer commented 8 years ago

I meant, maybe a sequence of lines only needed to be in a "cell", in other words, would a sequence of "line" in a "cell" be enough structure, or would there need to be an analog of a "stanza" inside the cell grouping all the lines together? Or would "cell" be enough to contain/delimit the "line"s?

rbeezer commented 8 years ago

I have a branch which implements a sequence of "line" inside a cell.

You will find many crazy suggestions on how to accomplish this without a p{} width specifier, usually by putting a tabular withing a tabular! Or using a matrix for the cell.

shortstack seems to work well and has l, r, c specifiers. http://tex.stackexchange.com/questions/38924/newline-in-a-table-cell-which-is-centered

I think this a good solution for table cell content that is "too wide" and needs to be line-broken manually by a human. Requires no other effort from author and no additional packages.

This does not preclude figuring out reflowable paragraph text inside a table, but this felt like a prerequisite, and a more natural need.

  1. Seems to work fine inside multicolumn.
  2. A bit tight on top of the box against the rule above. Maybe the vertical gap/spacing needs attention.
  3. I'll clean this up once I have time to study real paragraphs.
Alex-Jordan commented 3 years ago

The title of this issue was about p in cells. The discussion moved on to line in cells. Both things exist now and are regularly tested. So I'm closing this, but re-open if I've messed something.