Hi,

attached is the second iteration...
@Ihor Please let me know what you think.

Best, /PA

On Mon, 22 Jun 2026 at 07:31, Pedro Andres Aranda Gutierrez <
[email protected]> wrote:

> Hi
>
> On Sun, 21 Jun 2026 at 12:50, Ihor Radchenko <[email protected]> wrote:
>
>> "Pedro A. Aranda" <[email protected]> writes:
>>
>> > attached is a patch to enhance Org markup support in the LaTeX exporter.
>> > I needed it for a publication.
>>
>> I finally got to a proper review of this.
>>
>> > +*** LaTeX markup conventions
>> > +
>> > +#+cindex: @samp{Markup conventions, LaTeX}
>> > +#+vindex: org-latex-verb-is-verb
>> > +#+vindex: org-latex-quoted-verb
>> > ...
>>
>> I think that adding this kind of section is useful on its own,
>> regardless of the rest of the patch.
>>
>
> OK, let's progress with this...
>
>
>> > +*** ox-latex: Control whether =xxx= uses ~verb~ or ~texttt~
>> > +
>> > +Two new custom variables have been introduced:
>> > +org-latex-verb-is-verb: Setting this to t will make =xx= result in
>> > +~\verb~ instead of ~\texttt~
>> > +org-latex-quoted-verb: Surround ~\verb~ with double quotes (emualting
>> > +the texinfo exporter).
>>
>> As I mentioned in another email, I do not like the idea of layering
>> multiple defcustoms on top of `org-latex-text-markup-alist'.
>> Rather than creating new defcustoms I suggest expanding "special values"
>> in `org-latex-text-markup-alist' from `verb' and `protectedtexttt' to
>> `verb', `single-quoted-verb`, and `double-quoted-verb'.
>>
>
> So we would end up with verbatim being one of these three values only and
> drop protectedtexttt.
> Would make sense... Of course, with the ugliness of needing something like
>
> #+BEGIN_SRC emacs-lisp
> (setcdr (assoc 'verbatim org-latex-text-markup) <new_value>)
> #+END_SRC
>
> to change that...
> unless you don't object to a new custom with a getter function returning
> (cdr (assoc...)) and the setter function above.
>
>>
>> As for the complexity of setting `org-latex-text-markup-alist', I'd
>> rather split it into individual variables (possibly even adding
>> #+options: ... support for each markup element). That will make
>> customization easier for people who do not want to deal with the alist.
>>
>> WDYT?
>>
>> --
>> Ihor Radchenko // yantar92,
>> Org mode maintainer,
>> Learn more about Org mode at <https://orgmode.org/>.
>> Support Org development at <https://liberapay.com/org-mode>,
>> or support my work at <https://liberapay.com/yantar92>
>>
> Best, /PA
>
>
> --
> Fragen sind nicht da, um beantwortet zu werden,
> Fragen sind da um gestellt zu werden
> Georg Kreisler
>
> "Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
> Year 2 of the New Koprocracy
>
>

-- 
Fragen sind nicht da, um beantwortet zu werden,
Fragen sind da um gestellt zu werden
Georg Kreisler

"Sagen's Paradeiser" (ORF: Als Radiohören gefährlich war) => write BE!
Year 2 of the New Koprocracy
From ecc3ad39d501da0e988312fe949e158970c83878 Mon Sep 17 00:00:00 2001
From: "Pedro A. Aranda" <[email protected]>
Date: Mon, 22 Jun 2026 10:31:53 +0200
Subject: [PATCH] ox-latex: Add quoted verbatim

* doc/org-manual.org: Add LaTeX markup convetions section.
* etc/ORG-NEWS: Announce org-latex-verbatim-style.
* lisp/ox-latex.el (org-latex-verbatim-style):  New custom variable to
control quoting around verbatim output.
(org-latex-text-markup-alist):  Change association for verbatim markup.
(org-latex--text-markup): Add quotes to verbatim depending on
org-latex-verbatim-style.
Info channel: add org-latex-verbatim-style to the info channel.
* testing/lisp/test-ox-latex.el (test-ox-latex/quoted-single-verbatim):
New test to check single quotes around verbatim.
(test-ox-latex/quoted-double-verbatim): New test to check double quotes
around verbatim.
---
 doc/org-manual.org            | 38 +++++++++++++++++++++++++++++++++
 etc/ORG-NEWS                  |  7 ++++++
 lisp/ox-latex.el              | 40 +++++++++++++++++++++++------------
 testing/lisp/test-ox-latex.el | 27 +++++++++++++++++++++++
 4 files changed, 99 insertions(+), 13 deletions(-)

diff --git a/doc/org-manual.org b/doc/org-manual.org
index f47763746..0032f0d52 100644
--- a/doc/org-manual.org
+++ b/doc/org-manual.org
@@ -14452,6 +14452,44 @@ include it in the document options with:
 #+OPTIONS: latex-use-sans:t
 #+end_example
 
+*** LaTeX markup conventions
+
+#+cindex: @samp{Markup conventions, LaTeX}
+#+vindex: org-latex-text-markup-alist
+#+vindex: org-latex-verbatim-style
+
+By default, LaTeX translates the text markup for code and text
+copied verbatim using the LaTeX ~\texttt~ and ~\verb~ commands:
+
+#+begin_src org
+This is an example of a ~code keyword~.
+This is an example of a =couple of words= copied verbatim.
+#+end_src
+
+will be exported as:
+
+#+begin_src latex
+This is an example of a \texttt{code keyword}.
+This is an example of a \verb~couple of words~ copied verbatim.
+#+end_src
+
+Use custom variable ~org-latex-verbatim-style~ to control the aspect
+of the ~verb~ passages. By default, its value is ~verb~. Set it to
+~singlequoteverb~ or ~doublequoteverb~ in order to surround verbatim
+text with single or double quotes.
+
+~singlequoteverb~ mimics the =texinfo= conventions used in
+this manual. The resulting LaTeX code would be:
+
+#+begin_src latex
+This is an example of a \texttt{code keyword}.
+This is an example of a `\verb~couple of words~' copied verbatim.
+#+end_src
+
+*Note* that you can alternatively set custom variable
+~org-latex-text-markup-alist~, modifying the =verbatim= association.
+However, it is recommended to use ~org-latex-verbatim-style~, unless
+you need a more elaborate transformation.
 
 *** Quoting LaTeX code
 :PROPERTIES:
diff --git a/etc/ORG-NEWS b/etc/ORG-NEWS
index 03057cbd0..5055f8381 100644
--- a/etc/ORG-NEWS
+++ b/etc/ORG-NEWS
@@ -219,6 +219,13 @@ environment for descriptive lists when exporting to LaTeX.
 Use it when the default ~description~ environment does not fit your
 needs. The recommended alternative value is ~itemize~.
 
+*** New custom variable ~org-latex-verbatim-style~
+
+~org-latex-verbatim-style~ controls the style for verbatim markup. By
+default it is plain verbatim. Additionally, it accepts
+~singlequoteverb~ and ~doublequoteverb~ to add typographical quotes
+around the verbatim text.
+
 ** New functions and changes in function arguments
 
 # This also includes changes in function behavior from Elisp perspective.
diff --git a/lisp/ox-latex.el b/lisp/ox-latex.el
index 8e2f72209..1fa577f3d 100644
--- a/lisp/ox-latex.el
+++ b/lisp/ox-latex.el
@@ -168,6 +168,7 @@ (org-export-define-backend 'latex
     (:latex-tables-booktabs nil nil org-latex-tables-booktabs)
     (:latex-tables-centered nil nil org-latex-tables-centered)
     (:latex-text-markup-alist nil nil org-latex-text-markup-alist)
+    (:latex-verbatim-style nil nil org-latex-verbatim-style)
     (:latex-title-command nil nil org-latex-title-command)
     (:latex-toc-command nil nil org-latex-toc-command)
     (:latex-compiler "LATEX_COMPILER" nil org-latex-compiler)
@@ -910,18 +911,15 @@ (defcustom org-latex-text-markup-alist '((bold . "\\textbf{%s}")
 					 (italic . "\\emph{%s}")
 					 (strike-through . "\\sout{%s}")
 					 (underline . "\\uline{%s}")
-					 (verbatim . protectedtexttt))
+					 (verbatim . verb))
   "Alist of LaTeX expressions to convert text markup.
 
 The key must be a symbol among `bold', `code', `italic',
 `strike-through', `underline' and `verbatim'.  The value is
 a formatting string to wrap fontified text with.
 
-Value can also be set to the following symbols: `verb' and
-`protectedtexttt'.  For the former, Org will use \"\\verb\" to
-create a format string and select a delimiter character that
-isn't in the string.  For the latter, Org will use \"\\texttt\"
-to typeset and try to protect special characters.
+The value is a format string, `protectedtexttt' or the values that can
+be assigned to `org-latex-verbatim-style'.
 
 If no association can be found for a given markup, text will be
 returned as-is."
@@ -931,6 +929,12 @@ (defcustom org-latex-text-markup-alist '((bold . "\\textbf{%s}")
   :type 'alist
   :options '(bold code italic strike-through underline verbatim))
 
+(defcustom org-latex-verbatim-style 'verb
+  "The style for text. It can be any of: `verb',
+`singlequoteverb', or `doublequoteverb'. "
+  :group 'org-export-latex
+  :type 'symbol
+  :safe #'(lambda (s) (memq s '(verb singlequoteverb doublequoteverb))))
 
 ;;;; Drawers
 
@@ -1895,18 +1899,28 @@ (defun org-latex--text-markup (text markup info)
   "Format TEXT depending on MARKUP text markup.
 INFO is a plist used as a communication channel.  See
 `org-latex-text-markup-alist' for details."
-  (let ((fmt (cdr (assq markup (plist-get info :latex-text-markup-alist)))))
+  (let ((fmt (cdr (assq markup (plist-get info :latex-text-markup-alist))))
+        (verb-style (plist-get info :latex-verbatim-style)))
     (cl-case fmt
       ;; No format string: Return raw text.
       ((nil) text)
-      ;; Handle the `verb' special case: Find an appropriate separator
-      ;; and use "\\verb" command.
+      ;; Handle the `verb', `singlequoteverb' and `singlequoteverb'
+      ;; special cases: Find an appropriate separator
+      ;; and use "\\verb" command w/ the adequate quotes if requested.
       (verb
        (let ((separator (org-latex--find-verb-separator text)))
-	 (concat "\\verb"
+	 (concat (cl-case verb-style
+                   (singlequoteverb "`")
+                   (doublequoteverb "``")
+                   (t ""))
+                 "\\verb"
+		 separator
+		 (string-replace "\n" " " text)
 		 separator
-		 (replace-regexp-in-string "\n" " " text)
-		 separator)))
+                 (cl-case verb-style
+                   (singlequoteverb "'")
+                   (doublequoteverb "''")
+                   (t "")))))
       (protectedtexttt (org-latex--protect-texttt text))
       ;; Else use format string.
       (t (format fmt text)))))
@@ -4362,7 +4376,7 @@ (defun org-latex-verbatim (verbatim _contents info)
   "Transcode a VERBATIM object from Org to LaTeX.
 CONTENTS is nil.  INFO is a plist used as a communication
 channel."
-  (org-latex--text-markup
+  (org-latex--text-markup ;; (text markup info)
    (org-element-property :value verbatim) 'verbatim info))
 
 
diff --git a/testing/lisp/test-ox-latex.el b/testing/lisp/test-ox-latex.el
index a804e281b..f619697d2 100644
--- a/testing/lisp/test-ox-latex.el
+++ b/testing/lisp/test-ox-latex.el
@@ -522,5 +522,32 @@ (ert-deftest test-ox-latex/subtree-export-with-language ()
        (should (search-forward "\\usepackage[utf8]{inputenc} \\usepackage[french, english]{babel}")))
      (kill-buffer export-buffer))))
 
+(ert-deftest test-ox-latex/quoted-single-verbatim ()
+  "Test singlequoteverb"
+  (let ((org-latex-verbatim-style 'singlequoteverb))
+    (org-test-with-exported-text
+     'latex
+     "#+TITLE: quoted verbatim
+* A dummy title
+
+This text should be single-quoted =verbatim=."
+     ;; (message "-> verbatim-stype => %s"(buffer-string))
+     (goto-char (point-min))
+     (should (search-forward "single-quoted `\\verb~verbatim~'")))))
+
+(ert-deftest test-ox-latex/quoted-double-verbatim ()
+  "Test doublequoteverb"
+  (let ((org-latex-verbatim-style 'doublequoteverb))
+    (org-test-with-exported-text
+     'latex
+     "#+TITLE: quoted verbatim
+* A dummy title
+
+This text should be double-quoted =verbatim=."
+     ;; (message "-> verbatim-stype => %s"(buffer-string))
+     (goto-char (point-min))
+     (should (search-forward "double-quoted ``\\verb~verbatim~''")))))
+
+
 (provide 'test-ox-latex)
 ;;; test-ox-latex.el ends here
-- 
2.43.0

Reply via email to