Daniel-Diaz / HaTeX

The Haskell LaTeX library.
BSD 3-Clause "New" or "Revised" License
199 stars 46 forks source link

Position Here for Table Environment #127

Closed schnecki closed 5 years ago

schnecki commented 5 years ago

Hi, currently only the positions top, center and bottom are available. Thus it is not possible to generate

\begin{table}[h]
...
\end{table}

or even with an exclamation mark, like

\begin{table}[h!]
...
\end{table}

Thus the data Pos type seems for me to not cover all possibilities.

schnecki commented 5 years ago

Additionally, specifying multiple positions is currently also not possible, e.g.

\begin{table}[th]
...
\end{table}
Daniel-Diaz commented 5 years ago

They don't mention h neither here nor here. Interestingly enough, they do use it in two of the examples in the latter link. I guess this should be added. Does it require to import any specific package?

Thanks for the comment.

schnecki commented 5 years ago

They actually do. But not at the tabular environment, but the explanation of the table environment. Look at the here. Afaik it does not need any specific packages.

Daniel-Diaz commented 5 years ago

Oh, great, now I can't even read. :sweat_smile:

I will add it shortly.

Daniel-Diaz commented 5 years ago

@schnecki Does this look good to you?

https://github.com/Daniel-Diaz/HaTeX/commit/443de57d6755c245061c15adc28203c014c97bc6

schnecki commented 5 years ago

Haha, well shi** happens :grin:

I am fine with that, but by using the same data structure for two different kinds of locations, you allow a Here at the tabular environments as well. This might cause errors during compilation. But I think that's the better way instead of using prefixes to be able to distinguish between two different location data structures. So looks good to me :+1:

schnecki commented 5 years ago

Well actually I just figured that table only takes a Maybe Pos instead of a Maybe [Pos] which would allow a list of positions as for instance in

\begin[tb!]{table}
...

Cf. "Default is tbp, which means that it is by default placed on the top of the page. If that's not possible, it's placed at the bottom if possible, or finally with other floating environments on an extra page." (just below the html-table explaining the table positions of the previous link)

However, this would be a breaking change I fear :fearful:

Daniel-Diaz commented 5 years ago

Haha, well shi** happens

I am fine with that, but by using the same data structure for two different kinds of locations, you allow a Here at the tabular environments as well. This might cause errors during compilation. But I think that's the better way instead of using prefixes to be able to distinguish between two different location data structures. So looks good to me

Yes, I wrote a warning about this in the docs.

Well actually I just figured that table only takes a Maybe Pos instead of a Maybe [Pos] which would allow a list of positions as for instance in

\begin[tb!]{table}
...

Cf. "Default is tbp, which means that it is by default placed on the top of the page. If that's not possible, it's placed at the bottom if possible, or finally with other floating environments on an extra page." (just below the html-table explaining the table positions of the previous link)

However, this would be a breaking change I fear

Yes, that would be a breaking change, but the current type seems wrong, since it doesn't allow something one should be able to do. I think it will be better long-term to make the change.

Also, I would rather use [Pos] instead of Maybe [Pos], and use [] to not provide the optional position and use the default.

schnecki commented 5 years ago

Yeah true that makes sense :+1:

Daniel-Diaz commented 5 years ago

This commit makes table accept a list of positions: https://github.com/Daniel-Diaz/HaTeX/commit/436ce2809e396d93ddc3154f933b0c0bec3c88ac