Re: figures not exported properly by ox-latex
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 `` 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 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 > > #+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 < > karthikchikmaga...@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 >> >
Re: figures not exported properly by ox-latex
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 #+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 < karthikchikmaga...@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 >
Re: figures not exported properly by ox-latex
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 < karthikchikmaga...@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 >
Re: figures not exported properly by ox-latex
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 wrote: > mahmood sheikh 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> > 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))
Re: nested blocks in org
with the given minimal example: ``` #+begin_parent #+begin_child #+end_child #+end_parent ``` the code ```lisp (org-block-map (lambda () (message "elem: %s" (org-element-at-point ``` goes through only the parent element and doesnt run the lambda on the child block the docstring of org-block-map says it iterates through src blocks but it also goes through special blocks, albeit not nested ones, i might've confused it for org-element-map as im not sure about the later functions behavior. On Sat, Feb 17, 2024 at 7:44 PM Ihor Radchenko wrote: > > [ Adding Org list back to CC; please use Reply All or wide reply to keep > the discussion public ] > > mahmood sheikh writes: > > > consider the following block > > ``` > > #+begin_solution > > #+begin_src sql > > SELECT > > CONCAT(c.first_name, ' ', c.family_name) AS name, c.customer_id, > > ... > > #+end_solution > > ``` > > the src block isnt fontified by org because it is inside another block > > ... which is just a bug in the Org fontification code. > If you try M-: (org-element-at-point) , you will see that Org does > recognize the code block. > > So ... > > > can you point me in the right direction of getting org mode to recognize > > nested blocks, > > Org already recognizes nested blocks using Org element parser. See > https://orgmode.org/worg/dev/org-element-api.html > > > ... like code highlighting for src blocks that are within > > another special block? > > See https://list.orgmode.org/87ee7c9quk.fsf@localhost/ > This is something we are working in. > To get parser-aware fontification locally, you can use a function > MATCHER (as in font-lock-keywords docstring) and invoke > `org-element-at-point' there to check context. > > > ... and getting org-element-map to iterate through both > > a parent and its child blocks all the same? > > May you elaborate? `org-element-map' iterates through everything, > including nested parent and child blocks. What did you try? > > > could modifying `org-block-regexp` to be a recursive regex be of help? > > Sorry, but it is hard to see how this is related to `org-element-map'. > > -- > 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>
nested blocks in org
can you point me in the right direction of getting org mode to recognize nested blocks, like code highlighting for src blocks that are within another special block? and getting org-element-map to iterate through both a parent and its child blocks all the same? could modifying `org-block-regexp` to be a recursive regex be of help?
figures not exported properly by ox-latex
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