New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

More complete support of the array environment #269

Open
gagern opened this Issue Jun 25, 2015 · 17 comments

Comments

Projects
None yet
9 participants
@gagern
Collaborator

gagern commented Jun 25, 2015

While #246 added basic support for the array environment, that support is not complete yet. It would be nice to get it (more) complete one day, so let's keep track of what's still missing, since filing a bug for each of these things feels inappropriate just now.

In the format description:

  • | – vertical lines between columns (#267)
  • || – i.e. repeated vertical lines
  • *{7}{cc} – repetition in format description
  • @{=} – i.e. custom coumn separators
  • \extracolsep for use in @{…}
  • p{2em} – inserts \parbox of given width

In the body:

  • \hline – horizontal lines (#267)
  • \hline\hline – repeated horizontal lines
  • \cline[1-3] – lines spanning some of the columns
  • \multicolumn{1}{c}{Foo} – to change the formatting of a single cell
  • \multicolumn{2}{c}{Foo} – content spanning multiple columns

In individual cells:

  • \hfill at the ends to change the alignment of a single cell
  • \hfill within the content to split it into a left-aligned and a right-aligned part
  • \vline – vertical line as high as the cell

Format descriptions from the array package:

  • <{foo} and >{bar} – add content to all cells
  • m{1em} and b{3em} – like p but with different vertical alignment
  • !{=} – like @ but keep the space

I'm not sure we'll ever want to support all of this.

@azotova

This comment has been minimized.

azotova commented Jun 29, 2015

It would be also great to support {cases} environment to create systems of simultaneous equations (like here: https://kogler.wordpress.com/2008/03/21/latex-multiline-equations-systems-and-matrices/). I am sorry if this is not the right thread to bring this up, but it seems related to the {array} environment.

@kevinbarabash

This comment has been minimized.

Member

kevinbarabash commented Jun 29, 2015

@azotova It uses {array}, but {cases} is a separate environment. Could you open a new issue for it?

@kevinbarabash

This comment has been minimized.

Member

kevinbarabash commented Jun 29, 2015

Request for {cases} environment in #278.

@edemaine

This comment has been minimized.

Member

edemaine commented Jan 12, 2017

I was surprised to find no \multicolumn support, which lead me here. I was further surprised to see that arrays are rendered column by column instead of row by row, which seems to make supporting \multicolumn ... challenging. What was the rationale for this decision (perhaps #587? i.e. lack of horizontal space spacing information? or perhaps getting columns to center easily...)? Do you have any ideas on how to implement \multicolumn? I was hoping that array was implemented using HTML tables, which would make \multicolumn especially easy... but might make it harder to match LaTeX spacing?

@gagern

This comment has been minimized.

Collaborator

gagern commented Jan 12, 2017

Yes, the main motivation to implement arrays as colums was for lack of width information. It's easy to have all boxes of a column share a common column width, with control over where in the column they get positioned. In #246 I mentioned <table> as a possible alternative, and I still think they would be as noone ever voiced a compellin greason against that. I just started with the other approach first and it worked well enough so far. I think that if we switch to tables then we should be careful about fully resetting their style: a website might well have tables styled differently in many ways, so we must undo all website styling with sufficient specitivity.

I'm not sure whether we can get HTML tables to behave like LaTeX tables in situations where the multicolumn is the one defining the width. How is the extra width distributed among the contributing columns in such a case? A bit of experimentation or literature research will probably be useful here. Of course, having any form of multicolumn support is probably better than none at all, and will likely already cover many typical situations.

Another thing we should be careful to check is whether we can get rows of a table to overlap. With negative space between rows, such overlap can easily happen in the LaTeX world. I would guess that with visible overflow and negative margins or padding, this should be possible in the CSS world, too, but I'm not 100% sure.

@csilvers

This comment has been minimized.

csilvers commented Jan 13, 2017

I was once told, anecdotally, that <table> layout differs between browsers in ways that is impossible to correct or compensate for, and that nobody that cares about exact layout should ever use <table>. Unfortunately, I don't remember the source, and if it's still true (or indeed ever was). But something to keep in mind when considering <table>.

@edemaine

This comment has been minimized.

Member

edemaine commented Jan 13, 2017

I didn't realize CSS table support was so weak (it has no colspan feature), so we'd really need to use <table>/<tr>/<td> tags, and then we'd definitely need to reset their CSS in a careful way. In particular, we don't want any actual line wrapping within a cell. It's probably worth some experimentation to see whether it can be reliable for our case. Otherwise, to do it manually ourselves, I think we really need horizontal metrics.

@gagern

This comment has been minimized.

Collaborator

gagern commented Jan 13, 2017

Many shortcomings of CSS layouts can be dealt with using flex layouts, but so far I haven't come up with a way how a flex layout would help with multicols. My main concern at this time is vertical positioning. We need to wrap the cell content in such a way that we retain full control over cell height and the position of the content, while at the same time using the automatism from the table layout to determine the width of the cell. Some stand-alone experiments to this end might be useful.

@edemaine

This comment has been minimized.

Member

edemaine commented Jan 13, 2017

Here is a simple illustration of making \multicolumn using column-based <div>s, using some overlapping <div>s. Unfortunately, I believe this requires knowing whether the columns or the multicolumn are wider, so we know which one to use to define the parent width -- I don't think there's a mechanism to take the max...

@flagxor

This comment has been minimized.

flagxor commented Apr 10, 2018

It would be nice if alignment modifiers like [t] and [b] were supported.

@edemaine

This comment has been minimized.

Member

edemaine commented Apr 10, 2018

@flagxor What do you mean? Something like \parbox[t] for top or bottom alignment of the containing box? I'm not aware of such an argument in array but maybe there's an extension to this effect.

Where could we find the source for the example in http://flagxor.github.io/spec/core/bikeshed/index.html#store%E2%91%A0 ? The MathML seems to be stripped, so I can't see the LaTeX source...

@rossberg

This comment has been minimized.

rossberg commented Apr 10, 2018

@edemaine, he is referring to vertical anchors like in \begin{array}[t]{lll}.

See e.g. https://github.com/WebAssembly/spec/blob/master/document/core/exec/runtime.rst#59 for the source.

@fuzihaofzh

This comment has been minimized.

fuzihaofzh commented May 10, 2018

Hi, when will \hline be supported? it is needed in a lot of places. Thanks

@stevem6

This comment has been minimized.

stevem6 commented May 10, 2018

\hline would be nice but meanwhile it can be simulated using \mathrlap

\begin{array}{c|c|c|c|c|c}
\mathrlap{\rule[-1ex]{20em}{0.1ex}}\phantom{44}x\phantom{44} & (-\infty,-4) & -4 & (-4,7) &7&(7,\infty) \\[1ex]
x-7 &- & - &- & 0 & + \\[1ex] 
\mathrlap{\rule[-1.2ex]{20em}{0.1ex}}x+4 & - & 0 & + & + & +  \\[1ex] 
\dfrac{x-7}{x+4} & + & * & - & 0 & +
\end{array}

giving
image

@fuzihaofzh

This comment has been minimized.

fuzihaofzh commented May 11, 2018

@stevem6 Yes it does. But somehow seems wired.

@ronkok ronkok referenced this issue May 12, 2018

Merged

Support \hline #1306

@edemaine

This comment has been minimized.

Member

edemaine commented May 12, 2018

\hline support is now on master, thanks to @ronkok and #1306.

@fuzihaofzh

This comment has been minimized.

fuzihaofzh commented May 13, 2018

@edemaine It's great. Looking for this feature for ages. Hope to see it soon in release.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment