reddit / emacs

Org export to pdf gives error: Stopping because of bad filename

FloppyEggplant · 2022-10-23 15:03
Hi, When I try to export an org file to pdf it always gives the error: Stopping because of bad filename. Latexmk: Filename '~/notes/exports/20220825222250-beamer_presentation_example.tex' contains character not allowed for TeX file. Latexmk: Stopping because of bad filename(s). I believe it is because the home directory is specified with a tilde character. How can I fix this error?
CannibalismIsNatural · 2022-10-23 18:10
Try using the full path instead of the ~.
FloppyEggplant · 2022-10-23 18:40
I believe the problem lies in the function `org-export-output-file-name` that returns the current buffer path with a `~`. I don't understand why though, as the visited-file variable has the correct value: `(visited-file (buffer-file-name (buffer-base-buffer)))`, it returns the full path to the current buffer file. ​ **Edit**: forget it, I've set my export folder as `"~/notes/export"`, when org reads this variable, it takes the path as I wrote it.
tecosaur · 2022-10-24 01:31
How did you set the export folder?
FloppyEggplant · 2022-10-24 08:37
I've used this function, don't remember where I've seen it though: (defun org-export-output-file-name-modified (orig-fun extension &optional subtreep pub-dir) "Change the directory where exported files will go to." (unless pub-dir (setq pub-dir (concat org-roam-directory "/exports")) (unless (file-directory-p pub-dir) (make-directory pub-dir))) (apply orig-fun extension subtreep pub-dir nil)) (advice-add 'org-export-output-file-name :around #'org-export-output-file-name-modified)