Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7083961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T07:14:34+00:00 2026-05-28T07:14:34+00:00

When I do C-c C-e l to export an Org file to LaTeX it

  • 0

When I do C-c C-e l to export an Org file to LaTeX it produces a document with a particular preamble. Instead of this particular preamble I would like it to use a preamble of my choice. Say that I want it to use the following preamble:

% Don't forget to qpdf --linearize the final copy
\RequirePackage[l2tabu,orthodox]{nag}% Old habits die hard. All the same, there are commands, classes and packages which are outdated and superseded. nag provides routines to warn the user about the use of those.
\immediate\write18{sh ./vc}
\input{vc}% Version control macros (for \VCDateISO in \date) http://www.ctan.org/pkg/vc
\documentclass[a4paper,12pt]{article}% pt? doublepage?
%\usepackage{geometry}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}
\usepackage{lmodern}% Latin Modern (derivate of Knuth's CM)
\usepackage{fixltx2e}% \textsubscript and bugfixes for LaTeX
\usepackage{microtype}
\usepackage[strict=true]{csquotes}% Context-sensistive quotes. \enquote "" \enquote* ''. Use the integrated commands \textcquote and \blockcquote rather than biblatex internal commands to get contex sensistive quotes for them too. s/babel/autostyle in new version.
\usepackage[bookmarks,pdfborder={0 0 0}]{hyperref}% links and pdfinfo. MUST BE LOADED LAST!

\hypersetup{% Setup for hyperref
pdftitle    = {[Title from #+TITLE]},
pdfauthor   = {[Author from #+AUTHOR]}
}

I know that you can manipulate which packages are used on a per file basis as described in the manual but I want this preamble to be used for all files unless ) specify otherwise. The preamble I want to use includes the following:

  • deactivated packages (such as geometry above)
  • packages loaded by RequirePackage
  • input macros
  • \immediate\write18 macros
  • comments after usepackage macros
  • a hypersetup macro that recognizes #+TITLE and #+AUTHOR from Org-mode files
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T07:14:35+00:00Added an answer on May 28, 2026 at 7:14 am

    Deactivated packages (such as geometry above)

    Org-mode recognizes LaTeX syntax inside LaTeX code-blocks, as well as when including LaTeX files in the content. (See Quoting LaTeX code.)

    Packages loaded by RequirePackage

    As above.

    Input macros

    As above.

    \immediate\write18 macros

    I believe this should also be as above, however there is an alternate method of dealing with this. If you create a source code block of type sh with the command within it, Org will evaluate it on export and produce the desired behaviour. You have to enable sh as a babel language type for it to work however.

    (require 'ob-shell)
    

    You can also include sh as one of the languages loaded by babel by adding it to org-babel-load-languages

    (acons 'sh 't org-babel-load-languages)
    

    Then use a code block similar to the following to run your ./vc

    #+name: Test
    #+begin_src sh :results output silent :exports results
      ./vc
    #+end_src
    

    As long as this comes before your \input{vc} line it should run the code and then include it. Simply follow the code-block with

    #+LATEX: \input{vc}
    

    And your content should be included.

    Comments after usepackage macros

    If the code is within a LaTeX block it should recognize it as LaTeX.

    A hypersetup macro that recognizes #+TITLE and #+AUTHOR from Org-mode files.

    This will have to be included within each document rather than separate. The following will provide what you desire for your macros. It will not be within the preamble, however it will end up at the top of the document and the export does behave as expected (however it will not behave as expected if added through #+INCLUDE: from org.

    #+begin_latex
      \hypersetup{% Setup for hyperref
      pdftitle    = {{{{TITLE}}}}, %Org macro to take from #+TITLE
      pdfauthor   = {{{{AUTHOR}}}} %Org macro to take from #+AUTHOR
      }
    #+end_latex
    

    Creating your own Latex export class

    If you follow the instructions in the worg tutorials (See Org Latex Export) you can create your own export-class. If you want to have full control over the packages in the preamble you would simply need to:

    (add-to-list 'org-export-latex-classes
                 '("<CLASS NAME>"
                   "\\documentclass{article}
                   [NO-DEFAULT-PACKAGES]
                   [NO-PACKAGES]"
                   <insert desired sectioning configuration>))
    

    You can also add in your desired packages between the \\documentclass and [NO-DEFAULT-PACKAGES] lines. The alternative would be to add them to the file itself using:

    #+LATEX_CLASS: <CLASS NAME>
    #+LATEX_HEADER: \usepackage{package}
    ...
    

    As a third option, you can simply create a custom .sty file with the desired packages etc and include it as a single #+LATEX_HEADER:.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I export an Excel document with DisplayTag. It saves as a .xls file to
When using Org-mode and its LaTeX export BibTeX or Biblatex is often used to
I've got [16] in an org-mode file that is the text you would see
I would like to use Subversion and checkout only source files (for example: checking
I'm using http://www.openstreetmap.org/ export utility to generate a .osm (xml map file) of an
I use Emacs Org-mode to write some documents, and I describe some files like
I have a org file with source, documentation and latex code. Latex stuff draws
http://en.wikipedia.org/wiki/ICalendar I'm working to implement an export feature for events. The link above lists
I'm speaking of this module: http://docs.python.org/library/operator.html From the article: The operator module exports a
export PATH=${/home/mohit/}:<android-sdk-linux_86>/tools this is what i am using.. error:-- bash: PATH=${/home/mohit/}:: bad substitution this

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.