Skip to content
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

Docx: separate format style for tables #2033

Closed
tolot27 opened this issue Mar 28, 2015 · 10 comments
Closed

Docx: separate format style for tables #2033

tolot27 opened this issue Mar 28, 2015 · 10 comments

Comments

@tolot27
Copy link
Contributor

tolot27 commented Mar 28, 2015

Because the compact style in docx files is used not only by compact lists, but also for table cells, it is not possible to give tables their own look.

Hence, I propose a different style which is only applied to tables.

@lierdakil
Copy link
Contributor

That's going to be a little hard. Consider for example the case when there is a compact list inside a table cell. Pandoc uses Plain AST element for table cells, same as for compact list items. How to differentiate between them?

@tolot27
Copy link
Contributor Author

tolot27 commented Mar 29, 2015

Currently, I know nearly nothing about the implementation side in pandoc and why it represents two different syntactic and symantic elements as the same AST element. Is this intentional or just caused by code evolution?

From the users point of view I guess that having a compact list inside a table is much less frequent than having simple tables and compact lists outside of tables. Hence the benefit of a "plain table style" would outweight the rare cases of compact lists inside tables.

But indeed, an inconsistency would be introduced at the same time.

@tolot27
Copy link
Contributor Author

tolot27 commented Mar 29, 2015

As far as I can see, pandoc allows lists inside tables only for grid tables and the extension grid_tables is enabled by default. But to recognize these lists inside a table cell and format them in writers correctly, they have to be distinguishable from plain cells, already.

@lierdakil
Copy link
Contributor

Pandoc's AST does not make any distinction between different table
definition methods offered by Markdown, since it does not make sense for
most supported formats anyway (think html->docx for example). Hence, table
is just a table. And table cells are block-level elements, Plain being
the simplest.
Docx also does not offer a distinction between table cells and general
paragraphs, so I'm really not sure how to implement what you're asking for
in an unambiguous way...

2015-03-29 20:48 GMT+03:00 Mathias Walter notifications@github.com:

As far as I can see, pandoc allows lists inside tables only for grid
tables and the extension grid_tables is enabled by default. But to
recognize this lists inside a table cell and format them in writers
correctly, it have to be distinguishable from plain cells, already.


Reply to this email directly or view it on GitHub
#2033 (comment).

@tolot27
Copy link
Contributor Author

tolot27 commented Mar 29, 2015

You are right in that way that in Word there is no predefined style for tables. But there are themes available for tables and you can create a custom style with style type 'table' and can define first, last, even, odd rows, etc.
There is no reason against just defining a table style (based on standard paragraph style) and apply it to the whole table. If a table cell contains a list, it can be formatted as compact or an additional style 'List in Table Cell' can be applied to it.

BTW: There are some predefined styles for (un-)numbered lists. Personally, I would use those styles for the different kind of lists pandoc can generate, rather than the compact style.

@lierdakil
Copy link
Contributor

Lists in Word are... weird, let's leave it at that for now. It would be a very non-trivial thing to use list styles on lists, as unintuitive as it might sound. I might tackle this later, but not for a while most likely.

As for tables, I could probably hack together a solution for most-used case, i.e. plain text in cells, but it will probably be hacky as hell, so I'm not sure it is the right thing to do. It is possible to do with a filter though (yes, yes, I know, answer to every other request seems to be "use a filter", but that's kind of how it is...)

@jgm
Copy link
Owner

jgm commented Mar 17, 2017

See also #774 which is more general.

@gepcel
Copy link

gepcel commented Dec 10, 2017

This will be very useful.

I recently used pandoc to generate some docx format reports. When set indent: true, the contents of table were also indented. Couldn't find a way to un-indent table contents only.

Anyone working on this?

@cmwint
Copy link

cmwint commented May 1, 2018

I am having a very similar problem as @tolot27. I am converting HTML to DOCX, and I have li and ul tags in my html. I also have tables in my HTML. However, I want the lists and the tables to have a different font size. Both are using the compact style in Word, but I can't figure out how to differentiate tables and lists.

Has anyone been able to do this? Would you please point me in the right direction? Thank you so much for your help.

@ociule
Copy link

ociule commented Jan 24, 2019

This can be closed, IMO, as pandoc 2.2.1 uses the "Table" table style from the reference-doc now.

@jgm jgm closed this as completed Jan 24, 2019
gregelin pushed a commit to GovReady/govready-q that referenced this issue Jan 19, 2021
This PR changes the `Table` style in the custom-reference.docx
file in order to create a better looking table in generatee SSP
and other documents.

Pandoc prior 2.2.0 and earlier used `Compact` style for styling
tables. Pandoc 2.2.1 and higher use `Table` style for styling
tables.

See: jgm/pandoc#2033 (comment)
gregelin added a commit to GovReady/govready-q that referenced this issue Jan 20, 2021
This PR changes the `Table` style in the custom-reference.docx
file in order to create a better looking table in generatee SSP
and other documents.

Pandoc prior 2.2.0 and earlier used `Compact` style for styling
tables. Pandoc 2.2.1 and higher use `Table` style for styling
tables.

See: jgm/pandoc#2033 (comment)

Co-authored-by: Greg Elin <greg.elin@govready.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

7 participants