emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Myles English <mylesenglish@gmail.com>
To: Robert Love <rblove@airmail.net>
Cc: emacs-orgmode list <emacs-orgmode@gnu.org>
Subject: Re: Example of Make file for Org Mode LaTeX to pdf
Date: Sun, 06 Mar 2016 13:26:50 +0000	[thread overview]
Message-ID: <877fhf20v9.fsf@gmail.com> (raw)
In-Reply-To: <4A383BD1-2B7C-4AF3-909E-5D1561B1F933@airmail.net>


Hello Bob,

Robert Love writes:

> Does anyone have a make file example that has emacs load an .org file,
> process it into LaTeX and export as PDF, all from the command line
> without the user doing anything more than type ‘make’?   All examples
> appreciated.

Fraid I don't have a makefile but I do have a CMakeLists.txt that CMake
uses to generate a makefile.  This method uses a CMake module called
UseLATEX.cmake to generate the PDF.  I haven't used it for a couple of
years so it might be a bit outdated.

The CMakeLists.txt also contains an example of how to generate all the R
graphics for the document.

If it looks a bit over complicated for your requirements perhaps just
looking at the line that contains "COMMAND emacs" would be useful for
you.

Hopefully someone else will show a nice, simple, self-contained example.

Myles


#+BEGIN_SRC sh :tangle CMakeLists.txt
      cmake_minimum_required(VERSION 2.8)
      
      project(thesis NONE)
            
      include(/usr/share/cmake-2.8/Modules/UseLATEX.cmake)
      
      # Set R executable
      set(R_COMPILE "/usr/bin/Rscript")
            # Set the location of data files
            ##set(DATA_DIR data)
            # Set the location of the directory for image files
      set(IMAGE_DIR graphicsauto)
      
            # Get a list of R files
      file(GLOB_RECURSE R_FILES "R/*.R")
      
      file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/R DESTINATION ${CMAKE_CURRENT_BINARY_DIR})
      file(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR})
      
      foreach(file ${R_FILES})
      message("processing ${file}")
      get_filename_component(basename "${file}" NAME_WE)
      
                # Command to run R
      if(R_COMPILE)
          message("Adding ........... ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R")
  
          add_custom_command(
              OUTPUT
              ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
              DEPENDS
              ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
                      #      ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${DATA_DIR}
              COMMAND
              ${R_COMPILE}
              ARGS
              ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R
              ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
          )
          message("Running ${R_COMPILE} ${CMAKE_CURRENT_BINARY_DIR}/R/${basename}.R ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps")
            
          endif(R_COMPILE)
            
                # Make a list of all R files (for ADD_LATEX_DOCUMENT depend)
          set(ALL_R_FILES ${ALL_R_FILES}
              ${CMAKE_CURRENT_BINARY_DIR}/${IMAGE_DIR}/${basename}.eps
          )
          endforeach(file)
            
            # ------- export mainThesis.org -----------------------
          latex_get_output_path(OUTPUT_DIR)  
          file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/mainThesis.org DESTINATION ${OUTPUT_DIR}/ )
          file(COPY ${CMAKE_CURRENT_SOURCE_DIR}/thesis.el DESTINATION ${OUTPUT_DIR}/ )
      
          add_custom_target( orgfile ALL
              DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.org )
      
          add_custom_target( elfile ALL
              DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/thesis.el )
          
          add_custom_command(
              OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.tex
              COMMAND emacs -Q --batch --eval \"(progn
                  (add-to-list 'load-path
                         (expand-file-name \\"~/.emacs.d/plugins/org-mode/lisp/\\"))
                       (add-to-list 'load-path
                      (expand-file-name \\"~/.emacs.d/plugins/org-mode/contrib/lisp/\\" t))
                  (require 'org)
                       (require 'ox)
                  (require 'org-exp)
                       (require 'org-inlinetask)
                  (require 'ob-plantuml)
                       (setq org-plantuml-jar-path \\"/home/myles/Downloads/plantuml.jar\\")
                       (org-babel-do-load-languages
                        'org-babel-load-languages
                      '((emacs-lisp . t)
                          (sh . t)
                          (plantuml . t)))
                       (setq org-confirm-babel-evaluate nil)
                       (setq org-latex-listings 'minted)
                  (setq org-latex-with-hyperref nil)
                     (add-to-list 'org-latex-packages-alist '(\\"\\" \\"minted\\"))
  
  (add-to-list 'org-latex-classes 
    '(\\"mynewthesis\\" \\"\\\\\\documentclass[11pt]{mythesis}\\"
     (\\"\\\\\\chapter{%s}\\" . \\"\\\\\\chapter*{%s}\\")
     (\\"\\\\\\section{%s}\\" . \\"\\\\\\section*{%s}\\")
     (\\"\\\\\\subsection{%s}\\" . \\"\\\\\\subsection*{%s}\\")
     (\\"\\\\\\subsubsection{%s}\\" . \\"\\\\\\subsubsection*{%s}\\")
     (\\"\\\\\\paragraph{%s}\\" . \\"\\\\\\paragraph*{%s}\\")))
                     (setq org-export-with-todo-keywords nil)
                 (load-library \\"/home/myles/lib/lisp/my-export.el\\")
                 (add-to-list 'org-export-before-parsing-hook 'my-export-delete-headlines-tagged-noheading)
                 (add-to-list 'org-export-filter-link-functions 'my-autoref-filter-link-func)
              (load-file \\"thesis.el\\")
                  (find-file \\"${CMAKE_CURRENT_BINARY_DIR}/mainThesis.org\\")
                  (org-latex-export-to-latex))\"
              DEPENDS orgfile elfile
              COMMENT "Exporting orgmode file to LaTeX using emacs")
          
          add_custom_target( mainfile ALL
              DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/mainThesis.tex )
            # ------ end mainThesis.org ---------------------------
          
            # add_custom_command(
            #         OUTPUT ${CMAKE_CURRENT_BINARY_DIR}/master.tex
            #         COMMAND echo "\\\\input{mainThesis.tex}" > ${CMAKE_CURRENT_BINARY_DIR}/master.tex
            #         DEPENDS orgfile
            #         COMMENT "Writing file master.tex")
          
            # add_custom_target( masterfile ALL
            #         DEPENDS ${CMAKE_CURRENT_BINARY_DIR}/master.tex )
          
          add_latex_document(master.tex
              BIBFILES texlib/mybiblatex.bib
              INPUTS biber.conf
              phd_papers.bib
              tex/title.tex
              tex/titleBasic.tex
              tex/abstract.tex
              tex/sharedMemory_sec.tex
                     texlib/mystyle.sty
                     tex/linked_nodes_test.tex
                     IMAGE_DIRS ${IMAGE_DIR} ../graphics/thirdParty ../graphics/VE
                     DEPENDS ${ALL_R_FILES}
                     DEFAULT_PDF
                     USE_NOMENCL)
#+END_SRC

  reply	other threads:[~2016-03-06 13:26 UTC|newest]

Thread overview: 9+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-03-05  5:43 Example of Make file for Org Mode LaTeX to pdf Robert Love
2016-03-06 13:26 ` Myles English [this message]
2016-03-06 13:40 ` John Kitchin
2016-03-06 18:34 ` Eric S Fraga
2016-03-07  8:55   ` Loris Bennett
2016-03-07 14:20     ` Nick Dokos
2016-03-07 15:26     ` Eric S Fraga
2016-03-07 16:10       ` Loris Bennett
2016-03-09  3:38         ` Robert Love

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=877fhf20v9.fsf@gmail.com \
    --to=mylesenglish@gmail.com \
    --cc=emacs-orgmode@gnu.org \
    --cc=rblove@airmail.net \
    /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).