Closed lidaidavid closed 1 year ago
I am sorry, I don't understand what it would solve. Can you post an example of a simple Word document or a sreenshot that contains what you think is not possible?
Thank you for your reply. Say my template is the .docx file called 'example-template.docx'. The main text is using the style 'Normal' which has an indentation of two characters. With it, I knit a .docx called 'table-separate-style.docx' containing a flextable (the code is printed in the docx file).
The problem is, the content of the flextable in 'table-separate-style.docx' also has an indentation of two characters, which I don't want. I can't deal with it in the template file, because the style is 'Normal'. If I remove indentation in 'Normal', my main text will lose the indentation, which I don't want.
Is there a way to keep the indentation for my main texts, not for my table contents?
Thank you so much for your help.
Thanks and sorry, I was not aware of this annoying issue
Could you try to update officer (davidgohel/officer)? I think I fixed the issue
Thank you. I have updated officer, officedown, flextable, all to the latest version. It seems that the content of a flextable is still by default 'Normal', and the problem remains.
I don't know how I should use officer to change the style of the content of a flextable. In officer, there is the function table_stylenames which seems to do that, but I don't know how it should be used with a flextable object. The example in the documentation is using body_add_table(), which I'm not sure can be used to knit a document with a flextable.
Could you please clarify? Thank you very much!
content of a flextable is still by default 'Normal'
It is not set by flextable, that is Word that set it to Normal. Your issue was about firstIndent associated with Normal Style. The fix is about setting explicitly firstIndent to 0.
Could you please clarify
remotes::install_github("davidgohel/officer")
Great! Thanks, now it works. I look forward to your future works! Flextable is by far the best at making tables with Word.
This old thread has been automatically locked. If you think you have found something related to this, please open a new issue and link to this old issue if necessary.
I've been working with flextable for quite some time and I appreciate your hard work. I'd like to know if it is possible to set spefic style (from the docx template) for the body of a flextable?
This is a frequent problem for Chinese users. As I understand it, the content of flextable uses the Normal style by default and there is no way of changing it. However, in Chinese all paragraphs have indentation at the first line while no indentation in a table. We can't have them both work correctly by changing the style in the template. This is a major problem for every Chinese user who uses flextable.
In your earlier response, you suggested to use padding in as_paragraph() rather than adding a feature to change indentation. That won't fix this issue because even when padding is set to be 0, indentation is still here. We also cannot change the style in the yaml to fix this issue because as you said in another prior response, flextable doesn't use word style and one should use officedown.
I wonder if it is possible to add a feature to set the style name of the content of a flextable as you have done for the set_caption() function. In that way, we can create a new style in the template and let the body of a flextable to follow that style.