kaobook icon indicating copy to clipboard operation
kaobook copied to clipboard

[Feature Request] : kaobook template to use with emacs orgmode docs

Open zenny opened this issue 11 months ago • 2 comments

Summary

@fmarotta Kudos to you for creating such a nice text template which is better than tufte-book, imo.

Meanwhile it would be more convenient if this tex template could be integrated to the emacs orgmode so that as self-contained portable kaobook org file can be generated. If someone has done so let me know with the link, and ignore this feature request.

Details

It would be better to create an emacs org-mode template to kaobook so that one can create a portable orgmode file with all kaobook files. There is a a very nice orgmode template for tufte-book in https://github.com/asilata/emacsconf2021.

She has just appended the following under setup in the orgmode file as follows:

* Setup                                                            :noexport:
** Startup
#+startup: noptag overview hideblocks
** Org LaTeX setup
#+latex_class: tufte-book
#+latex_class_options: [openany, a4paper]
#+latex_header: \usepackage{amsmath,amssymb,amsthm,geometry,hyperref,paralist,svg,thmtools,tikz,tikz-cd}
#+latex_header: \usepackage{mathtools}
#+latex_header: \usepackage[capitalise,noabbrev]{cleveref}
#+latex_header: \usepackage{environ} \NewEnviron{abmn}{\marginnote{\BODY}}
#+latex_header: \setcounter{tocdepth}{1} 
#+latex_header: \newtheorem{theorem}{Theorem}
#+latex_header: \newtheorem{example}[theorem]{Example}
#+latex_header: \newtheorem{exmpl}[theorem]{Example}
#+latex_header: \newtheorem{definition}[theorem]{Definition}
#+latex_header: \newtheorem{proposition}[theorem]{Proposition}
#+latex_header: \newtheorem{lemma}[theorem]{Lemma}
#+latex_header: \newtheorem{exercise}[theorem]{Exercise}
#+latex_header: \usetikzlibrary{arrows,automata,positioning}
** Export settings
Export into the artifacts directory
#+export_file_name: artifacts/ggm

Add ~tufte-book~ to ~org-latex-classes~ and update ~org-latex-pdf-process~.
#+name: export-setup
#+begin_src emacs-lisp :results silent :var this-year="2021"
  (add-to-list 'org-latex-classes
               `("tufte-book"
                 ,(string-join
                   '("\\documentclass{tufte-book}"
                     "\\usepackage{color}"
                     "\\usepackage{amsmath,amssymb}")
                   "\n")
                 ("\\chapter{%s}" . "\\chapter*{%s}")
                 ("\\section{%s}" . "\\section*{%s}")
                 ("\\subsection{%s}" . "\\subsection*{%s}")
                 ("\\paragraph{%s}" . "\\paragraph*{%s}")
                 ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

  (setq-local org-latex-pdf-process
        (let
            ((cmd (concat "pdflatex -shell-escape -interaction nonstopmode"
                          " --synctex=1"
                          " -output-directory %o %f")))
          (list cmd
                "cd %o; if test -r %b.idx; then makeindex %b.idx; fi"
                "cd %o; bibtex %b"
                cmd
                cmd
                "mv *.svg %o/"
                "rm -rf %o/svg-inkscape"
                "mv svg-inkscape %o/"
                (concat "cp %o/%b.pdf ../docs/" this-year "/ggm.pdf"))))

  (setq-local org-latex-subtitle-format "\\\\\\medskip
          \\noindent\\Huge %s")
  (setq-local org-confirm-babel-evaluate nil)
#+end_src

and the following under local variables as follows:

* Local variables                                                  :noexport:
# Local variables:
# eval: (add-hook 'org-export-before-processing-hook (lambda (be) (org-babel-ref-resolve "export-setup")) nil t)
# End:

Quite nifty! So I am seeking inputs from a master of emacs orgmode and LaTeX so that such a beautiful kaobook template can be made self-contained and portable orgmode file.

Additional context

The amount of convenience my feature may bring with such an self-contained portable org file has been presented by @asilata in https://emacsconf.org/2021/talks/babel/ or can be watched in https://www.youtube.com/watch?v=1Ooi4KAd2FM.

Cheers, /z

zenny avatar Aug 06 '23 07:08 zenny