* figures not exported properly by ox-latex
@ 2024-02-02 11:39 mahmood sheikh
2024-02-02 11:46 ` Ihor Radchenko
2024-07-09 20:15 ` Karthik Chikmagalur
0 siblings, 2 replies; 9+ messages in thread
From: mahmood sheikh @ 2024-02-02 11:39 UTC (permalink / raw)
To: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 612 bytes --]
im on tecosaur's dev branch (version 9.7-pre)
i have the following in an org file:
```org
#+name: fig-switching-circuit-1
#+caption: implementation of \(p\)
[[attachment:circuit.svg]]
```
it gets turned into this
```
\includesvg[width=.9\linewidth]{/home/mahmooz/brain/notes/data/9e/5ba2ce-c383-4396-a2cb-891465f14d51/circuit}\\[0pt]
```
which isnt the behavior described in the docs:
> When captions follow the method as described in Captions, the LaTeX
export back-end wraps the picture in a floating ‘figure’ environment.
this is from https://orgmode.org/manual/Images-in-LaTeX-export.html
[-- Attachment #2: Type: text/html, Size: 788 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-02-02 11:39 figures not exported properly by ox-latex mahmood sheikh
@ 2024-02-02 11:46 ` Ihor Radchenko
2024-07-05 9:20 ` mahmood sheikh
2024-07-09 20:15 ` Karthik Chikmagalur
1 sibling, 1 reply; 9+ messages in thread
From: Ihor Radchenko @ 2024-02-02 11:46 UTC (permalink / raw)
To: mahmood sheikh, Timothy, Karthik Chikmagalur; +Cc: emacs-orgmode
mahmood sheikh <mahmod.m2015@gmail.com> writes:
> im on tecosaur's dev branch (version 9.7-pre)
> i have the following in an org file:
>...
CCing Timothy and Karhik.
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-02-02 11:46 ` Ihor Radchenko
@ 2024-07-05 9:20 ` mahmood sheikh
0 siblings, 0 replies; 9+ messages in thread
From: mahmood sheikh @ 2024-07-05 9:20 UTC (permalink / raw)
To: Ihor Radchenko; +Cc: Timothy, Karthik Chikmagalur, emacs-orgmode
[-- Attachment #1.1: Type: text/plain, Size: 860 bytes --]
hi,
i made a slight change to wrap the exported latex environments in a figure
environment so that the captions and labels get placed properly, this patch
i created on teco's branch.
i dont expect it to get accepted as it may be a naive fix and i may be
missing something, but it may point out to someone else where the issue is.
thanks!
On Fri, Feb 2, 2024 at 1:43 PM Ihor Radchenko <yantar92@posteo.net> wrote:
> mahmood sheikh <mahmod.m2015@gmail.com> writes:
>
> > im on tecosaur's dev branch (version 9.7-pre)
> > i have the following in an org file:
> >...
>
> CCing Timothy and Karhik.
>
> --
> Ihor Radchenko // yantar92,
> Org mode contributor,
> Learn more about Org mode at <https://orgmode.org/>.
> Support Org development at <https://liberapay.com/org-mode>,
> or support my work at <https://liberapay.com/yantar92>
>
[-- Attachment #1.2: Type: text/html, Size: 1515 bytes --]
[-- Attachment #2: latex_env_captions.patch --]
[-- Type: text/x-patch, Size: 534 bytes --]
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 46a3cae..11c3fc5 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -3005,7 +3005,10 @@ CONTENTS is nil. INFO is a plist holding contextual information."
;; the section instead). Also insert caption if `latex-environment'
;; is not a math environment.
(with-temp-buffer
+ (insert "\\begin{figure}\n")
(insert value)
+ (goto-char (point-max))
+ (insert "\\end{figure}")
(if caption-above-p
(progn
(goto-char (point-min))
^ permalink raw reply related [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-02-02 11:39 figures not exported properly by ox-latex mahmood sheikh
2024-02-02 11:46 ` Ihor Radchenko
@ 2024-07-09 20:15 ` Karthik Chikmagalur
2024-07-11 8:39 ` mahmood sheikh
1 sibling, 1 reply; 9+ messages in thread
From: Karthik Chikmagalur @ 2024-07-09 20:15 UTC (permalink / raw)
To: mahmood sheikh, emacs-orgmode
> im on tecosaur's dev branch (version 9.7-pre)
> i have the following in an org file:
> ```org
> #+name: fig-switching-circuit-1
> #+caption: implementation of \(p\)
> [[attachment:circuit.svg]]
> ```
> it gets turned into this
> ```
> \includesvg[width=.9\linewidth]{/home/mahmooz/brain/notes/data/9e/5ba2ce-c383-4396-a2cb-891465f14d51/circuit}\\[0pt]
> ```
Cannot reproduce. I get the following:
\begin{figure}[htbp]
\centering
\includesvg[width=.9\linewidth]{/tmp/circuit}
\caption{\label{fig-switching-circuit-1}implementation of \(p\)}
\end{figure}
Perhaps you have customized the LaTeX export process in some way? Also
note that we don't touch any of the LaTeX generation code in ox-latex
except the parts handling LaTeX preview images.
Karthik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-07-09 20:15 ` Karthik Chikmagalur
@ 2024-07-11 8:39 ` mahmood sheikh
2024-07-11 8:46 ` Ihor Radchenko
2024-07-11 8:47 ` Karthik Chikmagalur
0 siblings, 2 replies; 9+ messages in thread
From: mahmood sheikh @ 2024-07-11 8:39 UTC (permalink / raw)
To: Karthik Chikmagalur; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 1277 bytes --]
it might've been fixed for figures as its been a while, but shouldnt latex
environments with #+caption: and #+name: above them be exported as figures?
because currently the user has to write \begin{figure} and \end{figure}
explicitly which would work but may not be as practical for other ox
backends like html i think? perhaps im wrong.
On Tue, Jul 9, 2024 at 11:15 PM Karthik Chikmagalur <
karthikchikmagalur@gmail.com> wrote:
> > im on tecosaur's dev branch (version 9.7-pre)
> > i have the following in an org file:
> > ```org
> > #+name: fig-switching-circuit-1
> > #+caption: implementation of \(p\)
> > [[attachment:circuit.svg]]
> > ```
> > it gets turned into this
> > ```
> >
> \includesvg[width=.9\linewidth]{/home/mahmooz/brain/notes/data/9e/5ba2ce-c383-4396-a2cb-891465f14d51/circuit}\\[0pt]
> > ```
>
> Cannot reproduce. I get the following:
>
> \begin{figure}[htbp]
> \centering
> \includesvg[width=.9\linewidth]{/tmp/circuit}
> \caption{\label{fig-switching-circuit-1}implementation of \(p\)}
> \end{figure}
>
> Perhaps you have customized the LaTeX export process in some way? Also
> note that we don't touch any of the LaTeX generation code in ox-latex
> except the parts handling LaTeX preview images.
>
> Karthik
>
[-- Attachment #2: Type: text/html, Size: 1651 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-07-11 8:39 ` mahmood sheikh
@ 2024-07-11 8:46 ` Ihor Radchenko
2024-07-11 8:47 ` Karthik Chikmagalur
1 sibling, 0 replies; 9+ messages in thread
From: Ihor Radchenko @ 2024-07-11 8:46 UTC (permalink / raw)
To: mahmood sheikh; +Cc: Karthik Chikmagalur, emacs-orgmode
mahmood sheikh <mahmod.m2015@gmail.com> writes:
> it might've been fixed for figures as its been a while, but shouldnt latex
> environments with #+caption: and #+name: above them be exported as figures?
> because currently the user has to write \begin{figure} and \end{figure}
> explicitly which would work but may not be as practical for other ox
> backends like html i think? perhaps im wrong.
It looks like your original problem is not reproducible, and you are
talking about a _different_ problem now.
May you please provide an example of what kind of behavior you are
talking about?
--
Ihor Radchenko // yantar92,
Org mode contributor,
Learn more about Org mode at <https://orgmode.org/>.
Support Org development at <https://liberapay.com/org-mode>,
or support my work at <https://liberapay.com/yantar92>
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-07-11 8:39 ` mahmood sheikh
2024-07-11 8:46 ` Ihor Radchenko
@ 2024-07-11 8:47 ` Karthik Chikmagalur
2024-07-11 8:59 ` mahmood sheikh
1 sibling, 1 reply; 9+ messages in thread
From: Karthik Chikmagalur @ 2024-07-11 8:47 UTC (permalink / raw)
To: mahmood sheikh; +Cc: emacs-orgmode
> it might've been fixed for figures as its been a while, but shouldnt
> latex environments with #+caption: and #+name: above them be exported
> as figures? because currently the user has to write \begin{figure} and
> \end{figure} explicitly which would work
This is not the case. The LaTeX output I posted in my previous response
was the exported output from your example Org source. I did not add the
\begin{figure} and \end{figure} tags manually.
Karthik
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-07-11 8:47 ` Karthik Chikmagalur
@ 2024-07-11 8:59 ` mahmood sheikh
2024-07-11 12:47 ` mahmood sheikh
0 siblings, 1 reply; 9+ messages in thread
From: mahmood sheikh @ 2024-07-11 8:59 UTC (permalink / raw)
To: Karthik Chikmagalur; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 2281 bytes --]
this is an example of what i mean:
#+begin_src org
#+name: fig-switching-circuit-kmap-1
#+caption: karnaugh table of \(p\)
\begin{tikzpicture}
\karnaughmap[function=, defaultmap=8, omitzeros=false, omitidx,
variables=xyz]{01101001}
\end{tikzpicture}
#+end_src
i vaguely recall org mode automatically turning captioned
tikzpicture's into figures by wrapping them in a figure environment.
currently, this is what i get when i export to latex:
#+begin_src latex
\begin{tikzpicture}
\karnaughmap[function=, defaultmap=8, omitzeros=false, omitidx,
variables=xyz]{01101001}
\caption{\label{fig-switching-circuit-kmap-1}karnaugh table of \(p\)}
\end{tikzpicture}
a tikzpicture environment doesnt expect a \caption and therefore this gives
an error. to avoid this the environment has to be wrapped manually by the
user by a \begin{figure} environment, but i think this may be redundant
because anything that takes a #+caption is expected to be a figure.
also, ox-html doesnt handle those anymore, it used to handle #+caption: and
insert it into the generated html output, it simply ignores that now.
example:
#+begin_src org
#+name: fig-switching-circuit-1
#+caption: implementation of \(p\)
[[attachment:circuit.svg]]
#+end_src
ox-html generates the following html:
#+begin_src html
<img src="/circuit.svg" /><br />
#+end_src
its not a different problem, its basically that after the new overhaul
figures are being handled differently than i recall, but i cant say for
sure. although the report above about the exported circuit.svg img does
make sense even if it wasnt handled the way i'd expect before the overhaul.
thanks
On Thu, Jul 11, 2024 at 11:47 AM Karthik Chikmagalur <
karthikchikmagalur@gmail.com> wrote:
> > it might've been fixed for figures as its been a while, but shouldnt
> > latex environments with #+caption: and #+name: above them be exported
> > as figures? because currently the user has to write \begin{figure} and
> > \end{figure} explicitly which would work
>
> This is not the case. The LaTeX output I posted in my previous response
> was the exported output from your example Org source. I did not add the
> \begin{figure} and \end{figure} tags manually.
>
> Karthik
>
[-- Attachment #2: Type: text/html, Size: 2784 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
* Re: figures not exported properly by ox-latex
2024-07-11 8:59 ` mahmood sheikh
@ 2024-07-11 12:47 ` mahmood sheikh
0 siblings, 0 replies; 9+ messages in thread
From: mahmood sheikh @ 2024-07-11 12:47 UTC (permalink / raw)
To: Karthik Chikmagalur; +Cc: emacs-orgmode
[-- Attachment #1: Type: text/plain, Size: 3859 bytes --]
im fairly certain that at the time i sent this email, ox-latex was failing
to insert \label and \caption too after images in latex exports (like
ox-html to html exports). but perhaps someone made a change that fixed that.
the fact that ox-latex even inserts \caption and \label tells me that it
was the intention of the maintainer of ox-latex to handle latex blocks
preceded by a `#+caption` as figures. so it would be natural if org
inserted the figure environment itself like it does with images preceded by
`#+caption`. i hope this reasoning does make sense to you?
in ox-html, the function `org-html--wrap-image` is used to wrap an exported
image with a `<figure>` html environment with a caption and label, but it
doesnt happen for me.
after some more digging, i think inserting the `figure` environments
automatically in latex exports may be undesired behavior and it would be
preferred that the user do that themselves in the org document, because
`org-latex--caption/label-string` checks for a `figure` or `listing`
environment apparently, which tells me that the author expected the user to
insert the figure environment themselves. another reason is that the user
may use another, differently environment that accepts a \caption too.
thanks
p.s. sorry i keep hitting the "forward" button instead of the "forward all"
button so you may receive duplicate emails.
On Thu, Jul 11, 2024 at 11:59 AM mahmood sheikh <mahmod.m2015@gmail.com>
wrote:
> this is an example of what i mean:
> #+begin_src org
> #+name: fig-switching-circuit-kmap-1
> #+caption: karnaugh table of \(p\)
> \begin{tikzpicture}
> \karnaughmap[function=, defaultmap=8, omitzeros=false, omitidx,
> variables=xyz]{01101001}
> \end{tikzpicture}
> #+end_src
> i vaguely recall org mode automatically turning captioned
> tikzpicture's into figures by wrapping them in a figure environment.
> currently, this is what i get when i export to latex:
> #+begin_src latex
> \begin{tikzpicture}
> \karnaughmap[function=, defaultmap=8, omitzeros=false, omitidx,
> variables=xyz]{01101001}
> \caption{\label{fig-switching-circuit-kmap-1}karnaugh table of \(p\)}
> \end{tikzpicture}
> a tikzpicture environment doesnt expect a \caption and therefore this
> gives an error. to avoid this the environment has to be wrapped manually by
> the user by a \begin{figure} environment, but i think this may be redundant
> because anything that takes a #+caption is expected to be a figure.
> also, ox-html doesnt handle those anymore, it used to handle #+caption:
> and insert it into the generated html output, it simply ignores that now.
> example:
> #+begin_src org
> #+name: fig-switching-circuit-1
> #+caption: implementation of \(p\)
> [[attachment:circuit.svg]]
> #+end_src
> ox-html generates the following html:
> #+begin_src html
> <img src="/circuit.svg" /><br />
> #+end_src
> its not a different problem, its basically that after the new overhaul
> figures are being handled differently than i recall, but i cant say for
> sure. although the report above about the exported circuit.svg img does
> make sense even if it wasnt handled the way i'd expect before the overhaul.
> thanks
>
> On Thu, Jul 11, 2024 at 11:47 AM Karthik Chikmagalur <
> karthikchikmagalur@gmail.com> wrote:
>
>> > it might've been fixed for figures as its been a while, but shouldnt
>> > latex environments with #+caption: and #+name: above them be exported
>> > as figures? because currently the user has to write \begin{figure} and
>> > \end{figure} explicitly which would work
>>
>> This is not the case. The LaTeX output I posted in my previous response
>> was the exported output from your example Org source. I did not add the
>> \begin{figure} and \end{figure} tags manually.
>>
>> Karthik
>>
>
[-- Attachment #2: Type: text/html, Size: 4617 bytes --]
^ permalink raw reply [flat|nested] 9+ messages in thread
end of thread, other threads:[~2024-07-11 12:49 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-02-02 11:39 figures not exported properly by ox-latex mahmood sheikh
2024-02-02 11:46 ` Ihor Radchenko
2024-07-05 9:20 ` mahmood sheikh
2024-07-09 20:15 ` Karthik Chikmagalur
2024-07-11 8:39 ` mahmood sheikh
2024-07-11 8:46 ` Ihor Radchenko
2024-07-11 8:47 ` Karthik Chikmagalur
2024-07-11 8:59 ` mahmood sheikh
2024-07-11 12:47 ` mahmood sheikh
Code repositories for project(s) associated with this public inbox
https://git.savannah.gnu.org/cgit/emacs/org-mode.git
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).