diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el index 57ea66ef1..b36c46f13 100644 --- a/lisp/ox-latex.el +++ b/lisp/ox-latex.el @@ -2741,16 +2741,33 @@ used as a communication channel." ;; Retrieve latex attributes from the element around. (attr (org-export-read-attribute :attr_latex parent)) (float (let ((float (plist-get attr :float))) - (cond ((string= float "wrap") 'wrap) - ((string= float "sideways") 'sideways) - ((string= float "multicolumn") 'multicolumn) - ((string= float "t") 'figure) - ((and (plist-member attr :float) (not float)) 'nonfloat) - (float float) - ((or (org-element-property :caption parent) - (org-string-nw-p (plist-get attr :caption))) - 'figure) - (t 'nonfloat)))) + (cond + ((org-element-map (org-element-contents parent) t + (lambda (node) + (cond + ((and (org-element-type-p node 'plain-text) + (not (org-string-nw-p node))) + nil) + ((eq link node) + ;; Objects inside link description are + ;; allowed. + (throw :org-element-skip nil)) + (t 'not-a-float))) + info 'first-match) + ;; Not a single link inside paragraph (spaces + ;; ignored). Cannot use float environment. It + ;; would be inside paragraph. + nil) + ((string= float "wrap") 'wrap) + ((string= float "sideways") 'sideways) + ((string= float "multicolumn") 'multicolumn) + ((string= float "t") 'figure) + ((and (plist-member attr :float) (not float)) 'nonfloat) + (float float) + ((or (org-element-property :caption parent) + (org-string-nw-p (plist-get attr :caption))) + 'figure) + (t 'nonfloat)))) (placement (let ((place (plist-get attr :placement))) (cond diff --git a/lisp/ox.el b/lisp/ox.el index 9178d53cd..34ea32b3b 100644 --- a/lisp/ox.el +++ b/lisp/ox.el @@ -4360,7 +4360,7 @@ Return modified DATA." (or rules org-export-default-inline-image-rule)) ;; Replace contents with image link. (org-element-adopt - (org-element-set-contents l nil) + (org-element-set-contents l) (with-temp-buffer (save-excursion (insert contents)) (org-element-link-parser)))))))) diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el index 35e37e46a..41df1b823 100644 --- a/testing/lisp/test-ox-latex.el +++ b/testing/lisp/test-ox-latex.el @@ -93,5 +93,16 @@ Column & Column \\\\[0pt] "\\hline\\multicolumn{2}{r}{Continued on next page} \\\\ \\endfoot")))) +(ert-deftest test-ox-latex/inline-image () + "Test inline images." + (org-test-with-exported-text + 'latex + "#+caption: Schematic +[[https://orgmode.org/worg/images/orgmode/org-mode-unicorn.svg][file:/wallpaper.png]]" + (goto-char (point-min)) + (should + (search-forward + "\\href{https://orgmode.org/worg/images/orgmode/org-mode-unicorn.svg}{\\includegraphics[width=.9\\linewidth]{/wallpaper.png}}")))) + (provide 'test-ox-latex) ;;; test-ox-latex.el ends here