For the following sample,

#+LATEX_CMD: xelatex
#+LATEX_HEADER: \usepackage{xltxtra}
#+OPTIONS: ^:nil

This is a _test_

The export to PDF uses xelatex would produce the following error:

! Undefined control sequence.
l.28 This is a \uline
! Emergency stop.
l.28 This is a \uline
No pages of output.

If I use pdflatex then there is no such error. (I have to use xelatex for exporting text with Chinese.)

What would be the solution with xelatex?

  • 2
    Does #+LATEX_HEADER: \usepackage{ulem}\usepackage{fixltx2e} help? The fixltx2e hint with respect to xelatex is from golatex.de/…. – Tobias Jun 22 '18 at 20:04
  • Yes, and actually, adding #+LATEX_HEADER: \usepackage{ulem} alone would make it work as expected. Thanks! – Yu Shen Jun 22 '18 at 21:12

The LaTeX command \uline is defined in the LaTeX package ulem. You can load that package during PDF export with the following line in your org-file.

#+LATEX_HEADER: \usepackage{ulem}

Fine if that already helps. Nevertheless a problem of ulem with XeLaTeX is reported at golatex.de. Following that thread the workaround would be:

#+LATEX_HEADER: \usepackage{ulem}\usepackage{fixltx2e}

Note that in org-version 9.1.6 ulem is already present in org-latex-default-packages-alist as entry ("normalem" "ulem" t).

If you have already that or a newer version of org-mode then it might be that you have modified org-latex-default-packages-alist and that list is not upgraded for you.

Otherwise you could just upgrade to the newest stable version of org-mode from melpa. If you do not like to upgrade for any reason maybe you can add the ulem entry to org-latex-default-packages-alist.

|improve this answer|||||
  • Thanks, indeed, I have customized org-latex-default-packages-alist with probably partial and outdated content without ("normalem" "ulem" t) – Yu Shen Jun 23 '18 at 2:46

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.