emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: Bug: Percentage in caption (even escaped) does not work in LaTeX exp


From: Maxim Nikulin
Subject: Re: Bug: Percentage in caption (even escaped) does not work in LaTeX export
Date: Fri, 3 Sep 2021 19:17:25 +0700
User-agent: Mozilla/5.0 (X11; Linux x86_64; rv:78.0) Gecko/20100101 Thunderbird/78.11.0

On 30/07/2021 22:00, Charest, Luc wrote:
    I simplified the problem down to :

#+CAPTION: Org Mode works 99.99\% of the time.
#+BEGIN_SRC -n
// this is only a proof of concept
#+END_SRC

As soon as I put the percentage sign in the caption, the LaTeX export backend fails with this message :

org-latex-src-block: Not enough arguments for format string

Confirmed

User input is combined with format string in `org-latex-src-block' so percent character in caption is treated as a format specifier. Maybe emacs versions newer than 26 does not throw an error on extra specifier with missed argument. =:latex-cation-above nil= might still cause corrupted LaTeX code.

Code of `org-latex-src-block' is quite convoluted to provide a quick fix. Besides particular reported case it is better to check variants with listings and minted packages, custom environment.

Absence of language and line numbering option are irrelevant. Backslash before percent likely should not be used in Org files. My minimal example

    #+caption: User input "%S" is combined with format string
    #+begin_src emacs-lisp
      t
    #+end_src

P.S. "Not enough arguments for format string" error usually means that a string provided by user is passed as format or incorrect number of arguments is specified for a format-like function. The former case is a quite frequent mistake:
- https://orgmode.org/list/87bl5tzof2.fsf@posteo.net/,
- https://orgmode.org/list/CAJ51ETqZm+8rwcOMYMh2MEXe8Si0Nzn2Wq3K55N041-RAxhSew@mail.gmail.com/ (vs. correct variant https://emacs.stackexchange.com/questions/38276/get-description-of-an-org-mode-link).

Use

(defun my-safe-fun (msg)
 (message "%s" msg))

not just

(defun not-a-fun (msg)
 (message msg))





reply via email to

[Prev in Thread] Current Thread [Next in Thread]