2

Somewhere long ago I read I could use additional latex packages in org-mode using:

(setq org-latex-packages-alist '())
(add-to-list 'org-latex-packages-alist '("" "color" t))
(add-to-list 'org-latex-packages-alist '("" "physics" t))
(add-to-list 'org-latex-packages-alist '("" "mathtools" t))
(add-to-list 'org-latex-packages-alist '("" "xfrac" t))
(add-to-list 'org-latex-packages-alist '("" "siunitx" t))
(add-to-list 'org-latex-packages-alist '("" "mhchem" t))
(add-to-list 'org-latex-packages-alist '("" "fontenc" t))
(add-to-list 'org-latex-packages-alist '("" "multirow" t))

After updating my system I noticed latex images weren't being rendered. Investigating in /tmp, I discovered that mhchem wanted me to specify it's version number.

!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
!
! mhchem error: "options/no-version"
! 
! You did not specify a 'version' option for the mhchem package. Please write
! \usepackage[version=3]{mhchem} in your preamble (or any lower number for
! compatibility mode).
! 
! See the mhchem documentation for further information.
! 
! Type <return> to continue.
!...............................................  

l.2971   }

? 
! Emergency stop.
!...............................................  

l.2971   }

|'''''''''''''''''''''''''''''''''''''''''''''''
| LaTeX does not know anything more about this error, sorry.
| 
| Try typing <return> to proceed.
| If that doesn't work, type X <return> to quit.
|...............................................

By educated guess and trial and error, I determined I needed to put version=3 in the first set of quotations. I was wondering if this was documented anywhere?

  • 2
    You know you can just add this to the Org file header, right? #+LATEX_HEADER: \usepackage[version=3]{mhchem}. But there is almost certainly a way of specifying the version the way you originally intended too, but I wouldn't know it off top of my head. – wvxvw Apr 11 '15 at 19:58
  • 1
    Actually, I tried to explain in the question that I had figured it out. I just need to make it '("version=3" "mhchem" t). What I was looking for was documentation for this as I don't remember where I found that I could do this in the first place. – wdkrnls Apr 11 '15 at 20:58
  • 1
    Ah, sorry, I see now. Well, I guess you can say its documented. If you look at C-h v org-latex-packages-alist, you'll see it says "options" when it describes what goes into that variable. – wvxvw Apr 12 '15 at 6:07
  • You do realize that you can just write (setq org-latex-packages-alist '(("" "color" t) ("" "physics" t)...))? And that you can simply use Customize to set the complete value? And that as a general rule you should use Customize (or the custom* functions), not setq, to set user options? – Drew Apr 13 '15 at 5:48
  • 1
    Dunno what you mean. If you don't want to use the Customize UI, then use the custom-* and customize-* functions in your init file. Such functions, like the UI, take all of the parts of a defcustom into account, including :set, :type, and :initialize. This means that they take care of type-checking and properly initializing and applying update (:set) triggers. When you use just setq you are out in the jungle with just a pocketknife. – Drew Apr 13 '15 at 16:42
6

Here's the relevant info from the documentation of org-latex-packages-alist (you can view it by pressing C-hv org-latex-packages-alist.

org-latex-packages-alist is a variable defined in org.el.

Its value is (("AUTO" "inputenc" t))

Original value was nil

Documentation: Alist of packages to be inserted in every LaTeX header.

These will be inserted after org-latex-default-packages-alist. Each element is either a cell or a string.

A cell is of the format:

("options" "package" SNIPPET-FLAG)

SNIPPET-FLAG, when non-nil, indicates that this package is also needed when turning LaTeX snippets into images for inclusion into non-LaTeX output.

A string will be inserted as-is in the header of the document.

Make sure that you only list packages here which:

  • you want in every file;
  • do not conflict with the setup in org-format-latex-header;
  • do not conflict with the default packages in org-latex-default-packages-alist.

You can customize this variable.

The option place in the cell is where the version=3 should go in your case.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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