From: "Denis Bitouzé" <denis.bitouze@univ-littoral.fr>
To: emacs-orgmode@gnu.org
Subject: Export (to `LaTeX`) `~⟨code snippet⟩~` into `\lstinline+⟨code snippet⟩+` (just as does `src_⟨language⟩{⟨code snippet⟩}`)
Date: Fri, 11 Mar 2022 15:45:56 +0100 [thread overview]
Message-ID: <87zglwbl97.fsf@example.com> (raw)
Hi,
here is a feature request about the LaTeX export (another one: the
previous mine, https://list.orgmode.org/87zgmda67z.fsf@example.com/,
sadly didn't get any answer).
With `(setq org-latex-listings t)`, `src_⟨language⟩{⟨code snippet⟩}` is
exported from `org-mode` to `LaTeX` into
`\lstinline[language=⟨language⟩]~⟨code snippet⟩~` (here, `~` could be
almost any token): so far, so good.
But one could expect to get the same export with the usual `org-mode`
syntax for code snippets: `~⟨code snippet⟩~` (this supposes the ⟨language⟩
to be declared globally), as in the following example:
--8<---------------cut here---------------start------------->8---
#+OPTIONS: toc:nil title:nil
#+LaTeX_HEADER: \usepackage{xcolor}
#+LaTeX_HEADER: \usepackage{listings}
#+LaTeX_HEADER: \lstset{language=[auto]lisp,basicstyle=\ttfamily,keywordstyle=\color{red}}
#+PROPERTY: header-args :padline no :exports both :noweb yes :eval always
src_lisp{defun} is fun!
~defun~ is fun!
--8<---------------cut here---------------end--------------->8---
For this, it is possible to redefine the `org-latex-code` function:
--8<---------------cut here---------------start------------->8---
;; Inspired by https://emacs.stackexchange.com/q/70720/5267
(defun org-latex-code (code _contents info)
"Transcode a CODE object from Org to LaTeX.
CONTENTS is nil. INFO is a plist used as a communication
channel."
(format "\\lstinline+%s+"
(org-element-property :value code)))
--8<---------------cut here---------------end--------------->8---
but, IMHO, this should be the default.
WDYT?
--
Denis
next reply other threads:[~2022-03-11 14:48 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-03-11 14:45 Denis Bitouzé [this message]
2022-03-11 19:38 ` Export (to `LaTeX`) `~⟨code snippet⟩~` into `\lstinline+⟨code snippet⟩+` (just as does `src_⟨language⟩{⟨code snippet⟩}`) Nick Dokos
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=87zglwbl97.fsf@example.com \
--to=denis.bitouze@univ-littoral.fr \
--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).