5

I want to export an Org file into PDF, with any depth titles showed in TOC; however, cannot works. Even though adding \setcounter{tocdepth}{5}, TOC still only contains the title of 3rd depth (\subsubsection).

I check the TeX file it exported: org-export seemed to ignore my setting for org-latex-classes, and just convert **** into '\item instead of \paragraph. But I cannot find some worked solution for this...

Following is my org-latex-classes:

(setq org-latex-classes
  '(("article"         "
\\documentclass[10pt,a4paper]{article}
\\usepackage[margin=2cm]{geometry}
\\usepackage{fontspec}

\\XeTeXlinebreakskip = 0pt plus 1pt
\\linespread{1.36}

\\setcounter{tocdepth}{5}

\\usepackage{multicol}

\\usepackage{hyperref}
\\hypersetup{
  colorlinks=true,
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  pagebackref=true,
  linktoc=all,}
"
 ("\\section{%s}" . "\\section*{%s}")
 ("\\subsection{%s}" . "\\subsection*{%s}")
 ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
 ("\\paragraph{%s}" . "\\paragraph*{%s}")
 ("\\subparagraph{%s}" . "\\subparagraph*{%s}"))
    )
  )
1
  • This isn't really about TOCs. It's about headlines not getting exported as paragraphs (there's a setting for that, the name eludes me now).
    – Malabarba
    Commented Dec 28, 2014 at 23:01

2 Answers 2

3

Try something like this:

;; This buffer is for notes you don't want to save, and for Lisp evaluation.
;; If you want to create a file, visit that file with C-x C-f,
;; then enter the text in that file's own buffer.

(let ((org-latex-classes
   '(("my-article" "
\\documentclass[10pt,a4paper]{article}
\\usepackage[margin=2cm]{geometry}
\\usepackage{fontspec}

\\XeTeXlinebreakskip = 0pt plus 1pt
\\linespread{1.36}

\\setcounter{tocdepth}{5}

\\usepackage{multicol}

\\usepackage{hyperref}
\\hypersetup{
  colorlinks=true,
  linkcolor=[rgb]{0,0.37,0.53},
  citecolor=[rgb]{0,0.47,0.68},
  filecolor=[rgb]{0,0.37,0.53},
  urlcolor=[rgb]{0,0.37,0.53},
  pagebackref=true,
  linktoc=all,}"
      ("\\section{%s}" . "\\section*{%s}")
      ("\\subsection{%s}" . "\\subsection*{%s}")
      ("\\subsubsection{%s}" . "\\subsubsection*{%s}")
      ("\\paragraph{%s}" . "\\paragraph*{%s}")
      ("\\subparagraph{%s}" . "\\subparagraph*{%s}")))))
  (with-temp-buffer
(insert
 (mapconcat 'identity
        '("#+LATEX_CLASS: my-article"
          "#+OPTIONS: h:5 num:3"
          "* section"
          "** subsection"
          "*** subsubsection"
          "**** paragraph"
          "***** subparagraph")
        "\n"))
(org-latex-export-as-latex nil nil nil t)))

=>

\section{section}
\label{sec-1}
\subsection{subsection}
\label{sec-1-1}
\subsubsection{subsubsection}
\label{sec-1-1-1}
\paragraph*{paragraph}
\label{unnumbered-1}
\subparagraph*{subparagraph}
\label{unnumbered-2}

For more info see http://orgmode.org/org.html#Export-settings.

3

In org mode manual, LaTeX-header-and-sectioning

The LaTeX export back-end converts the first three of Org’s outline levels into LaTeX headlines. The remaining Org levels are exported as lists. To change this globally for the cut-off point between levels and lists, (see note Export Settings).

In Export-Settings, this is the setting to change the levels to be converted.

H
Set the number of headline levels for export (‘org-export-headline-levels’). Below that level, headlines are treated differently. In most back-ends, they become list items.

so, you could add this at the beginning of your org file, so the 4th level to be exported would be (in your case) \paragraph

#+OPTIONS: H:5

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

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