emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
* How to display babel src block language on exported PDF code block?
@ 2018-04-06  2:01 stardiviner
  2018-04-06  3:32 ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: stardiviner @ 2018-04-06  2:01 UTC (permalink / raw)
  To: org-mode

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

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to display babel src block language on exported PDF code block?
  2018-04-06  2:01 How to display babel src block language on exported PDF code block? stardiviner
@ 2018-04-06  3:32 ` John Kitchin
  2018-04-13  0:33   ` stardiviner
  0 siblings, 1 reply; 4+ messages in thread
From: John Kitchin @ 2018-04-06  3:32 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 2169 bytes --]

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

[-- Attachment #2: Type: text/html, Size: 3557 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to display babel src block language on exported PDF code block?
  2018-04-06  3:32 ` John Kitchin
@ 2018-04-13  0:33   ` stardiviner
  2018-04-13 15:20     ` John Kitchin
  0 siblings, 1 reply; 4+ messages in thread
From: stardiviner @ 2018-04-13  0:33 UTC (permalink / raw)
  To: John Kitchin; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 2292 bytes --]

I recently switched email client from Thunderbird to 
mu4e+getmail+procmail. Found missed many my related messages because my 
wrong procmail rules. Missed this too. I found on Thunderbird again.


On 04/06/2018 11:32 AM, John Kitchin wrote:
> I have done soemthing like this before:
>
> ;; 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")

Is it possible to not manually export file, I want it is integrated into 
Org-mode [C-c C-e l] seamlessly. Do I have to inherit `'latex` backend 
and create a new variant `'my-latex' backend? then export manually? 
Maybe use some kind of modification of default list values to replace or 
append?
What do you think?

>
> 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 <numbchild@gmail.com 
> <mailto: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.
>            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-----
>
>


[-- Attachment #2: Type: text/html, Size: 4649 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

* Re: How to display babel src block language on exported PDF code block?
  2018-04-13  0:33   ` stardiviner
@ 2018-04-13 15:20     ` John Kitchin
  0 siblings, 0 replies; 4+ messages in thread
From: John Kitchin @ 2018-04-13 15:20 UTC (permalink / raw)
  To: stardiviner; +Cc: org-mode

[-- Attachment #1: Type: text/plain, Size: 3184 bytes --]

You can add an export menu of your own:

(defun my-src-block (src-block contents info)
  (concat "got you\n" (org-latex-src-block src-block contents info)))

(org-export-define-derived-backend 'my-latex 'latex
  :translate-alist '((src-block . my-src-block))
  :menu-entry
  '(?z "my special exporter"
       ((?o "pdf and open" (lambda (&rest args)
     (let ((texfile (org-export-output-file-name ".tex"))
   (pdffile (org-export-output-file-name ".pdf")))
       (org-export-to-file 'my-latex texfile)
       (ox-manuscript-latex-pdf-process texfile)  ;; scimax function, you
might do something else here.
       (org-open-file pdffile)))))))

Then: C-c C-e z o



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 12, 2018 at 5:33 PM, stardiviner <numbchild@gmail.com> wrote:

> I recently switched email client from Thunderbird to
> mu4e+getmail+procmail. Found missed many my related messages because my
> wrong procmail rules. Missed this too. I found on Thunderbird again.
>
> On 04/06/2018 11:32 AM, John Kitchin wrote:
>
> I have done soemthing like this before:
>
> ;; 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")
>
>
> Is it possible to not manually export file, I want it is integrated into
> Org-mode [C-c C-e l] seamlessly. Do I have to inherit `'latex` backend and
> create a new variant `'my-latex' backend? then export manually? Maybe use
> some kind of modification of default list values to replace or append?
> What do you think?
>
>
>
> 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 <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.
>>        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-----
>>
>>
>
>

[-- Attachment #2: Type: text/html, Size: 6557 bytes --]

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2018-04-13 15:20 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2018-04-06  2:01 How to display babel src block language on exported PDF code block? stardiviner
2018-04-06  3:32 ` John Kitchin
2018-04-13  0:33   ` stardiviner
2018-04-13 15:20     ` John Kitchin

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