literate-programming-tutorials/how-to/00-convert-latex-template-into-org-mode-template/how-to-migrate-latex-template-into-org-mode.org

75 KiB

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.

Footnotes


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.