2

Scimax has already some templates for various journals. However, is there a way to convert latex templates of some specific journals (like nuclear physics A, European physical journal etc.) to org-mode template? Maybe a script that does it automatically?

Those journals already have their example manuscripts. For new learners of scimax, it is difficult to create a template. Or is there a step by step guy to create org-template from the latex-template?

For instance for the journal: EPJA: https://mc.manuscriptcentral.com/societyimages/epja/EPJA_templ.zip

Elsevier (Nuclear Physics A: https://www.elsevier.com/__data/assets/file/0007/56842/elsarticle-template.zip)

Thanks

  • I'm happy to help do this. Please update your question with link(s) to any specific latex templates you would like to convert to org-mode. If the answer(s) are too detailed for this forum, I'll do my best to provide an overview which links to a public git for detailed steps. – Melioratus Nov 15 '18 at 15:53
  • Looks like @jkitchin provides for ox-manuscript-templates. Does that help? – Melioratus Nov 15 '18 at 16:00
  • There is no automated way. Even I just look in the ox-manuscripts-template folder and adapt one of them to create a new one. Sometimes it is simple, and sometimes it is not. – John Kitchin Nov 15 '18 at 16:35
  • I edited the questions with the links for the latex templates of the specific journals. It will be a great help if the template is formed so that I can write the first paper in org mode @Melioratus. – sbilmis Nov 16 '18 at 3:41
  • 2
    You can find some new templates at github.com/jkitchin/scimax/blob/master/ox-manuscript/… and github.com/jkitchin/scimax/blob/master/ox-manuscript/…. They might need some fine tuning still, but they mostly build to pdfs that look like the examples in those links. – John Kitchin Nov 17 '18 at 0:35
1

Summary

This How-To tutorial provides a step by step guide on how to migrate the LaTeX template provided by an academic journal into org-mode syntax.

Instructions

To complete this tutorial successfully, please follow all steps in the order presented of each section listed below:

  • Requirements
  • Create New org-mode File
  • Download LaTeX Template
  • Migrate LaTeX Template Code into file variables
  • Migrate LaTeX Template Code into SRC blocks
  • Customize a SRC block using Literate Programming
  • Add Content to org-mode File
  • Export completed org-mode file as PDF

Requirements

Note: All the requirements must be completed successfully before continuing with the steps in this How-To tutorial.

Instructions

  1. Download, Install, and Configure LaTeX Software

    Unfortunately, this requirement is beyond the scope of this How-To tutorial.

  2. Download, Install, and Configure emacs Software

    Unfortunately, this requirement is beyond the scope of this How-To tutorial.

  3. Download, Install, and Configure org-mode Software

    Note: The org-mode application is already installed if you are using a recent version of emacs, i.e. versions 25 or greater.

    Unfortunately, this requirement is beyond the scope of this How-To tutorial.

  4. Export an org-mode file as PDF via built-in LaTeX exporter.

    TIP: To export an org-mode document to PDF:

    1. Open the org-mode file in emacs.
    2. Position the cursor in the buffer of the org-mode document in emacs.
    3. Press the following key chords and keys, C-c C-e l p to initiate the export process.
    4. Open the exported PDF file to validate the export process succeeded.

    If exporting an org-mode file to PDF succeeded then continue following the steps in this How-To tutorial. Otherwise troubleshoot each step in the requirements section and repeat until exporting an org-mode document to PDF is successful.

Create New org-mode File

Instructions

  1. Create a new org-mode file using emacs.

    For this tutorial, the filename will be journal-template.org

    • To create the file in emacs do the following:
      1. Press the key chords C-x C-f
      2. Type journal-template.org
      3. Press Return or Enter key
  2. Add mode line to top of the file.

    # -*- mode: org; org-confirm-babel-evaluate: nil; org-babel-noweb-wrap-start: "«"; org-babel-noweb-wrap-end: "»"; -*-
    

    TIP: To insert « press key chord C-x 8 < and to insert » press key chord C-x 8 >

  3. Add Template Utility Code Section to end of file.

    * Template Utility Code                                            :noexport:
    
  4. Add Common Export Settings Section to end of the file.

    * Common Export Settings                                           :noexport:
    
    #+OPTIONS: ':nil *:t -:t ::t <:nil H:4 \n:nil ^:{} arch:headline
    #+OPTIONS: author:nil broken-links:nil c:nil creator:nil
    #+OPTIONS: d:(not "LOGBOOK") date:nil e:t email:nil f:t inline:t num:nil
    #+OPTIONS: p:nil pri:nil prop:t stat:nil tags:t tasks:nil tex:t
    #+OPTIONS: timestamp:nil title:nil toc:nil todo:nil |:t
    #+SELECT_TAGS: export
    #+EXCLUDE_TAGS: noexport nolatex
    
    # For Display when file is exported with org-ruby 
    
    #+EXPORT_SELECT_TAGS: export
    #+EXPORT_EXCLUDE_TAGS: noexport
    
  5. Save the file in emacs.

    • To save the file in emacs do the following:
      1. Press the key chords C-x C-s

Self Check - Example 1

After completing the instructions in this section, the contents of journal-template.org should be similar to self-check-example-01.org.

Download LaTeX Template

For this How-To tutorial, the LaTeX template1 provided by the European Physical Journal A (EPJ A)2 will be used.

The following 3 files provided by the EPJ A will be needed in this tutorial:

  • template.tex

    The template.tex file is provided as "[a] fill-in-form for a standard article with usage comments"3.

    The objective of this How-To tutorial is migrate LaTeX code from template.tex into the new org-mode file.

  • svepj.clo

    The svepj.clo is the LaTeX "[c]lass option file for The European Physical Journal"4.

  • svjour.cls

    The svjour.cls is the LaTeX "[c]ore document class file for Springer journals"5.

Instructions

  1. Download template.tex file into same directory as journal-template.org.

  2. Download svepj.clo file into same directory as journal-template.org.

  3. Download svjour.cls file into same directory as journal-template.org.

Migrate LaTeX Template Code into file variables

In this section, the objective is migrate LaTeX code from LaTeX template into file varibles syntax at the bottom of the org-mode file. The file varibles will be used when exporting from org-mode back to LaTeX.

The LaTeX code that will be migrated into file variables syntax is located near the top of template.tex file:

%
\begin{filecontents}{leer.eps}
%!PS-Adobe-2.0 EPSF-2.0
%%CreationDate: Mon Jul 13 16:51:17 1992
%%DocumentFonts: (atend)
%%Pages: 0 1
%%BoundingBox: 72 31 601 342
%%EndComments

gsave
72 31 moveto
72 342 lineto
601 342 lineto
601 31 lineto
72 31 lineto
showpage
grestore
%%Trailer
%%DocumentFonts: Helvetica
\end{filecontents}
%
\documentclass[epj]{svjour}

TIP: When migrating the LaTeX code into file variables, you will need to double the backslashes \, e.g. \end will become \\end.

Instructions

  1. Add the following lines of file variables syntax to the end of the journal-template.org file.

    # Local Variables:
    # eval: (require (quote cl-lib))
    # eval: (require (quote ox))
    # eval: (require (quote ox-publish))
    # org-latex-with-hyperref: nil
    # eval: (add-to-list (quote org-latex-classes) (quote ("epj-svjour" "%%%%%%%%%%%%%%%%%%%%%%%% epj-svjour %%%%%%%%%%%%%%%%%%%%%%%%%%
    # %
    # \\begin{filecontents}{leer.eps}
    # %!PS-Adobe-2.0 EPSF-2.0
    # %%CreationDate: Mon Jul 13 16:51:17 1992
    # %%DocumentFonts: (atend)
    # %%Pages: 0 1
    # %%BoundingBox: 72 31 601 342
    # %%EndComments
    # 
    # gsave
    # 72 31 moveto
    # 72 342 lineto
    # 601 342 lineto
    # 601 31 lineto
    # 72 31 lineto
    # showpage
    # grestore
    # %%Trailer
    # %%DocumentFonts: Helvetica
    # \\end{filecontents}
    # %
    # \\documentclass[epj]{svjour}
    #  [NO-DEFAULT-PACKAGES]
    #  [PACKAGES]
    #  [EXTRA]" ("\\section{%s}" . "\\section*{%s}") ("\\subsection{%s}" . "\\subsection*{%s}") ("\\subsubsection{%s}" . "\\subsubsection*{%s}") ("\\paragraph{%s}" . "\\paragraph*{%s}") ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))))
    # End:
    
  2. Add the following line under the mode line near the top of the journal-template.org file.

    #+LATEX_CLASS: epj-svjour
    

Self Check - Example 2

After completing the instructions in this section, the contents of journal-template.org should be similar to self-check-example-02.org.

Migrate LaTeX Template Code into SRC blocks

In this section, the object is to migrate specific snippets of LaTeX code from the LaTeX template into SRC block syntax provided by org-mode. Each SRC block will inject customized LaTeX into the final LaTeX document created by the built-in exporter.

These template specific SRC blocks will be kept under a dedicated section named Template Utility Code which will not be exported.

Instructions

  1. Add the following lines after the * Template Utility Code section in the journal-template.org document.

    ** export-epj-latex-block
    
     #+NAME: export-epj-latex-block
     #+BEGIN_SRC latex :noweb yes
       %
       \title{«get-title-text()»}
       \subtitle{«get-subtitle-text()»}
       \author{«epj-authors-latex()»% etc
       % \thanks is optional - remove next line if not needed
       \thanks{\emph{Present address:} Insert the address here if needed}%
       }                     % Do not remove
       %
       \offprints{}          % Insert a name or remove this line
       %
       \institute{«epj-institutions-latex()»}
       %
       \date{Received: date / Revised version: date}
       % The correct dates will be entered by Springer
       %
       \abstract{
       «get-abstract-text()»
       %
       \PACS{
       «epj-pacs-codes-latex()»
        } % end of PACS codes
       } %end of abstract
       %
       \maketitle
     #+END_SRC
    
    *** get-title-text
    
     #+NAME: get-title-text
     #+BEGIN_SRC elisp 
       (format "%s" (car (plist-get (org-export-get-environment) ':title)))
     #+END_SRC
    
     #+RESULTS: get-title-text
     : Title Goes Here
    
    *** get-subtitle-text
    
     #+NAME: get-subtitle-text
     #+BEGIN_SRC elisp  :results replace :var keyword="subtitle" :var delimiter=" "
      (mapconcat 'car (org-element-map
           (org-element-parse-buffer)
           '(keyword)
         (lambda (x) (if (string= (upcase keyword) (org-element-property :key x))
              (list (org-element-property :value x)) )
           )
         ) delimiter)
     #+END_SRC
    
     #+RESULTS: get-subtitle-text
     : Subtitle Goes Here
    
    *** get-abstract-text
    
     #+NAME: get-abstract-text
     #+BEGIN_SRC elisp :results replace :var keyword="abstract"
       (org-element-map (org-element-map
                (org-element-parse-buffer)
                '(headline)
                  (lambda (hl) (if (string= (upcase keyword) (upcase (org-element-property :raw-value hl)))
                          hl)
                ) 
                  nil t)
           '(paragraph)
         (lambda (p) 
           (format "%s" (replace-regexp-in-string (rx (or (: bos (* (any " \t\n")))
                                  (: (* (any " \t\n")) eos)))
                              ""
                     (buffer-substring-no-properties (org-element-property :contents-begin p) (org-element-property :contents-end p))))
           )
         nil t)
     #+END_SRC
    
     #+RESULTS: get-abstract-text
     : The abstract goes here.
    
    *** epj-pacs-codes-latex 
    
     #+NAME: epj-pacs-codes-latex
     #+BEGIN_SRC elisp  :var pacs_codes=pacs-codes-table :results latex replace :var join_delim="   \\and\n"
       (mapconcat 'identity (mapcar (lambda (x) (format "      {%s}{%s}" (car x) (nth 1 x))) pacs_codes) join_delim)
     #+END_SRC
    
     #+RESULTS: epj-pacs-codes-latex
     #+BEGIN_EXPORT latex
           {PACS-key01}{Text Describing PACS-key01}   \and
           {PACS-key02}{Text Describing PACS-key02}
     #+END_EXPORT
    
    *** epj-authors-latex 
    
     #+NAME: epj-authors-latex
     #+BEGIN_SRC elisp  :var authors=authors-table :results latex replace :var join_delim=" \\and "
       (mapconcat 'identity (mapcar (lambda (x) (format "%s\\inst{%s}" (car x) (nth 2 x))) authors) join_delim)
     #+END_SRC
    
     #+RESULTS: epj-authors-latex
     #+BEGIN_EXPORT latex
     Mai Deah\inst{1} \and Arthur Secondus\inst{1} \and E. Tal\inst{2}
     #+END_EXPORT
    
    *** epj-institutions-latex 
    
     #+NAME: epj-institutions-latex
     #+BEGIN_SRC elisp  :var institutions=institutions-table :results latex replace :var join_delim=" \\and "
       (mapconcat 'identity (mapcar (lambda (x) (format "%s" (nth 1 x))) institutions) join_delim)
     #+END_SRC
    
     #+RESULTS: epj-institutions-latex
     #+BEGIN_EXPORT latex
     New Discoveries Lab, Department of Something-or-Ruther, University of Some-Sort, Some-Sort, Some-Sort-of-Country \and Golden Opportunities Lab, Department of Obscure Studies, Ancient College, Olde-Locale, Stodgy-Land
     #+END_EXPORT
    
  2. Add the following lines before the * Template Utitily Code section in the journal-template.org document.

    #+TITLE: Title Goes Here
    
    #+SUBTITLE: Subtitle Goes Here
    
    #+CALL: export-epj-latex-block()
    
    * Authors                                                          :nolatex:
    
    #+NAME: authors-table
    | Author          | Email                | Institution-ID |
    |-----------------+----------------------+----------------|
    | Mai Deah        | mai.deah@example.edu |              1 |
    | Arthur Secondus |                      |              1 |
    | E. Tal          |                      |              2 |
    
    * Institutions                                                     :nolatex:
    
    #+NAME: institutions-table
    | Institution-ID | Institution                                                                                                      |
    |----------------+------------------------------------------------------------------------------------------------------------------|
    |              1 | New Discoveries Lab, Department of Something-or-Ruther, University of Some-Sort, Some-Sort, Some-Sort-of-Country |
    |              2 | Golden Opportunities Lab, Department of Obscure Studies, Ancient College, Olde-Locale, Stodgy-Land               |
    
    * PACS                                                             :nolatex:
    
    #+NAME: pacs-codes-table
    | PACS-KEY   | PACS-KEY-Description-Text  |
    |------------+----------------------------|
    | PACS-key01 | Text Describing PACS-key01 |
    | PACS-key02 | Text Describing PACS-key02 |
    
    * Abstract                                                         :nolatex:
    
    # The abstract goes here.
    

Self Check - Example 3

After completing the instructions in this section, the contents of journal-template.org should be similar to self-check-example-03.org.

Add Content to org-mode File

In this section, several new placeholder sections will added. The content of each section will be Lorem Ipsum

Instructions

  1. Add content to journal-template.org.

    The migration to journal-template.org is complete. Adding real content will be left as an exercise for the reader.

Self Check - Example 4 - Part I

After completing the instructions in this section, the contents of journal-template.org should be similar to self-check-example-04.org.

Export completed org-mode file as PDF

In this section, the objective is to export the org-mode template to LaTeX and create a PDF.

Instructions

  1. Export an org-mode file as PDF via built-in LaTeX exporter.

    To export an org-mode document to PDF:

    1. Open the org-mode file in emacs.
    2. Position the cursor in the buffer of the org-mode document in emacs.
    3. Press the following key chords and keys, C-c C-e l p to initiate the export process.
    4. Open the exported PDF file to validate the export process succeeded.

Self Check - Example 4 - Part II

After completing the instructions in this section, the contents of journal-template.org should be similar to self-check-example-04.pdf.

Note: The LaTeX file created during the export should be similar to self-check-example-04.tex.

Footnotes

1 https://mc.manuscriptcentral.com/societyimages/epja/EPJA_templ.zip

2 https://epja.epj.org/

3 Description text for template.tex provided by EPJ A in read.me instructions.

4 Description text for svepj.clo provided by EPJ A in read.me instructions.

5 Description text for svjour.cls provided by EPJ A in read.me instructions.


This answer was validated using:
emacs: GNU Emacs 26.1
org-mode: 9.1.14

2

To use a specific journal template in Org Mode you need to create a LaTeX class. This is what I use in my init file for Springer journals:

(add-to-list 'org-latex-classes '("Springer"
               "\\documentclass[natbib]{svjour3}
               ("\\section{%s}" . "\\section*{%s}")
               ("\\subsection{%s}" . "\\subsection*{%s}")
               ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
               ("\\paragraph{%s}" . "\\paragraph*{%s}")
               ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))

To use this setup in your org file, reference the name you gave it.

#+LATEX_CLASS: Springer

All you have to do is to install the appropriate files in LaTeX, update your init file in Emacs. Example using the APA template is here: https://github.com/pprevos/r.prevos.net/tree/master/Miscellaneous/BodyImage

Your Answer

By clicking "Post Your Answer", you acknowledge that you have read our updated terms of service, privacy policy and cookie policy, and that your continued use of the website is subject to these policies.

Not the answer you're looking for? Browse other questions tagged or ask your own question.