mirror of
https://git.savannah.gnu.org/git/emacs/org-mode.git
synced 2024-09-05 10:12:55 +00:00
ox-latex: Do not use float for inline images inside links
* lisp/ox.el (org-export-insert-image-links): Fix call to `org-element-set-contents' - setting "nil" literally would put an actual nil element into contents. * lisp/ox-latex.el (org-latex--inline-image): Do not use float environment unless the inline image is a single image inside paragraph. The code is adapted with simplifications from `org-html-standalone-image-p'. * testing/lisp/test-ox-latex.el (test-ox-latex/inline-image): New test. Reported-by: Dr. Arne Babenhauserheide <arne_bab@web.de> Link: https://orgmode.org/list/878rest3qv.fsf@localhost
This commit is contained in:
parent
59238cfa82
commit
38c6eb2b72
|
@ -2741,7 +2741,24 @@ 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)
|
||||
(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)
|
||||
|
|
|
@ -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))))))))
|
||||
|
|
|
@ -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
|
||||
|
|
Loading…
Reference in a new issue