From mboxrd@z Thu Jan 1 00:00:00 1970 From: John Kitchin Subject: Re: How to display babel src block language on exported PDF code block? Date: Thu, 5 Apr 2018 20:32:23 -0700 Message-ID: References: <87bmext7n2.fsf@gmail.com> Mime-Version: 1.0 Content-Type: multipart/alternative; boundary="001a113ca36054d1c1056925b467" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:38826) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1f4I70-0002fX-PE for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 23:32:28 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1f4I6z-0006NN-Cg for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 23:32:26 -0400 Received: from mail-wr0-x229.google.com ([2a00:1450:400c:c0c::229]:39130) by eggs.gnu.org with esmtps (TLS1.0:RSA_AES_128_CBC_SHA1:16) (Exim 4.71) (envelope-from ) id 1f4I6z-0006Mf-0Q for emacs-orgmode@gnu.org; Thu, 05 Apr 2018 23:32:25 -0400 Received: by mail-wr0-x229.google.com with SMTP id c24so31586541wrc.6 for ; Thu, 05 Apr 2018 20:32:24 -0700 (PDT) In-Reply-To: <87bmext7n2.fsf@gmail.com> List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: stardiviner Cc: org-mode --001a113ca36054d1c1056925b467 Content-Type: text/plain; charset="UTF-8" I have done soemthing like this before: (setq org-latex-minted-options '(("frame" "lines") ("fontsize" "\\scriptsize"))) ;; custom code block format to indicate input variables (defun my-src-block (src-block contents info) (cond ((eq (elt (plist-get info :back-end) 2) 'latex) (concat "\\begin{tcolorbox} " (format (concat (when (org-element-property :name src-block) (format "src block name: %s\\\\" (org-element-property :name src-block))) "language: %s") (org-element-property :language src-block)) (org-latex-src-block src-block contents info) " \\end{tcolorbox}")))) ;; custom exporter (org-export-define-derived-backend 'my-latex 'latex :translate-alist '((src-block . my-src-block))) (org-export-to-file 'my-latex "manuscript.tex" nil nil nil nil nil) (ox-manuscript-latex-pdf-process "manuscript.tex") John ----------------------------------- Professor John Kitchin Doherty Hall A207F Department of Chemical Engineering Carnegie Mellon University Pittsburgh, PA 15213 412-268-7803 @johnkitchin http://kitchingroup.cheme.cmu.edu On Thu, Apr 5, 2018 at 7:01 PM, stardiviner wrote: > -----BEGIN PGP SIGNED MESSAGE----- > Hash: SHA256 > > By default org-mode export to PDF file does not have language indicator on > code block. > How to setup to add a language string on exported PDF code block like this > HTML https://stardiviner.github.io/ ? > - -- > [ stardiviner ] don't need to convince with trends. > Blog: https://stardiviner.github.io/ > IRC(freenode): stardiviner > GPG: F09F650D7D674819892591401B5DF1C95AE89AC3 > > -----BEGIN PGP SIGNATURE----- > > iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrG1RIACgkQG13xyVro > msP0UQf/aPrlTV1ZreOrTmKuqo9rA28u/vtX266EtmOFOwB/y50pazkT5YdFLHKW > HUGyFFrWxBtTTCA9KW6/OJ49AB6kXoHSdj98jyCkRroroaT9mqtWdY9Xi8DRogqA > SCWOjjybOSEGlWsmu1gwXs0yNgqQijJR03JbMZoTcuDFctdFSk4XnnebfLiN20Ix > 56fdVBMRotTFv6CCcvYZncyCp1POJQ6JtlwP3GDQufrgPy2uxZJGHUzPx9BUj4Bg > TDERPlDVjSZckc6uP6tIhzGm1PqklG34E770r3By66yeLEMaW1B6QX3IPrJ4oh7w > yhfty2UfsLQfiKyykqnt6+0SHM9IHg== > =cLnk > -----END PGP SIGNATURE----- > > --001a113ca36054d1c1056925b467 Content-Type: text/html; charset="UTF-8" Content-Transfer-Encoding: quoted-printable
I have done soemthing like this before:

(setq org-latex-minted-options
=C2=A0 =C2=A0 =C2=A0 =C2=A0 = =C2=A0 =C2=A0'(("frame" "lines")
=C2=A0 = =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0 =C2=A0("fontsize" "\\scri= ptsize")))

;; custom code block format to ind= icate input variables
(defun my-src-block (src-block contents inf= o)
=C2=A0 (cond
=C2=A0 =C2=A0((eq (elt (plist-get info = :back-end) 2) 'latex)
=C2=A0 =C2=A0 (concat
=C2=A0 = =C2=A0 =C2=A0"\\begin{tcolorbox}
"
=C2=A0 =C2= =A0 =C2=A0(format
=C2=A0 =C2=A0 =C2=A0 (concat
=C2=A0 = =C2=A0 =C2=A0 =C2=A0(when (org-element-property :name src-block)
= (format "src block name: %s\\= \\" (org-element-property :name src-block)))
=C2=A0 =C2=A0 = =C2=A0 =C2=A0"language: %s")
=C2=A0 =C2=A0 =C2=A0 (org-= element-property :language src-block))
=C2=A0 =C2=A0 =C2=A0(org-l= atex-src-block src-block contents info)
"
\\end{tc= olorbox}"))))

;; custom exporter
(o= rg-export-define-derived-backend 'my-latex 'latex
=C2=A0 = :translate-alist '((src-block . my-src-block)))

(org-export-to-file 'my-latex "manuscript.tex" nil nil nil = nil nil)
(ox-manuscript-latex-pdf-process "manuscript.tex&qu= ot;)

John

-----------------------------------<= br>Professor John Kitchin=C2=A0
Doherty Hall A207F
Department of Chem= ical Engineering
Carnegie Mellon University
Pittsburgh, PA 15213
4= 12-268-7803

On Thu, Apr 5, 2018 at 7:01 PM, stardiviner = <numbchild@gmail.com> wrote:
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA256

By default org-mode export to PDF file does not have language indicator on = code block.
How to setup to add a language string on exported PDF code block like this = HTML https://stardiviner.github.io/ ?
- --
[ stardiviner ] don't need to convince with trends.
=C2=A0 =C2=A0 =C2=A0 =C2=A0Blog: https://stardiviner.github.io/ =C2=A0 =C2=A0 =C2=A0 =C2=A0IRC(freenode): stardiviner
=C2=A0 =C2=A0 =C2=A0 =C2=A0GPG: F09F650D7D674819892591401B5DF1C95AE89A= C3

-----BEGIN PGP SIGNATURE-----

iQEzBAEBCAAdFiEE8J9lDX1nSBmJJZFAG13xyVromsMFAlrG1RIACgkQG13xyVro<= br> msP0UQf/aPrlTV1ZreOrTmKuqo9rA28u/vtX266EtmOFOwB/y50pazkT5YdF= LHKW
HUGyFFrWxBtTTCA9KW6/OJ49AB6kXoHSdj98jyCkRroroaT9mqtWdY9Xi8DRogqA<= br> SCWOjjybOSEGlWsmu1gwXs0yNgqQijJR03JbMZoTcuDFctdFSk4XnnebfLiN20Ix<= br> 56fdVBMRotTFv6CCcvYZncyCp1POJQ6JtlwP3GDQufrgPy2uxZJGHUzPx9BUj4Bg<= br> TDERPlDVjSZckc6uP6tIhzGm1PqklG34E770r3By66yeLEMaW1B6QX3IPrJ4oh7w<= br> yhfty2UfsLQfiKyykqnt6+0SHM9IHg=3D=3D
=3DcLnk
-----END PGP SIGNATURE-----


--001a113ca36054d1c1056925b467--