emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: John Kitchin <jkitchin@andrew.cmu.edu>
To: Emacs Orgmode <emacs-orgmode@gnu.org>
Subject: Troubleshooting empty *Org PDF LaTeX Output*
Date: Sat, 29 Apr 2023 08:59:12 -0400	[thread overview]
Message-ID: <CALEYq0_t38_gsmjE-qgPCX07-V0P8FYwYEt9R4AT0dZ_SnXRuA@mail.gmail.com> (raw)

[-- Attachment #1: Type: text/plain, Size: 3108 bytes --]

For a while the *Org PDF LaTeX Output* buffer has been empty for me when I
export to PDF.

I am currently using: Org mode version 9.7-pre (release_9.6.4-337-geaf274

It looks like this happens because of this code:

https://git.sr.ht/~bzg/org-mode/tree/main/item/lisp/ox-latex.el#L4313

It seems to have been added in
commit f0dfbf0c3999e44ef7b6704e6584aa2a5d43f2d8

Author: TEC <git@tecosaur.net>

Date:   Sun Dec 25 00:59:21 2022 +0800


    ox-latex: Erase compile buffer at the start



    * lisp/ox-latex.el (org-latex-compile): Before running the compile

    command, erase the log buffer to ensure that stale/old logging is

    cleared.


It seems like it is in the wrong place though, and it erases the buffer
after the compile happens.

It looks like the code should be modified to look like something like this:

(defun org-latex-compile (texfile &optional snippet)
  "Compile a TeX file.

TEXFILE is the name of the file being compiled.  Processing is
done through the command specified in `org-latex-pdf-process',
which see.  Output is redirected to \"*Org PDF LaTeX Output*\"
buffer.

When optional argument SNIPPET is non-nil, TEXFILE is a temporary
file used to preview a LaTeX snippet.  In this case, do not
create a log buffer and do not remove log files.

Return PDF file name or raise an error if it couldn't be
produced."
  (unless snippet (message "Processing LaTeX file %s..." texfile))
  (let* ((compiler
 (or (with-temp-buffer
(save-excursion (insert-file-contents texfile))
(and (search-forward-regexp (regexp-opt org-latex-compilers)
   (line-end-position 2)
   t)
    (progn (beginning-of-line) (looking-at-p "%"))
    (match-string 0)))
              ;; Cannot find the compiler inserted by
              ;; `org-latex-template' -> `org-latex--insert-compiler'.
              ;; Use a fallback.
              org-latex-compiler))
(process (if (functionp org-latex-pdf-process) org-latex-pdf-process
   ;; Replace "%latex" with "%L" and "%bib" and
   ;; "%bibtex" with "%B" to adhere to `format-spec'
   ;; specifications.
   (mapcar (lambda (command)
     (replace-regexp-in-string
                               "%\\(?:\\(?:bib\\|la\\)tex\\|bib\\)\\>"
      (lambda (m) (upcase (substring m 0 2)))
      command))
   org-latex-pdf-process)))
         (spec `((?B . ,(shell-quote-argument org-latex-bib-compiler))
                 (?L . ,(shell-quote-argument compiler))))
(log-buf-name "*Org PDF LaTeX Output*")
         (log-buf (and (not snippet) (get-buffer-create log-buf-name)))
         (outfile))
    (with-current-buffer log-buf
      (erase-buffer))
    (setq outfile (org-compile-file texfile process "pdf"
   (format "See %S for details" log-buf-name)
   log-buf spec))
    (org-latex-compile--postprocess outfile log-buf snippet)
    ;; Return output file name.
    outfile))

WDYT?
-- 
John

-----------------------------------
Professor John Kitchin (he/his)
Doherty Hall A207F
Department of Chemical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
412-268-7803
https://kitchingroup.cheme.cmu.edu
https://pointbreezepubs.gumroad.com/ pycse bookstore

[-- Attachment #2: Type: text/html, Size: 4323 bytes --]

             reply	other threads:[~2023-04-29 13:00 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-04-29 12:59 John Kitchin [this message]
2023-04-30  8:18 ` Troubleshooting empty *Org PDF LaTeX Output* Ihor Radchenko

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=CALEYq0_t38_gsmjE-qgPCX07-V0P8FYwYEt9R4AT0dZ_SnXRuA@mail.gmail.com \
    --to=jkitchin@andrew.cmu.edu \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).