Org-mode mailing list
 help / color / mirror / Atom feed
From: Maxim Nikulin <manikulin@gmail.com>
To: emacs-orgmode@gnu.org
Subject: Re: Bug: Percentage in caption (even escaped) does not work in LaTeX export
Date: Fri, 3 Sep 2021 19:17:25 +0700
Message-ID: <sgt3om$mae$1@ciao.gmane.io> (raw)
In-Reply-To: <YT2PR01MB45101E27DC6251D8F8B7B366F6EC9@YT2PR01MB4510.CANPRD01.PROD.OUTLOOK.COM>

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))




  parent reply	other threads:[~2021-09-03 12:26 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-07-30 15:00 Charest, Luc
2021-08-03 13:51 ` Eric S Fraga
2021-08-31 15:38   ` Timothy
2021-08-31 16:43     ` Charest, Luc
2021-09-03 12:17 ` Maxim Nikulin [this message]
2021-09-07 12:21   ` [PATCH] ox-latex: Allow percent sign in 'src-block' caption Maxim Nikulin
2021-09-07 13:17     ` Timothy

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://orgmode.org

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

  git send-email \
    --in-reply-to='sgt3om$mae$1@ciao.gmane.io' \
    --to=manikulin@gmail.com \
    --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

Org-mode mailing list

This inbox may be cloned and mirrored by anyone:

	git clone --mirror https://orgmode.org/list/0 list/git/0.git

	# If you have public-inbox 1.1+ installed, you may
	# initialize and index your mirror using the following commands:
	public-inbox-init -V2 list list/ https://orgmode.org/list \
		emacs-orgmode@gnu.org
	public-inbox-index list

Example config snippet for mirrors.
Newsgroups are available over NNTP:
	nntp://news.yhetil.org/yhetil.emacs.orgmode
	nntp://news.gmane.io/gmane.emacs.orgmode


AGPL code for this site: git clone https://public-inbox.org/public-inbox.git