0

A similar question has been put to the TeX community over here, which led to the insight that this is an org-export issue. Hence the current question:

The org document below generates a tex file that compiles as follows:

#+TITLE: Annotated Bibliography
#+OPTIONS:  H:3 author:nil

* Section Heading

** Subsection Heading

*** Numbered Heading

**** Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.

* Section Heading

** Subsection Heading

*** Unnumbered Heading

**** Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
:PROPERTIES:
:UNNUMBERED: t
:END:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.

Generated TeX document:

% Created 2020-10-08 Thu 19:05
% Intended LaTeX compiler: pdflatex

\documentclass[12pt,a4paper]{article}
%\documentclass[12pt,a4paper]{ctexart}

\usepackage{xeCJK}
\usepackage{zhnumber} % package for Chinese formatting of date time (use /zhtoday)
\usepackage[yyyymmdd]{datetime} % set date time to numeric

% For Generation of Citations and Bibliography
\usepackage[notes, isbn=false, backend=biber]{biblatex-chicago}
\bibliography{/Users/satibodhi/Creation/notes/bibliography/thesis}

% Set default indentation

\setlength\parindent{24pt}

% Set Paper Size, Page Layout (another variable is 'bindingoffset')
\usepackage[margin = 1.5in, paper = a4paper, inner = 2.5cm,
outer = 2.5cm, top = 3cm, bottom = 2.5cm]{geometry}

% Keep paragraph indentation while having a line break in between paragraphs.
\edef\restoreparindent{\parindent=\the\parindent\relax}
\usepackage{parskip}
\restoreparindent

% Indent first paragraph.
\usepackage{indentfirst}

\usepackage{titlesec}
\usepackage{titling}
\usepackage{fontspec} % packages for title and section-heading font setting.
\usepackage{newunicodechar} % custom fallback font for certain unicode characters.
\usepackage{tocloft} % adding the tocloft package for toc customization

% Set Header and Numbering Depth
\setcounter{tocdepth}{5}
\setcounter{secnumdepth}{5}

% Set Font.
\setsansfont{Times New Roman}
\setmainfont{Calibri} % Set serifed font to Calibri. Originally set to 'Times New Roman', but it cannot display certain characters such as ①②③.
\setCJKmainfont{Songti TC}
\setCJKsansfont{Kaiti TC} % Set Chinese font. NOTE: Remember to append CJK before of the font class. CJK HAS to be there for the font to show.
\setCJKmonofont{PingFang TC}

% Set fallback fonts for ㊀ characters.

\newCJKfontfamily\fallbackfont{PingFang TC}
\newunicodechar{㊀}{{\fallbackfont ㊀}}
\newunicodechar{㊁}{{\fallbackfont ㊁}}
\newunicodechar{㊂}{{\fallbackfont ㊂}}
\newunicodechar{㊃}{{\fallbackfont ㊃}}
\newunicodechar{㊄}{{\fallbackfont ㊄}}
\newunicodechar{㊅}{{\fallbackfont ㊅}}
\newunicodechar{㊆}{{\fallbackfont ㊆}}
\newunicodechar{㊇}{{\fallbackfont ㊇}}
\newunicodechar{㊈}{{\fallbackfont ㊈}}
\newunicodechar{㊉}{{\fallbackfont ㊉}}

% WHEN \documentclass is set to {article},
% zhnum[style={Traditional,Financial}] doesn't work with the section counter,
% so we define our own counter and increase it every time in \thesection.

\newcounter{mysec}[section]
\renewcommand\thesection{%
    \addtocounter{mysec}{1}%
    \zhnum[style={Traditional,Financial}]{mysec}、} % 大標題序號:壹、貳、參、…
\renewcommand\thesubsection{\zhnum{subsection}、} % added a 、小標題序號:一、二、三、…
\renewcommand\thesubsubsection{(\zhnum{subsubsection})} % added parentheses
% (full-width, don't know if that's what you want) 副標題序號:(一)(二)(三)
\renewcommand\theparagraph{\arabic{paragraph}} % arabic numbering for paragraph
\renewcommand\thesubparagraph{} % no subparagraph numbering

% we have to adjust the spacing in the toc because the section label is longer than usual
\addtolength\cftsecnumwidth{1em}
\addtolength\cftsubsecindent{1em}
\addtolength\cftsubsubsecindent{1em}

% Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.

% here we need to make sure the normal section counter is accessed
\titleformat{\section}{\LARGE\bfseries\sffamily\filcenter}
    {\zhnum[style={Traditional,Financial}]{section}、}{.5em}{}

\titleformat*{\subsection}{\Large\bfseries\sffamily}
\titleformat*{\subsubsection}{\large\bfseries\sffamily} % Set formats for each heading level. 'sffamily' will point to the sans-serif font. In this case, 「楷體」.

% The `titlesec` package is used over here to make use of `\paragraph` and `\subparagraph` as headings. Up to five levels of headings can be implemented this way.

% no extra version for numberless is necessary since no numbers are used anyways
% also you get newlines from omitting the [display] in \titleformat already
\titleformat{\paragraph}[block]
    {\large\bfseries\sffamily}{\theparagraph}{0em}{}
\titleformat{\subparagraph}[block]
    {\large\bfseries\sffamily}{}{0em}{}
% we need the following so that they don't indent (second argument, 0em);
% you'll have to adjust the spacing though since this is not display style anymore:
\titlespacing*{\paragraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}
\titlespacing*{\subparagraph}{0em}{3.25ex plus 1ex minus .2ex}{.75ex plus .1ex}

% Set title font.
\renewcommand{\maketitlehooka}{\sffamily}

% Set quotation font.
\usepackage{etoolbox}
\newCJKfontfamily\quotefont{Kaiti TC}
\AtBeginEnvironment{quote}{\quotefont\normalsize}

% Tweak default settings.
\renewcommand{\baselinestretch}{1.2} % Set line width.
\renewcommand{\contentsname}{\hfill\bfseries\Large 目\hspace{0.5cm} 錄\hfill} % Translate content page title to Chinese.
\renewcommand{\cftaftertoctitle}{\hfill} % Center contents title.
\renewcommand{\abstractname}{摘要} % Translate abstract title to Chinese.
\renewcommand{\tablename}{表} % Translate table to Chinese.
\renewcommand{\figurename}{圖} % Translate figure to Chinese.

% For text-boxes

\usepackage{mdframed}
\BeforeBeginEnvironment{minted}{\begin{mdframed}}
\AfterEndEnvironment{minted}{\end{mdframed}}

% For tables

\usepackage{float}
\restylefloat{table}

% [FIXME] ox-latex 的設計不良導致 hypersetup 必須在這裡插入
\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,}

\usepackage{hyperref}
\usepackage{graphicx}
\usepackage{longtable}
\usepackage{wrapfig}
\usepackage{rotating}
\usepackage[normalem]{ulem}
\usepackage{amsmath}
\usepackage{textcomp}
\date{\today}
\title{Annotated Bibliography}
\begin{document}

\maketitle
\tableofcontents \clearpage
\section{Section Heading}
\label{sec:org3a53a1d}

\subsection{Subsection Heading}
\label{sec:orgc4856dc}

\subsubsection{Numbered Heading}
\label{sec:orgb9d37be}

\begin{enumerate}
\item Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
\label{sec:org53c352d}

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.\\
\end{enumerate}

\section{Section Heading}
\label{sec:orgeab8943}

\subsection{Subsection Heading}
\label{sec:org1be7ca4}

\subsubsection{Unnumbered Heading}
\label{sec:org70aa910}

\begin{itemize}
\item Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
\label{sec:org25ccf60}
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.\\
\end{itemize}
\end{document}

As can be observed from the output below, there is no empty line between the label and the text body in the unnumbered section, which resulted in the text and heading mixing together in the second subsubsection.

Output:

difference between numbered and unnumbered heading

The issue doesn't seem to lie entirely with differences between numbered and unnumbered property settings because while differences remain when they are swapped:

swapped

A lone subsubsection which is numbered yields the same undesirable result.

#+TITLE: Annotated Bibliography
#+OPTIONS: d:(not "CITED") H:3 author:nil

* Section Heading

** Subsection Heading

*** Subsubsection Heading

**** Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
:PROPERTIES:
:END:
:CITED:

:END:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.

lone numbered heading test

Only when d:(not "CITED") is removed from the options do we get what we want in the output. Commenting out the second section without removing it entirely also yields normal results.

So my guess is that drawer settings somehow interfere with the LaTeX export function that result in having/not having an empty line added between the label and text body in the generated TeX file.

Is there a quick fix for this?


Update:

Adding a drawer to the numbered heading breaks the desired behavior. Whether it is PROPERTIES or CITED or any other, it doesn't matter.

#+TITLE: Annotated Bibliography
#+OPTIONS: H:3 author:nil

* Section Heading

** Subsection Heading

*** Numbered Heading

**** Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
:CITED:
:END:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.

* Section Heading

** Subsection Heading

*** Unnumbered Heading

**** Yang, X. (2006). A Moral Psychology without the Concept of Reason? History of Philosophy Quarterly, 23(4), 295–318.
:PROPERTIES:
:UNNUMBERED: t
:END:
:CITED:
:END:

Lorem ipsum dolor sit amet, consectetur adipiscing elit. Vivamus at vestibulum libero. Morbi mattis elit nunc, eu molestie neque dignissim ac. Praesent commodo neque volutpat ligula gravida, a placerat nunc fermentum. Curabitur pellentesque mollis nisi id aliquet. Integer pellentesque nulla a maximus dapibus. In non nisi turpis. Mauris condimentum hendrerit velit, vel ultrices purus commodo vel.

So it is confirmed that the bug has got something to do with the way drawers are coded.

desired behavior broken after adding drawer

8
  • It would help if you told us which version of Emacs and org-mode you're using, and whether you've tried the latest org releases. – rpluim Oct 8 '20 at 12:52
  • I wonder if the property drawer consumes the following character (the newline). If that's the case, having two blank lines after the drawer might help? – Tyler Oct 8 '20 at 13:48
  • @rpluim: GNU Emacs 27.1 (build 1, x86_64-apple-darwin18.7.0, NS appkit-1671.60 Version 10.14.6 (Build 18G95)) of 2020-08-12, org-mode 9.3. I've just installed the newest version for both. – Sati Oct 8 '20 at 14:31
  • @Tyler, I've tried adding more blank lines before the Lorem ipsum in the source file but that doesn't work. – Sati Oct 8 '20 at 14:37
  • Try adding `\` instead of an empty line. – NickD Oct 8 '20 at 19:22
1

It is not possible to nest an indefinite number of titles (see org-export-headline-levels). The limit depends on the back-end (see also org-latex-classes).

#+OPTIONS: H:4

In Org Mode, inferior headlines are converted in list items.

TLDR;

In the following snippet, the fourth heading is converted into an enumerate environment.

#+OPTIONS: H:3

* First headline
** Second headline
*** Third headline
**** Malformed headline
    :PROPERTIES:
    :END:

Subsequent text

What happened? An enigmatic code conversion: the following text seems to be just below the "title". More precisely, after an Org -> LaTeX conversion, we can see that the LaTeX code produces a visual rendering identical to the Org code as if there was no vertical spacing between the title and the following text in the original Org code.

Below, we can see that the sentence "Subsequent text" is included inside the enumerate environ­ment. It seems wrong for a LaTeX author¹ although it's the expected behavior in Org Mode. Indeed, everything between two headlines is usually part of the same group (see below).

\begin{enumerate}
\item Malformed headline
\label{sec:org025ca38}

Subsequent text
\end{enumerate}

In any case, the back-end limit for document structuring is reached before: in LaTeX, lists are not used as section titles.

This issue doesn't occur using the "right code" (see below). A possible issue is assigning properties to a paragraph, is this sensible?

#+OPTIONS: H:4

* First headline
** Second headline
*** Third headline
**** Malformed headline
     :PROPERTIES:
     :END:

Subsequent text
\paragraph{Malformed headline}
\label{sec:org6999b6a}
Subsequent text

¹ For me, the paragraph should be outside the enumerate environment.

5
  • 3
    Although this is true, I don't see what it has to do with the question. – NickD Oct 8 '20 at 21:12
  • This would make the bibliography appear on the TOC, which is not what I want. – Sati Oct 9 '20 at 4:12
  • 1
    @SxE equals 10n minus 2n, If you wish to number your headings using enumerate in LaTeX, it would be impossible to place the paragraph outside the enumerate environment. I think it is quite sensible to place text within a paragraph environment instead of enumerate, though. – Sati Oct 9 '20 at 21:33
  • I just realized that setting unnumbered to true leaves the heading out of the TOC. Which means this could be a solution after all. But that still leaves the mystery of the missing empty line unsolved. – Sati Oct 10 '20 at 4:11
  • @Sati: You are right but the back-end limit for document structuring is reached before: in LaTeX lists are not used as section titles. – user19761 Oct 10 '20 at 8:40

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.