Repository navigation
Refactor latex table - #3389
Refactor latex table#3389
Conversation
|
|
||
| # longtable | ||
| table = tables['longtable'] | ||
| assert ('\\begin{longtable}{|l|l|}\n\\hline' in table) |
There was a problem hiding this comment.
It seems longtable does not starts with empty line and \noindent. Is this correct?
There was a problem hiding this comment.
Yes, this is correct, longtable would not be affected by a \noindent because it behaves like a paragraph, not inline, type of object.
It admits option [l], [r], or [c] for horizontal placement, default behaviour is centering (c).
There was a problem hiding this comment.
Thanks, but I'm refactoring the writer now. So I could not merge it.
Don't mind. I will merge master branch at the end of my work :-)
|
As a first step, I added test case for tabular macros. |
| if self.table.colspec: | ||
| self.body.append(self.table.colspec) | ||
| elif self.table.colwidths: | ||
| elif self.table.colwidths and 'colwidths-given' in self.table.classes: |
There was a problem hiding this comment.
I needed to change also at line https://github.com/sphinx-doc/sphinx/pull/3389/files#diff-81c44cde8d80608ae558b93878f9be8aR1199 to let test pass
|
@tk0miya |
|
ah actually I can make a PR on your fork I guess, will check... ok, had to fight a bit with github interface which somehow was always bringing me back to sphinx repo, but it is done at tk0miya#2 |
8489786 to
976fc32
Compare
|
I just updated this pull request. It also includes the changes in master branch. I would like to continue to refactor in another pull request. |
| elif self.is_longtable(): | ||
| return '{|' + ('l|' * self.colcount) + '}\n' | ||
| else: | ||
| return '{|' + ('L|' * self.colcount) + '}\n' |
There was a problem hiding this comment.
what about (less efficient but more robust):
elif self.get_table_type() == 'tabulary':
return '{|' + ('L|' * self.colcount) + '}\n'
else:
return '{|' + ('l|' * self.colcount) + '}\n'
| @@ -0,0 +1,21 @@ | |||
| \begin{longtable}<%= table.get_colspec() %> | |||
There was a problem hiding this comment.
there is possibility in future to add [c|l|r] option here for horizontal alignment. (new :align: option of Docutils 0.13)
| return 'longtable' | ||
| elif self.has_verbatim: | ||
| return 'tabular' | ||
| elif self.has_problematic and not self.colspec: |
There was a problem hiding this comment.
the table having :widths: option uses tabulary because of that but it should use tabular
in my PR I had something like
elif self.table.has_problematic or \
(self.table.colwidths and 'colwidths-given' in self.table.classes):
other remark is that the templates produces extra blank lines in tex output. mentioning it here because I am off now for a while, will resume later ;-) congrats on great work ! ( :align: option will cause evolutions)
|
|
||
| # table having :widths: option | ||
| table = tables['table having :widths: option'] | ||
| assert ('\\noindent\\begin{tabulary}{\\linewidth}' |
There was a problem hiding this comment.
should be assert ('\\noindent\\begin{tabular}' after remark at https://github.com/sphinx-doc/sphinx/pull/3389/files#r99466224
and \end{tabular} of course
|
Merged. Thank you for reviewing! |
To improve LaTeX tables, I try to refactor the LaTeX writer.