Open jfbu opened 7 years ago
@tk0miya could you check https://github.com/jfbu/sphinx/commit/f545805bd9949929a5c1f5defc5a36cd898c7d2f, as far as I understand LaTeX writer visit_figure
there is lot of never executed branches due to the fact that when align
attribute exists, the wrapfigure
is used. Hence this commit removes the non executed branches. I will merge in stable if ok.
Ticket can probably be closed, seems above is no longer applicable to current version? Generated latex for me doesn't contain wrapfigure
when using alignment.
Though in my case I wish it did as I need to find a method of wrapping text. Found this ticket while searching for a solution.
Nope. A misunderstanding on my part. Docs suggest that text is supposed to wrap around both images and figures when aligned. While latex generates only wrapfigure for figures and not images.
@annanyearian The problem is still there as the :align:
triggers usage of wrapfigure
environment which behaves as reported in the topic box. Sadly wrapfigure
LaTeX environment is utterly fragile and basically is for manually edited LaTeX sources. We also see here that the caption is set to the width of the figure which is inappropriate for very narrow graphics.
The picture says it all:
Expected results
The figure appears inside the topic box.
Reproducible project / your project
Environment info
Relates: #3289.
This is other demonstration that LaTeX package
wrapfig
can not be used for robust automated placement of objects such as figures with text flow around them. Use ofwrapfigure
environment is triggered by:align:
option.I propose there is some config variable to not use
wrapfigure
environment at all.Here is result of adding to the tex file:
Of course alignment is lost. But this was just proof of concept. Actually LaTeX writer does not even need to use
figure
LaTeX float withH
, it can do its own "here" placement routine and do the caption with\sphinxcaptionof
macro recently added tosphinx.sty
for the caption, even if in deeply nested list item.There is really no way to let
wrapfig
package work robustly for Sphinx. Although it does work in some circumstances, it is trapped by too many constructs, particularly lists. LaTeX2e does not, as far as I know have any robust solution for automated flow of text around objects in a way handling page breaks etc...