How to deal with recursive includes?
gpetrini opened this issue · 18 comments
First of all, thank you a lot for this repo!
There is one thing that I cannot manage yet: how do you deal with relative paths?
For example, let's say that I have a folder thesis
and a subfolder called research-chapter
. In addition, I have a latex table (I cannot create it with org synthax) in ./thesis/research-chapter/tabs/table.tex
. Inside ./research-chapter/manuscript.org
I used
\input{./tabs/table.tex}
However, it is not detected by ./thesis/thesis.org
(which has #+include:./research-chapter/manuscript.org
). I tried to generate symbolic links, but this not seems to be a good solution. Do you recommend to use absolute paths instead?
If my pseudo-coded is not clear, I can provide the real file.
Thank you once more
Hi @gpetrini,
I've been meaning to clean up this repo for about 4 years but haven't come around to.
The issues here (to my understanding) is that you are using latex syntax instead of org-mode syntax, which means that the latex is not parsed by org-mode during inclusion, and is copied as is. I would suggest mixing org-mode include and latex include, since that only increases complexity.
Potential solutions:
- wrap your entire table into an export latex block and make the file a table.org
- This is my preferred solution because 1. you can add org mode comments to the file and 2. you can always just export the tex directly again, so nothing is lost.
- place the table inline
- use absolute paths for latex inclusions. I also don't see what the issue is with symbolic links - they exist for a reason, no shame using them either.
Let me know how that goes.
Regards,
Daniel
Hi @dangom,
Thank you for your quick response. I tried to wrap my tables in export blocks as you suggested and it worked!
However, I still cannot include figures in the thessis. This is unexpected because I am using the org-syntax in this case.
Here is the code:
#+caption: Expectational Vs. effective aggregate market-share (synthetic data)
#+attr_latex: :label ch_dotcom_fig_artificial_bubble :placement [htb]
[[file:./figs/Ch_DotCom_Stylized_Bubble.pdf]]```
Do you have any suggestions?
What's your Emacs/org-mode version?
No, the inclusion should work. There was an old bug with org-mode that would lead to this happening. I fixed it some 4,5 years ago, that's why I was wondering whether you weren't running an older org-mode version.
So you are using the org-mode inclusion mechanism and your path is not being updated? Does this work if you use non-pdfs as figures? Does this work if you remove the attr_latex
?
I am using org-mode version 9.6, so I think your fix is included.
For including figure, I am using the link syntax as in your example and the path is not updated.
I tried using png, using #+include
syntax and remove attr_latex
and got the same result :(
I guess that the problem is related to how org translate its own syntax to latex.
The code that I sent to you earlier is the following in thesis.tex
:
\begin{figure}[htb]
\centering
\includegraphics[width=.9\linewidth]{./figs/Ch_DotCom_Stylized_Bubble.png}
\caption{\label{ch_dotcom_fig_artificial_bubble}Expectational Vs. effective aggregate market-share (synthetic data)}
\end{figure}
I gues that the path is not being updated as you mentioned.
Can you get the thesis.org example to compile properly? Run C-c C-e l p
on thesis.org?
It works at my end and updates the path from the image at the research chapter. Both thesis and manuscript work.
Do you get the same issue there?
Yep, I get the same issue here.
Aparently, the path is not updated.
Here is the error message:
Unable to read file "/home/gpetrini/Documents/org-thesis/thesis/manuscript.setup" [6 times]
org-babel-exp process elisp at position 5084...
Executing Elisp unknown (code)...
Code block evaluation complete.
Wrote /home/gpetrini/.emacs.d/.local/cache/undo-tree-hist/.d7a85b2b2517a4905bfe581b783bcffbea1411e0.~undo-tree~.zst
org-latex-headline: Wrong type argument: number-or-marker-p, nil
The first line suggest that it is looking for a file inside thesis
, but it should be looked insed research-chapter
.
I don't know if it helps, but I am using doom emacs.
I cannot reproduce. To debug this at your end I would call edebug-defun
on org-export--prepare-file-contents
, and then check what's going on by exporting the thesis to pdf and then stepping through the link conversion with edebug.
I tried what you mention and I have no clues. It seems that none of the paths are updated.
For example, if a have a #+setupfile:manuscript.setup
inside manuscript
folder, it works fine for the research paper.
However, the thesis.org
file searches for a #+setupfile:manuscript.setup
as it is, not updating the path.
Update: I was able to reproduce your pdf by just adapting the thesis.setup file.
Thus, the problem is not related to org or emacs I guess.
Possibly, I need to adjust the files at my end.
Do you have any suggestion on how to debug it?
Thanks for your help.
I think I figured it out.
My research-paper.org
file also have #+include
s.
So, I think org prepares the relative links for the research-paper.org
file and uses it as it is in the thesis.org
.
Do you know how to add more recursive links?
Fell free to close this issue.
Please open an issue with a simple example of the bug at the org mailing list, so devs can help.
We'll keep this issue open until that gets fixed.
I came up with a simple workaround.
Inside thesis.org
I just replicated the contents (which have other includes) of research_paper.org
and adjusted the path for each paper section.
It is not ideial, but with that I do not need to create symbolic links.
I would just open an issue upstream; this seems like an easy fix.
Here's where to submit: https://orgmode.org/worg/org-mailing-list.html
Ok, I've just sent it.
I'll update this issue as soon as I get some answer.
Brilliant. Thanks for reporting and thanks for contributing to org-mode!
Good luck with your thesis!